Spaces:
Running
Running
Upload main.py
Browse files
main.py
CHANGED
|
@@ -224,7 +224,7 @@ class ToneStyle(str, Enum):
|
|
| 224 |
FRIENDLY = "friendly"
|
| 225 |
BULLET = "bullet" # convert to bullet points
|
| 226 |
|
| 227 |
-
DEFAULT_MODEL =
|
| 228 |
|
| 229 |
BLOCKED_PATTERNS = [
|
| 230 |
r"(?i)\b(nude|sex|porn|erotic|18\+|naked|rape|fetish|incest|adult content|horny)\b"
|
|
@@ -1478,16 +1478,19 @@ class ChatMessage(BaseModel):
|
|
| 1478 |
instructions: str = ""
|
| 1479 |
autoPersonality: bool = False
|
| 1480 |
additionalInfor: str = ""
|
| 1481 |
-
|
| 1482 |
-
|
| 1483 |
-
|
|
|
|
|
|
|
|
|
|
| 1484 |
persona: Optional[str] = None
|
| 1485 |
-
deep_think: bool
|
| 1486 |
-
deep_search: bool
|
| 1487 |
response_length: ResponseLength = ResponseLength.BALANCED
|
| 1488 |
tone: ToneStyle = ToneStyle.DEFAULT
|
| 1489 |
-
json_mode: bool
|
| 1490 |
-
image_session_id: str
|
| 1491 |
|
| 1492 |
class TranslateRequest(BaseModel):
|
| 1493 |
user_id: str
|
|
@@ -1576,8 +1579,8 @@ async def chat(payload: ChatMessage, request: Request):
|
|
| 1576 |
return {"response": "π Sorry, I can't respond to that type of message."}
|
| 1577 |
|
| 1578 |
# ββ Resolve model from registry βββββββββββββββββββββββββββββ
|
| 1579 |
-
#
|
| 1580 |
-
raw_model_id = payload.model_id.strip() or payload.model.
|
| 1581 |
model_cfg = model_registry.get(raw_model_id)
|
| 1582 |
|
| 1583 |
# ββ Persona βββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -1724,7 +1727,7 @@ async def chat_stream(payload: ChatMessage, request: Request):
|
|
| 1724 |
yield "data: [DONE]\n\n"
|
| 1725 |
return StreamingResponse(rate_error(), media_type="text/event-stream")
|
| 1726 |
|
| 1727 |
-
raw_model_id = payload.model_id.strip() or payload.model.
|
| 1728 |
model_cfg = model_registry.get(raw_model_id)
|
| 1729 |
tz_str = get_user_timezone(user_id, ip)
|
| 1730 |
|
|
|
|
| 224 |
FRIENDLY = "friendly"
|
| 225 |
BULLET = "bullet" # convert to bullet points
|
| 226 |
|
| 227 |
+
DEFAULT_MODEL = "neurones-pro-1.0"
|
| 228 |
|
| 229 |
BLOCKED_PATTERNS = [
|
| 230 |
r"(?i)\b(nude|sex|porn|erotic|18\+|naked|rape|fetish|incest|adult content|horny)\b"
|
|
|
|
| 1478 |
instructions: str = ""
|
| 1479 |
autoPersonality: bool = False
|
| 1480 |
additionalInfor: str = ""
|
| 1481 |
+
# IMPORTANT: must be str, NOT AIModel enum.
|
| 1482 |
+
# Pydantic rejects any value not in the enum (e.g. "neurones-pro-1.0")
|
| 1483 |
+
# causing a 422 before the endpoint even runs β "failed to fetch" on frontend.
|
| 1484 |
+
model: str = "neurones-pro-1.0"
|
| 1485 |
+
model_id: str = "" # registry model id β preferred field
|
| 1486 |
+
force_groq: bool = False
|
| 1487 |
persona: Optional[str] = None
|
| 1488 |
+
deep_think: bool = False
|
| 1489 |
+
deep_search: bool = False
|
| 1490 |
response_length: ResponseLength = ResponseLength.BALANCED
|
| 1491 |
tone: ToneStyle = ToneStyle.DEFAULT
|
| 1492 |
+
json_mode: bool = False
|
| 1493 |
+
image_session_id: str = ""
|
| 1494 |
|
| 1495 |
class TranslateRequest(BaseModel):
|
| 1496 |
user_id: str
|
|
|
|
| 1579 |
return {"response": "π Sorry, I can't respond to that type of message."}
|
| 1580 |
|
| 1581 |
# ββ Resolve model from registry βββββββββββββββββββββββββββββ
|
| 1582 |
+
# model_id is the preferred field (new). model is legacy compat (plain string now).
|
| 1583 |
+
raw_model_id = payload.model_id.strip() or payload.model.strip() or "neurones-pro-1.0"
|
| 1584 |
model_cfg = model_registry.get(raw_model_id)
|
| 1585 |
|
| 1586 |
# ββ Persona βββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 1727 |
yield "data: [DONE]\n\n"
|
| 1728 |
return StreamingResponse(rate_error(), media_type="text/event-stream")
|
| 1729 |
|
| 1730 |
+
raw_model_id = payload.model_id.strip() or payload.model.strip() or "neurones-pro-1.0"
|
| 1731 |
model_cfg = model_registry.get(raw_model_id)
|
| 1732 |
tz_str = get_user_timezone(user_id, ip)
|
| 1733 |
|