Spaces:
Sleeping
Sleeping
Update app.py
Browse files45 unmodified lines46474849505051525354555651525354555657585960616263646566676869707145 unmodified lines
# single LLM call; enforce bare answer def _llm(self, prompt: str) -> str: model = self.cfg["model"] if self.cfg["provider"] == "hf": out = self.hf.text_generation( model=self.cfg["model"], prompt=prompt, max_new_tokens=128, temperature=0.2, ) return out.strip() try: # Try text-generation first out = self.client.text_generation( model=model, prompt=prompt, max_new_tokens=128, temperature=0.2 ) return out.strip() except Exception as e: # If the backend says “Supported task: conversational”, retry with chat if "supported task: conversational" in str(e).lower(): chat = self.client.chat_completion( model=model, messages=[{"role": "user", "content": prompt}], max_tokens=128, temperature=0.2, ) return chat.choices[0].message["content"].strip() raise
# Groq (chat.completions) res = requests.post( "https://api.groq.com/openai/v1/chat/completions",app.py+19-7