Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -191,6 +191,7 @@ def get_completion(message,history,profile: gr.OAuthProfile | None,oauth_token:
|
|
191 |
|
192 |
# headers
|
193 |
openai_api_key = os.environ.get('openai_api_key')
|
|
|
194 |
headers = {
|
195 |
'Authorization': f'Bearer {openai_api_key}'
|
196 |
}
|
@@ -212,7 +213,7 @@ def get_completion(message,history,profile: gr.OAuthProfile | None,oauth_token:
|
|
212 |
}
|
213 |
|
214 |
# get response
|
215 |
-
# response = requests.post(
|
216 |
# response_data = response.json()
|
217 |
# print(response_data)
|
218 |
# print('-----------------------------------\n')
|
@@ -224,7 +225,7 @@ def get_completion(message,history,profile: gr.OAuthProfile | None,oauth_token:
|
|
224 |
# return response_content
|
225 |
|
226 |
# get response with stream
|
227 |
-
response = requests.post(
|
228 |
response_content = ""
|
229 |
for line in response.iter_lines():
|
230 |
line = line.decode().strip()
|
|
|
191 |
|
192 |
# headers
|
193 |
openai_api_key = os.environ.get('openai_api_key')
|
194 |
+
base_url = os.environ.get('base_url')
|
195 |
headers = {
|
196 |
'Authorization': f'Bearer {openai_api_key}'
|
197 |
}
|
|
|
213 |
}
|
214 |
|
215 |
# get response
|
216 |
+
# response = requests.post(base_url, headers=headers, json=data)
|
217 |
# response_data = response.json()
|
218 |
# print(response_data)
|
219 |
# print('-----------------------------------\n')
|
|
|
225 |
# return response_content
|
226 |
|
227 |
# get response with stream
|
228 |
+
response = requests.post(base_url, headers=headers, json=data,stream=True)
|
229 |
response_content = ""
|
230 |
for line in response.iter_lines():
|
231 |
line = line.decode().strip()
|