Skip to content

Commit

Permalink
fix call to openai
Browse files Browse the repository at this point in the history
  • Loading branch information
yann300 committed Aug 29, 2023
1 parent 55d26e6 commit 853713d
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 152 deletions.
28 changes: 14 additions & 14 deletions apps/remix-ide/src/app/plugins/openaigpt.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Plugin } from '@remixproject/engine'
import { OpenAIApi, CreateChatCompletionResponse } from 'openai'
import { CreateChatCompletionResponse } from 'openai'

const _paq = window._paq = window._paq || []
const _paq = (window._paq = window._paq || [])

const profile = {
name: 'openaigpt',
Expand All @@ -13,25 +13,25 @@ const profile = {
}

export class OpenAIGpt extends Plugin {
openai: OpenAIApi

constructor() {
super(profile)
}

async message(prompt): Promise<CreateChatCompletionResponse> {
this.call('terminal', 'log', 'Waiting for GPT answer...')
const result = await (await fetch('https://openai-gpt.remixproject.org', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({prompt})
})).json()

const result = await (
await fetch('https://openai-gpt.remixproject.org', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({ prompt }),
})
).json()

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

0 comments on commit 853713d

Please sign in to comment.