Update main.py
Browse files
main.py
CHANGED
@@ -197,7 +197,14 @@ async def chat_completions(request: ChatRequest):
|
|
197 |
|
198 |
response_content = ""
|
199 |
async for chunk in async_generator:
|
200 |
-
|
|
|
|
|
|
|
201 |
|
202 |
-
|
|
|
|
|
|
|
203 |
|
|
|
|
197 |
|
198 |
response_content = ""
|
199 |
async for chunk in async_generator:
|
200 |
+
if isinstance(chunk, str):
|
201 |
+
response_content += chunk
|
202 |
+
else:
|
203 |
+
response_content += chunk.content
|
204 |
|
205 |
+
# Clean up the response to get only the plain text content
|
206 |
+
start = response_content.find('"content": "') + len('"content": "')
|
207 |
+
end = response_content.find('"', start)
|
208 |
+
clean_content = response_content[start:end].replace('\\n', '\n') # Handle newline characters
|
209 |
|
210 |
+
return Response(content=clean_content.strip(), media_type="text/plain") # Return plain text
|