I want to use OpenAi GPT-3 api but I don’t find a proper way to configure the coding.
Are you a developer?
If no, go to Wix marketplace and hire a dev.
If yes, then you can do so with:
-
Install NPM module.
-
Write backend exported function
-
Write frontend code with UI elements to allow user to call the backend API.
I have figured out how to connect to openai but I’m getting error 401.
See my code below, please help.
import wixSecretsBackend from ‘wix-secrets-backend’ ;
import { fetch } from ‘wix-fetch’ ;
export const askOpenAi = async () => {
const { Configuration , OpenAIApi } = require ( “openai” );
const configuration = new Configuration ({
apiKey : wixSecretsBackend . getSecret ( “OpenAi” ),
});
const openai = new OpenAIApi ( Configuration );
const prompt = input: What is human life expectancy in the United States? output:
const response = await openai . createCompletion ( “text-davinci-001” , {
prompt : prompt ,
temperature : 0 ,
max_tokens : 100 ,
top_p : 1 ,
frequency_penalty : 0 ,
presence_penalty : 0 ,
stop : [ “input:” ],
});
return response . data ;
}
Hey @vishalkasbe40
It can be difficult to setup AI chats with code. With Chat with GPT Canvas, you can do the same by simply adding the widget to any page you like. It supports normal conversation and docs editing well. Give it a try!