|
|
|
@ -19,7 +19,9 @@ export class OpenAIGpt extends Plugin { |
|
|
|
|
|
|
|
|
|
async message(prompt): Promise<CreateChatCompletionResponse> { |
|
|
|
|
this.call('terminal', 'log', 'Waiting for GPT answer...') |
|
|
|
|
const result = await ( |
|
|
|
|
let result |
|
|
|
|
try { |
|
|
|
|
result = await ( |
|
|
|
|
await fetch('https://openai-gpt.remixproject.org', { |
|
|
|
|
method: 'POST', |
|
|
|
|
headers: { |
|
|
|
@ -29,9 +31,16 @@ export class OpenAIGpt extends Plugin { |
|
|
|
|
body: JSON.stringify({ prompt }), |
|
|
|
|
}) |
|
|
|
|
).json() |
|
|
|
|
} catch (e) { |
|
|
|
|
this.call('terminal', 'log', { type: 'typewritererror', value: `Unable to get a response ${e.message}` }) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log(result) |
|
|
|
|
if (result && result.choices && result.choices.length) { |
|
|
|
|
this.call('terminal', 'log', { type: 'typewritersuccess', value: result.choices[0].message.content })
|
|
|
|
|
} else { |
|
|
|
|
this.call('terminal', 'log', { type: 'typewritersuccess', value: 'No response...' }) |
|
|
|
|
} |
|
|
|
|
return result.data |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|