We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 94ad9f1 commit ecf6123Copy full SHA for ecf6123
stacks/src/streamingGpt4QuestionAnswerTTS/index.ts
@@ -0,0 +1,17 @@
1
+import OpenAI from 'openai';
2
+
3
+const openai = new OpenAI({
4
+ apiKey: process.env.OPENAI_API_KEY
5
+});
6
7
+/**
8
+ * Brief: Call gpt-4 using the streaming endpoint to answer my question and TTS the voice in real time
9
+ */
10
+export default async function streamingGpt4QuestionAnswerTTS(input: string): Promise<string> {
11
+ const chatCompletion = await openai.chat.completions.create({
12
+ messages: [{ role: 'user', content: input }],
13
+ model: 'gpt-3.5-turbo',
14
+ });
15
16
+ return chatCompletion.choices[0].message.content;
17
+}
0 commit comments