Eng-Musa commited on
Commit
19bcadf
·
1 Parent(s): c8b3c41

optimized quiz

Browse files
Files changed (3) hide show
  1. clients/groq_client.py +14 -6
  2. main.py +6 -1
  3. optimized_quiz.py +10 -0
clients/groq_client.py CHANGED
@@ -176,8 +176,8 @@ class GroqClient:
176
 
177
  # ---------------MAIN-----------------
178
 
179
- # Non-streaming ask method for backwards compatibility
180
- # ============================================
181
  def ask(self, raw_query: str) -> tuple[str, str | None]:
182
  if (
183
  not raw_query
@@ -256,15 +256,23 @@ class GroqClient:
256
  return f"Error while calling LLM: {e}", None
257
 
258
  # If all models fail
259
- return "I'm temporarily experiencing high demand. Please try again in a few minutes or rephrase your question.", None
 
 
 
260
 
261
- # Streaming ask method (Generator)
262
- # ============================================
263
  def ask_stream(self, raw_query: str):
264
  """Generator function that yields response chunks in real-time"""
265
 
266
  # Validation
267
- if not raw_query or raw_query is None or raw_query == "" or len(raw_query) > 1000:
 
 
 
 
 
268
  yield "Please provide a valid query under 1,000 characters."
269
  return
270
 
 
176
 
177
  # ---------------MAIN-----------------
178
 
179
+ # Non-streaming ask method for backwards compatibility
180
+ # ============================================
181
  def ask(self, raw_query: str) -> tuple[str, str | None]:
182
  if (
183
  not raw_query
 
256
  return f"Error while calling LLM: {e}", None
257
 
258
  # If all models fail
259
+ return (
260
+ "I'm temporarily experiencing high demand. Please try again in a few minutes or rephrase your question.",
261
+ None,
262
+ )
263
 
264
+ # Streaming ask method (Generator)
265
+ # ============================================
266
  def ask_stream(self, raw_query: str):
267
  """Generator function that yields response chunks in real-time"""
268
 
269
  # Validation
270
+ if (
271
+ not raw_query
272
+ or raw_query is None
273
+ or raw_query == ""
274
+ or len(raw_query) > 1000
275
+ ):
276
  yield "Please provide a valid query under 1,000 characters."
277
  return
278
 
main.py CHANGED
@@ -45,7 +45,12 @@ async def chat_endpoint(request: QueryRequest):
45
  groq_client = get_groq_client()
46
  response, model = groq_client.ask(request.query)
47
  if response.startswith("Error while"):
48
- return {"status_code": 500, "response": response, "model": model, "next_questions": []}
 
 
 
 
 
49
  return {
50
  "status_code": 200,
51
  "response": response,
 
45
  groq_client = get_groq_client()
46
  response, model = groq_client.ask(request.query)
47
  if response.startswith("Error while"):
48
+ return {
49
+ "status_code": 500,
50
+ "response": response,
51
+ "model": model,
52
+ "next_questions": [],
53
+ }
54
  return {
55
  "status_code": 200,
56
  "response": response,
optimized_quiz.py CHANGED
@@ -82,4 +82,14 @@ OPTIMIZED_QUESTIONS = [
82
  "How do construction professionals benefit from using UjenziLink?",
83
  "What specific problems in the construction industry does UjenziLink address?",
84
  "What are the different roles and permissions available in UjenziLink?",
 
 
 
 
 
 
 
 
 
 
85
  ]
 
82
  "How do construction professionals benefit from using UjenziLink?",
83
  "What specific problems in the construction industry does UjenziLink address?",
84
  "What are the different roles and permissions available in UjenziLink?",
85
+ "What is Falqon Jobs?",
86
+ "How does Falqon Jobs work?",
87
+ "What makes Falqon Jobs different?",
88
+ "How does CV matching work?",
89
+ "Where do the job listings come from?",
90
+ "Can I apply through Falqon Jobs?",
91
+ "Can I upload my CV?",
92
+ "What insights does CV matching provide?",
93
+ "Can I find remote jobs?",
94
+ "What technologies power Falqon Jobs?",
95
  ]