Niansuh commited on
Commit
4e59b46
·
verified ·
1 Parent(s): 4e4fed1

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -2
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
- response_content += chunk if isinstance(chunk, str) else chunk.content
 
 
 
201
 
202
- return Response(content=response_content.strip(), media_type="text/plain") # Return plain text
 
 
 
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