sharktide commited on
Commit
792fbc3
·
verified ·
1 Parent(s): 5c28005

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -31
app.py CHANGED
@@ -358,41 +358,47 @@ async def generate_text(
358
  if kw in prompt_text:
359
  score += 1
360
 
361
- chosen_model = "meta-llama/llama-4-scout-17b-16e-instruct"
362
  provider = "groq"
363
- if score > 10:
364
- score = 10
365
- if uses_tools:
366
- if score >= 4:
367
- chosen_model = "openai/gpt-oss-120b"
368
- else:
369
- chosen_model = "openai/gpt-oss-20b"
370
- provider = "groq"
371
-
372
- elif code_present:
373
 
374
- if code_heavy and score >= 6:
375
- chosen_model = "gpt-oss-120b"
376
- provider = "cerebras"
377
-
378
- elif score >= 4:
379
- chosen_model = "llama-3.3-70b-versatile"
380
- provider = "groq"
381
-
382
- elif score >= 4:
383
  chosen_model = "meta-llama/llama-4-scout-17b-16e-instruct"
384
  provider = "groq"
385
-
386
- if provider == "groq" and (
387
- total_chars > MAX_GROQ_PROMPT_CHARS or total_bytes > MAX_GROQ_PROMPT_BYTES
388
- ):
389
- raise HTTPException(
390
- status_code=413,
391
- detail=(
392
- f"Prompt exceeds Groq-safe size ({total_chars} chars, {total_bytes} bytes). "
393
- f"Max Groq-safe size is {MAX_GROQ_PROMPT_CHARS} chars or {MAX_GROQ_PROMPT_BYTES} bytes."
394
- ),
395
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
 
397
  await check_chat_rate_limit(request, authorization, x_client_id)
398
 
 
358
  if kw in prompt_text:
359
  score += 1
360
 
361
+ chosen_model = "llama-3.1-8b-instant"
362
  provider = "groq"
363
+ has_images = contains_images(messages)
 
 
 
 
 
 
 
 
 
364
 
365
+ if has_images:
 
 
 
 
 
 
 
 
366
  chosen_model = "meta-llama/llama-4-scout-17b-16e-instruct"
367
  provider = "groq"
368
+ else:
369
+ if score > 10:
370
+ score = 10
371
+ if uses_tools:
372
+ if score >= 4:
373
+ chosen_model = "openai/gpt-oss-120b"
374
+ else:
375
+ chosen_model = "openai/gpt-oss-20b"
376
+ provider = "groq"
377
+
378
+ elif code_present:
379
+
380
+ if code_heavy and score >= 6:
381
+ chosen_model = "gpt-oss-120b"
382
+ provider = "cerebras"
383
+
384
+ elif score >= 4:
385
+ chosen_model = "llama-3.3-70b-versatile"
386
+ provider = "groq"
387
+
388
+ elif score >= 4:
389
+ chosen_model = "meta-llama/llama-4-scout-17b-16e-instruct"
390
+ provider = "groq"
391
+
392
+ if provider == "groq" and (
393
+ total_chars > MAX_GROQ_PROMPT_CHARS or total_bytes > MAX_GROQ_PROMPT_BYTES
394
+ ):
395
+ raise HTTPException(
396
+ status_code=413,
397
+ detail=(
398
+ f"Prompt exceeds Groq-safe size ({total_chars} chars, {total_bytes} bytes). "
399
+ f"Max Groq-safe size is {MAX_GROQ_PROMPT_CHARS} chars or {MAX_GROQ_PROMPT_BYTES} bytes."
400
+ ),
401
+ )
402
 
403
  await check_chat_rate_limit(request, authorization, x_client_id)
404