Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
| 2 |
from fastapi.responses import HTMLResponse
|
| 3 |
from pydantic import BaseModel
|
| 4 |
from fastapi.responses import JSONResponse, StreamingResponse
|
|
@@ -150,12 +150,12 @@ async def chat_gpt_stream_fun(content: Text = None):
|
|
| 150 |
print(f"Full conversation received: {full_reply_content}")
|
| 151 |
content = {'content': full_reply_content}
|
| 152 |
print('content:', content)
|
| 153 |
-
yield
|
| 154 |
|
| 155 |
|
| 156 |
-
@app.post("/chatgptstream")
|
| 157 |
async def get_random_numbers(content: Text = None):
|
| 158 |
-
return StreamingResponse(chat_gpt_stream_fun(content))
|
| 159 |
|
| 160 |
|
| 161 |
@app.post("/embeddings")
|
|
|
|
| 1 |
+
from fastapi import FastAPI, status
|
| 2 |
from fastapi.responses import HTMLResponse
|
| 3 |
from pydantic import BaseModel
|
| 4 |
from fastapi.responses import JSONResponse, StreamingResponse
|
|
|
|
| 150 |
print(f"Full conversation received: {full_reply_content}")
|
| 151 |
content = {'content': full_reply_content}
|
| 152 |
print('content:', content)
|
| 153 |
+
yield json.dumps(content) + '\n'
|
| 154 |
|
| 155 |
|
| 156 |
+
@app.post("/chatgptstream", status_code=status.HTTP_200_OK)
|
| 157 |
async def get_random_numbers(content: Text = None):
|
| 158 |
+
return StreamingResponse(chat_gpt_stream_fun(content), media_type='application/json')
|
| 159 |
|
| 160 |
|
| 161 |
@app.post("/embeddings")
|