You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{ChatGPT}from"chatgpt-official";letoptions={temperature: 0.7,// OpenAI parametermax_tokens: 100,// OpenAI parameter [Max response size by tokens]top_p: 0.9,// OpenAI parameterfrequency_penalty: 0,// OpenAI parameterpresence_penalty: 0,// OpenAI parameterinstructions: `You are ChatGPT, a large language model trained by OpenAI.`,// initial instructions for the botmodel: "gpt-3.5-turbo",// OpenAI parameter `gpt-3.5-turbo` is PAID};letbot=newChatGPT("<OPENAI_API_KEY>",options);// Note: options is optionalletresponse=awaitbot.ask("Hello?");console.log(response);letconversationId="conversation name";letresponse1=awaitbot.ask("Hello?",conversationId);console.log(response1);letconversationId2="another conversation name";letresponse2=awaitbot.ask("Hello?",conversationId2);console.log(response2);
Usage: Creating ChatGPT with Official OpenAI Completion API
import{OpenAI}from"chatgpt-official";letoptions={temperature: 0.7,// OpenAI parametermax_tokens: 256,// OpenAI parameter [Max response size by tokens]top_p: 0.9,// OpenAI parameterfrequency_penalty: 0,// OpenAI parameterpresence_penalty: 0,// OpenAI parameterinstructions: `You are ChatGPT, a large language model trained by OpenAI.`,// initial instructions for the botmodel: "text-davinci-003",// OpenAI parameter `text-davinci-003` is PAIDstop: "<|im_end|>",// OpenAI parameter};letbot=newOpenAI("<OPENAI_API_KEY>",options);// Note: options is optionalletresponse=awaitbot.ask("Hello?");console.log(response);letconversationId="conversation name";letresponse1=awaitbot.ask("Hello?",conversationId);console.log(response1);letconversationId2="another conversation name";letresponse2=awaitbot.ask("Hello?",conversationId2);console.log(response2);