Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -18,11 +18,11 @@ import random
|
|
18 |
|
19 |
import httpx # add 11/13/23
|
20 |
import asyncio
|
21 |
-
|
22 |
-
from openai import AsyncOpenAI
|
23 |
-
client =
|
24 |
# defaults to os.environ.get("OPENAI_API_KEY")
|
25 |
-
|
26 |
)
|
27 |
|
28 |
|
@@ -165,13 +165,13 @@ async def chat_with_model(prompt, document_section, model_choice='gpt-3.5-turbo'
|
|
165 |
key = os.getenv('OPENAI_API_KEY')
|
166 |
client.api_key = key
|
167 |
|
168 |
-
client =
|
169 |
-
stream =
|
170 |
prompt="Say this is a test",
|
171 |
messages=[{"role": "user", "content": "Say this is a test"}],
|
172 |
stream=True,
|
173 |
)
|
174 |
-
|
175 |
chunk_message = (part.choices[0].delta.content or "")
|
176 |
collected_messages.append(chunk_message) # save the message
|
177 |
content=chunk["choices"][0].get("delta",{}).get("content")
|
|
|
18 |
|
19 |
import httpx # add 11/13/23
|
20 |
import asyncio
|
21 |
+
from openai import OpenAI
|
22 |
+
#from openai import AsyncOpenAI
|
23 |
+
client = OpenAI(
|
24 |
# defaults to os.environ.get("OPENAI_API_KEY")
|
25 |
+
api_key= os.getenv('OPENAI_API_KEY')
|
26 |
)
|
27 |
|
28 |
|
|
|
165 |
key = os.getenv('OPENAI_API_KEY')
|
166 |
client.api_key = key
|
167 |
|
168 |
+
client = OpenAI()
|
169 |
+
stream = client.chat.completions.create(
|
170 |
prompt="Say this is a test",
|
171 |
messages=[{"role": "user", "content": "Say this is a test"}],
|
172 |
stream=True,
|
173 |
)
|
174 |
+
for part in stream:
|
175 |
chunk_message = (part.choices[0].delta.content or "")
|
176 |
collected_messages.append(chunk_message) # save the message
|
177 |
content=chunk["choices"][0].get("delta",{}).get("content")
|