Update main.py
Browse files
main.py
CHANGED
@@ -9,7 +9,7 @@ import base64
|
|
9 |
from aiohttp import ClientSession, ClientTimeout, ClientError
|
10 |
from fastapi import FastAPI, HTTPException, Request
|
11 |
from pydantic import BaseModel
|
12 |
-
from typing import List, Dict, Any, Optional, AsyncGenerator
|
13 |
from datetime import datetime
|
14 |
from fastapi.responses import StreamingResponse
|
15 |
|
@@ -30,7 +30,7 @@ class ModelNotWorkingException(Exception):
|
|
30 |
self.message = f"The model '{model}' is currently not working. Please try another model or wait for it to be fixed."
|
31 |
super().__init__(self.message)
|
32 |
|
33 |
-
#
|
34 |
class ImageResponse:
|
35 |
def __init__(self, data_uri: str, alt: str):
|
36 |
self.data_uri = data_uri
|
@@ -200,7 +200,7 @@ class Blackbox:
|
|
200 |
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36",
|
201 |
}
|
202 |
|
203 |
-
if model in cls.model_prefixes:
|
204 |
prefix = cls.model_prefixes[model]
|
205 |
if not messages[0]['content'].startswith(prefix):
|
206 |
logger.debug(f"Adding prefix '{prefix}' to the first message.")
|
|
|
9 |
from aiohttp import ClientSession, ClientTimeout, ClientError
|
10 |
from fastapi import FastAPI, HTTPException, Request
|
11 |
from pydantic import BaseModel
|
12 |
+
from typing import List, Dict, Any, Optional, AsyncGenerator
|
13 |
from datetime import datetime
|
14 |
from fastapi.responses import StreamingResponse
|
15 |
|
|
|
30 |
self.message = f"The model '{model}' is currently not working. Please try another model or wait for it to be fixed."
|
31 |
super().__init__(self.message)
|
32 |
|
33 |
+
# Implementation for ImageResponse and to_data_uri
|
34 |
class ImageResponse:
|
35 |
def __init__(self, data_uri: str, alt: str):
|
36 |
self.data_uri = data_uri
|
|
|
200 |
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36",
|
201 |
}
|
202 |
|
203 |
+
if model in cls.model_prefixes and messages:
|
204 |
prefix = cls.model_prefixes[model]
|
205 |
if not messages[0]['content'].startswith(prefix):
|
206 |
logger.debug(f"Adding prefix '{prefix}' to the first message.")
|