Spaces:
Running
Running
| from groq import Groq | |
| import os | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| client = Groq(api_key=os.getenv("GROQ_API_KEY")) | |
| def generate_answer(context, question): | |
| prompt = f""" | |
| You are an AI assistant. Answer ONLY from the given context. | |
| Context: | |
| {context} | |
| Question: | |
| {question} | |
| """ | |
| response = client.chat.completions.create( | |
| model="openai/gpt-oss-20b", | |
| messages=[{"role": "user", "content": prompt}], | |
| temperature=0.3 | |
| ) | |
| return response.choices[0].message.content |