Update api/utils.py
Browse files- api/utils.py +3 -7
api/utils.py
CHANGED
@@ -3,7 +3,6 @@ import json
|
|
3 |
import uuid
|
4 |
import asyncio
|
5 |
import random
|
6 |
-
import string
|
7 |
from typing import Any, Dict, Optional
|
8 |
|
9 |
import httpx
|
@@ -15,7 +14,6 @@ from api.config import (
|
|
15 |
AGENT_MODE,
|
16 |
TRENDING_AGENT_MODE,
|
17 |
MODEL_PREFIXES,
|
18 |
-
MODEL_REFERERS,
|
19 |
)
|
20 |
from api.models import ChatRequest
|
21 |
from api.logger import setup_logger
|
@@ -85,11 +83,9 @@ def strip_model_prefix(content: str, model_prefix: Optional[str] = None) -> str:
|
|
85 |
return content
|
86 |
|
87 |
|
88 |
-
# Function to get the
|
89 |
def get_referer_url(model: str) -> str:
|
90 |
-
"""Generate the referer URL based on
|
91 |
-
if model in MODEL_REFERERS:
|
92 |
-
return f"{BASE_URL}/chat?model={model}"
|
93 |
return BASE_URL
|
94 |
|
95 |
|
@@ -154,7 +150,7 @@ async def process_streaming_response(request: ChatRequest):
|
|
154 |
if "https://www.blackbox.ai" in line:
|
155 |
# Refresh hid and inform the user
|
156 |
validate.getHid(True)
|
157 |
-
content = "The HID has been refreshed; please try again
|
158 |
yield (
|
159 |
f"data: {json.dumps(create_chat_completion_data(content, request.model, int(datetime.now().timestamp())))}\n\n"
|
160 |
)
|
|
|
3 |
import uuid
|
4 |
import asyncio
|
5 |
import random
|
|
|
6 |
from typing import Any, Dict, Optional
|
7 |
|
8 |
import httpx
|
|
|
14 |
AGENT_MODE,
|
15 |
TRENDING_AGENT_MODE,
|
16 |
MODEL_PREFIXES,
|
|
|
17 |
)
|
18 |
from api.models import ChatRequest
|
19 |
from api.logger import setup_logger
|
|
|
83 |
return content
|
84 |
|
85 |
|
86 |
+
# Function to get the referer URL
|
87 |
def get_referer_url(model: str) -> str:
|
88 |
+
"""Generate the referer URL based on the model."""
|
|
|
|
|
89 |
return BASE_URL
|
90 |
|
91 |
|
|
|
150 |
if "https://www.blackbox.ai" in line:
|
151 |
# Refresh hid and inform the user
|
152 |
validate.getHid(True)
|
153 |
+
content = "The HID has been refreshed; please try again.\n"
|
154 |
yield (
|
155 |
f"data: {json.dumps(create_chat_completion_data(content, request.model, int(datetime.now().timestamp())))}\n\n"
|
156 |
)
|