-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgenerator.py
More file actions
39 lines (30 loc) · 1.5 KB
/
generator.py
File metadata and controls
39 lines (30 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from groq import Groq
from config import GROQ_API_KEY, LLM_MODEL
_client = Groq(api_key=GROQ_API_KEY)
def generate_response(query, retrieved_chunks):
"""
Generate a grounded answer from retrieved rule chunks.
TODO — Milestone 3:
`retrieved_chunks` is the list returned by retrieve(). Each item is a dict:
- "text" : the chunk text
- "game" : the game name
- "distance" : similarity score (you can use this to filter weak matches)
Before writing code, talk through these with your group:
- How will you format the chunks into a context block for the prompt?
- What instructions will stop the model from answering beyond what the
rules say? (Grounding is the whole point — a confident wrong answer
is worse than an honest "I don't know.")
- How will you surface which game each answer comes from?
Your response should:
1. Answer using only the retrieved context — not the model's general knowledge
2. Make clear which game the answer comes from
3. Say so clearly when the answer isn't in the loaded rules
Return the response as a plain string.
"""
if not retrieved_chunks:
return (
"I couldn't find anything relevant in the loaded rule books. "
"Try rephrasing your question — or check that your ingestion pipeline is working."
)
# Your implementation here.
return "⚙️ Response generation not yet implemented. Complete Milestone 3 to activate answers."