Chandima Prabhath commited on
Commit
ed8fee4
·
1 Parent(s): 8a638e3

Enhance trivia question generation prompt for clarity and enforce strict JSON format; add debug logging for random seed in LLM URL construction.

Browse files
Files changed (2) hide show
  1. app.py +2 -1
  2. polLLM.py +2 -1
app.py CHANGED
@@ -680,7 +680,8 @@ async def whatsapp_webhook(request: Request):
680
  # TRIVIA
681
  if low == "/trivia":
682
  raw = generate_llm(
683
- "Generate a random trivia question and answer in JSON format like this: "
 
684
  "{\"question\": \"What is the capital of France?\", \"answer\": \"Paris\"}"
685
  )
686
  def extract_json(text):
 
680
  # TRIVIA
681
  if low == "/trivia":
682
  raw = generate_llm(
683
+ "Generate a unique and random trivia question and answer in JSON format. "
684
+ "The output should strictly follow this example format without extra text:\n\n"
685
  "{\"question\": \"What is the capital of France?\", \"answer\": \"Paris\"}"
686
  )
687
  def extract_json(text):
polLLM.py CHANGED
@@ -21,7 +21,8 @@ def generate_llm(prompt):
21
  encoded_system = urllib.parse.quote(system_prompt)
22
  # Build the GET request URL for Pollinations' text API
23
  randomSeed = random.randint(0, 999999)
24
- url = f"https://text.pollinations.ai/{encoded_prompt}?model=openai&private=true&seed={randomSeed}&system={encoded_system}"
 
25
 
26
  try:
27
  response = requests.get(url, timeout=30)
 
21
  encoded_system = urllib.parse.quote(system_prompt)
22
  # Build the GET request URL for Pollinations' text API
23
  randomSeed = random.randint(0, 999999)
24
+ print(f"DEBUG: Random seed: {randomSeed}")
25
+ url = f"https://text.pollinations.ai/{encoded_prompt}?model=openai&seed={randomSeed}&private=true&system={encoded_system}"
26
 
27
  try:
28
  response = requests.get(url, timeout=30)