Eng-Musa commited on
Commit
f1fe51a
·
1 Parent(s): 45ab13f

catch repeted quiz

Browse files
__pycache__/main.cpython-312.pyc CHANGED
Binary files a/__pycache__/main.cpython-312.pyc and b/__pycache__/main.cpython-312.pyc differ
 
clients/__pycache__/groq_client.cpython-312.pyc CHANGED
Binary files a/clients/__pycache__/groq_client.cpython-312.pyc and b/clients/__pycache__/groq_client.cpython-312.pyc differ
 
clients/groq_client.py CHANGED
@@ -131,8 +131,22 @@ class GroqClient:
131
  def handle_unknown_query(self):
132
  return random.choice(FALLBACK_RESPONSES)
133
 
 
 
 
 
 
134
  def get_next_questions(self):
135
- return random.sample(OPTIMIZED_QUESTIONS, 3)
 
 
 
 
 
 
 
 
 
136
 
137
  # ---------------MAIN-----------------
138
 
 
131
  def handle_unknown_query(self):
132
  return random.choice(FALLBACK_RESPONSES)
133
 
134
+ # def get_next_questions(self):
135
+ # return random.sample(OPTIMIZED_QUESTIONS, 3)
136
+
137
+ _shown = set()
138
+
139
  def get_next_questions(self):
140
+ """Return 3 non-repeated random questions within the session."""
141
+ remaining = [q for q in OPTIMIZED_QUESTIONS if q not in self._shown]
142
+
143
+ if len(remaining) < 3:
144
+ self._shown.clear()
145
+ remaining = OPTIMIZED_QUESTIONS[:]
146
+
147
+ selected = random.sample(remaining, 3)
148
+ self._shown.update(selected)
149
+ return selected
150
 
151
  # ---------------MAIN-----------------
152
 
main.py CHANGED
@@ -11,7 +11,7 @@ app = FastAPI()
11
  origins = [
12
  "http://localhost:4200",
13
  "https://mosesmangabo.vercel.app",
14
- "https://chatbot-bridge-service.onrender.com"
15
  "https://eng-musa-chatbotbridge.hf.space"
16
  ]
17
 
 
11
  origins = [
12
  "http://localhost:4200",
13
  "https://mosesmangabo.vercel.app",
14
+ "https://chatbot-bridge-service.onrender.com",
15
  "https://eng-musa-chatbotbridge.hf.space"
16
  ]
17