awacke1 commited on
Commit
b4dc760
·
1 Parent(s): 75f1b97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -18,11 +18,11 @@ import random
18
 
19
  import httpx # add 11/13/23
20
  import asyncio
21
- #from openai import OpenAI
22
- from openai import AsyncOpenAI
23
- client = AsyncOpenAI(
24
  # defaults to os.environ.get("OPENAI_API_KEY")
25
- # api_key="My API Key",
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 = AsyncOpenAI()
169
- stream = await 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
- async 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")
 
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")