DeepImagix commited on
Commit
5076cb7
Β·
verified Β·
1 Parent(s): 092fccd

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +14 -11
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 = AIModel.NEURONES_SELF
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
- model: AIModel = DEFAULT_MODEL # legacy enum β€” kept for compat
1482
- model_id: str = "" # NEW: registry model id e.g. "neurones-r1-1.0"
1483
- force_groq: bool = False
 
 
 
1484
  persona: Optional[str] = None
1485
- deep_think: bool = False
1486
- deep_search: bool = False
1487
  response_length: ResponseLength = ResponseLength.BALANCED
1488
  tone: ToneStyle = ToneStyle.DEFAULT
1489
- json_mode: bool = False
1490
- image_session_id: str = "" # NEW: reference an uploaded image by session ID
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
- # Prefer model_id (new field) over legacy enum
1580
- raw_model_id = payload.model_id.strip() or payload.model.value
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.value
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