Skip to content

Commit

Permalink
use remixproject endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
yann300 committed Jun 26, 2023
1 parent b9e4fa4 commit cf48c25
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions apps/remix-ide/src/app/plugins/openaigpt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,21 @@ export class OpenAIGpt extends Plugin {

constructor() {
super(profile)
const configuration = new Configuration({
apiKey: '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',
});
this.openai = new OpenAIApi(configuration)
}

async message(prompt): Promise<CreateChatCompletionResponse> {
this.call('terminal', 'log', 'Waiting for GPT answer...')
const result = await this.openai.createChatCompletion(
{
model: "gpt-3.5-turbo",
messages: [{role: "user", content: prompt}]
const result = await (await fetch('https://openai-gpt.remixproject.org', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
{
timeout: 10000,
headers: {
"Authorization": "Bearer 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",
},
}
)
const response: CreateChatCompletionResponse = result.data
console.log(response)
this.call('terminal', 'log', { type: 'typewriterlog', value: response.choices[0].message.content })
body: JSON.stringify({prompt})
})).json()

console.log(result)
this.call('terminal', 'log', { type: 'typewriterlog', value: result.choices[0].message.content })
return result.data
}
}

0 comments on commit cf48c25

Please sign in to comment.