Update api/utils.py
Browse files- api/utils.py +3 -4
api/utils.py
CHANGED
@@ -7,7 +7,6 @@ from api.logger import logger
|
|
7 |
from api.config import MODEL_MAPPING, EDITEA_API_ENDPOINT, EDITEA_HEADERS
|
8 |
from fastapi import HTTPException
|
9 |
|
10 |
-
# Editee class is now integrated within utils.py
|
11 |
class Editee:
|
12 |
label = "Editee"
|
13 |
url = "https://editee.com"
|
@@ -45,7 +44,6 @@ class Editee:
|
|
45 |
**kwargs
|
46 |
):
|
47 |
model = cls.get_model(model)
|
48 |
-
|
49 |
headers = EDITEA_HEADERS
|
50 |
|
51 |
async with ClientSession(headers=headers) as session:
|
@@ -109,7 +107,7 @@ async def process_response(request: ChatRequest):
|
|
109 |
raise HTTPException(status_code=500, detail=str(e))
|
110 |
|
111 |
# Function to process streaming response
|
112 |
-
def process_response_stream(request: ChatRequest):
|
113 |
try:
|
114 |
model = MODEL_MAPPING.get(request.model, request.model)
|
115 |
messages = [
|
@@ -130,7 +128,8 @@ def process_response_stream(request: ChatRequest):
|
|
130 |
yield "data: [DONE]\n\n"
|
131 |
except Exception as e:
|
132 |
logger.error(f"Error in streaming response: {e}")
|
133 |
-
|
|
|
134 |
return event_generator()
|
135 |
except Exception as e:
|
136 |
logger.error(f"Error processing streaming response: {e}")
|
|
|
7 |
from api.config import MODEL_MAPPING, EDITEA_API_ENDPOINT, EDITEA_HEADERS
|
8 |
from fastapi import HTTPException
|
9 |
|
|
|
10 |
class Editee:
|
11 |
label = "Editee"
|
12 |
url = "https://editee.com"
|
|
|
44 |
**kwargs
|
45 |
):
|
46 |
model = cls.get_model(model)
|
|
|
47 |
headers = EDITEA_HEADERS
|
48 |
|
49 |
async with ClientSession(headers=headers) as session:
|
|
|
107 |
raise HTTPException(status_code=500, detail=str(e))
|
108 |
|
109 |
# Function to process streaming response
|
110 |
+
async def process_response_stream(request: ChatRequest):
|
111 |
try:
|
112 |
model = MODEL_MAPPING.get(request.model, request.model)
|
113 |
messages = [
|
|
|
128 |
yield "data: [DONE]\n\n"
|
129 |
except Exception as e:
|
130 |
logger.error(f"Error in streaming response: {e}")
|
131 |
+
yield f"data: [ERROR] {str(e)}\n\n"
|
132 |
+
|
133 |
return event_generator()
|
134 |
except Exception as e:
|
135 |
logger.error(f"Error processing streaming response: {e}")
|