(question: string)
| 11 | |
| 12 | export class ChatGPTClient { |
| 13 | async getAnswer(question: string): Promise<string> { |
| 14 | const { model, maxTokens, temperature } = await getPromptOptions(); |
| 15 | |
| 16 | try { |
| 17 | const result = await openai.createCompletion({ |
| 18 | model, |
| 19 | prompt: question, |
| 20 | max_tokens: maxTokens, |
| 21 | temperature, |
| 22 | }); |
| 23 | return result.data.choices[0].text; |
| 24 | } catch (e) { |
| 25 | console.error(e?.response ?? e); |
| 26 | throw e; |
| 27 | } |
| 28 | |
| 29 | // @ts-ignore |
| 30 | } |
| 31 | } |
no test coverage detected