optimize grok client
Browse files- .env +6 -2
- __pycache__/main.cpython-312.pyc +0 -0
- __pycache__/optimized_quiz.cpython-312.pyc +0 -0
- clients/__pycache__/groq_client.cpython-312.pyc +0 -0
- clients/groq_client.py +61 -68
- data.json +15 -5
- main.py +21 -1
- optimized_quiz.py +72 -92
.env
CHANGED
|
@@ -14,13 +14,17 @@ BASE_URL=https://openrouter.ai/api/v1
|
|
| 14 |
GROQ_API_KEY=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
|
| 15 |
G_TEMPERATURE = 0.7
|
| 16 |
G_MAX_CONVERSATION_HISTORY = 5
|
| 17 |
-
G_MODEL = compound-beta-mini
|
| 18 |
-
G_MODEL1 = compound-beta
|
|
|
|
|
|
|
| 19 |
G_TOP_P = 0.7
|
| 20 |
G_MAX_TOKENS = 2000
|
| 21 |
G_RETRIEVE_K = 8
|
| 22 |
MMR = mmr
|
| 23 |
G_FETCH_K = 20
|
| 24 |
LAMBDA_MULT = 0.5
|
|
|
|
|
|
|
| 25 |
|
| 26 |
|
|
|
|
| 14 |
GROQ_API_KEY=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
|
| 15 |
G_TEMPERATURE = 0.7
|
| 16 |
G_MAX_CONVERSATION_HISTORY = 5
|
| 17 |
+
# G_MODEL = compound-beta-mini
|
| 18 |
+
# G_MODEL1 = compound-beta
|
| 19 |
+
G_MODEL=llama-3.1-8b-instant
|
| 20 |
+
G_MODEL1=gemma2-9b-it
|
| 21 |
G_TOP_P = 0.7
|
| 22 |
G_MAX_TOKENS = 2000
|
| 23 |
G_RETRIEVE_K = 8
|
| 24 |
MMR = mmr
|
| 25 |
G_FETCH_K = 20
|
| 26 |
LAMBDA_MULT = 0.5
|
| 27 |
+
HF_API_KEY = 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
|
| 28 |
+
|
| 29 |
|
| 30 |
|
__pycache__/main.cpython-312.pyc
CHANGED
|
Binary files a/__pycache__/main.cpython-312.pyc and b/__pycache__/main.cpython-312.pyc differ
|
|
|
__pycache__/optimized_quiz.cpython-312.pyc
CHANGED
|
Binary files a/__pycache__/optimized_quiz.cpython-312.pyc and b/__pycache__/optimized_quiz.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
|
@@ -5,6 +5,8 @@ import json
|
|
| 5 |
from uuid import uuid4
|
| 6 |
from groq import Groq
|
| 7 |
from langchain_core.documents import Document
|
|
|
|
|
|
|
| 8 |
from langchain_huggingface import HuggingFaceEmbeddings
|
| 9 |
from langchain_chroma import Chroma
|
| 10 |
from dotenv import load_dotenv
|
|
@@ -27,23 +29,16 @@ MAX_CONVERSATION_HISTORY = int(os.getenv("G_MAX_CONVERSATION_HISTORY", 5))
|
|
| 27 |
MMR = str(os.getenv("MMR", "mmr"))
|
| 28 |
G_FETCH_K = int(os.getenv("G_FETCH_K", 20))
|
| 29 |
LAMBDA_MULT = float(os.getenv("LAMBDA_MULT", 0.5))
|
| 30 |
-
# Read environment variables with defaults
|
| 31 |
-
model_1 = os.getenv("G_MODEL", "compound-beta")
|
| 32 |
-
model_2 = os.getenv("G_MODEL1", "compound-beta-mini")
|
| 33 |
|
| 34 |
|
| 35 |
class GroqClient:
|
| 36 |
def __init__(self):
|
| 37 |
-
self.conversation_history = []
|
| 38 |
|
| 39 |
self.documents = self.load_json_data(DATA_PATH)
|
| 40 |
if not self.documents:
|
| 41 |
raise RuntimeError("No data loaded")
|
| 42 |
|
| 43 |
self.vector_store = self.init_vector_store(self.documents)
|
| 44 |
-
# self.retriever = self.vector_store.as_retriever(
|
| 45 |
-
# search_type="similarity", search_kwargs={"k": RETRIEVE_K}
|
| 46 |
-
# )
|
| 47 |
|
| 48 |
self.retriever = self.vector_store.as_retriever(
|
| 49 |
search_type=MMR, # Use Maximal Marginal Relevance
|
|
@@ -65,8 +60,13 @@ class GroqClient:
|
|
| 65 |
"If knowledge is limited, give the most relevant answer possible without making things up. "
|
| 66 |
"Avoid repetitive openings such as 'I'm happy to...' or 'Sure, I'd be glad to...'. "
|
| 67 |
"Begin responses naturally, varying the first sentence. "
|
| 68 |
-
"Use first person when speaking as Moses. "
|
| 69 |
"Use third person when the question explicitly asks about Moses."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
)
|
| 71 |
|
| 72 |
self.PROMPT_TEMPLATE = """
|
|
@@ -233,6 +233,8 @@ Answer:
|
|
| 233 |
return []
|
| 234 |
|
| 235 |
def init_vector_store(self, documents):
|
|
|
|
|
|
|
| 236 |
embeddings_model = HuggingFaceEmbeddings(
|
| 237 |
model_name="sentence-transformers/all-MiniLM-L6-v2"
|
| 238 |
)
|
|
@@ -249,38 +251,19 @@ Answer:
|
|
| 249 |
persist_directory=CHROMA_PATH,
|
| 250 |
)
|
| 251 |
|
|
|
|
| 252 |
vector_store.add_documents(documents=documents, ids=uuids)
|
| 253 |
return vector_store
|
| 254 |
|
| 255 |
-
# def sanitize_input(self, user_input):
|
| 256 |
-
# cleaned = re.sub(r"[\x00-\x1f\x7f]", "", user_input)
|
| 257 |
-
# if len(cleaned) > 200:
|
| 258 |
-
# cleaned = cleaned[:200]
|
| 259 |
-
|
| 260 |
-
# for bad in self.BLACKLIST:
|
| 261 |
-
# if bad.lower() in cleaned.lower():
|
| 262 |
-
# return None
|
| 263 |
-
# return cleaned.strip()
|
| 264 |
-
|
| 265 |
-
# def correct_spelling(self, text):
|
| 266 |
-
# corrected = TextBlob(text).correct()
|
| 267 |
-
# return str(corrected)
|
| 268 |
-
|
| 269 |
def handle_unknown_query(self):
|
| 270 |
return random.choice(self.FALLBACK_RESPONSES)
|
| 271 |
|
| 272 |
def get_next_questions(self):
|
| 273 |
-
return random.sample(OPTIMIZED_QUESTIONS,
|
| 274 |
-
|
| 275 |
-
def get_model(self):
|
| 276 |
-
return random.choice([model_1, model_2])
|
| 277 |
|
| 278 |
# ---------------MAIN-----------------
|
| 279 |
|
| 280 |
def ask(self, raw_query: str) -> str:
|
| 281 |
-
# q_corrected = self.correct_spelling(raw_query)
|
| 282 |
-
# q = self.sanitize_input(q_corrected)
|
| 283 |
-
|
| 284 |
q = raw_query
|
| 285 |
if q is None or q == "":
|
| 286 |
return random.choice(self.FALLBACK_RESPONSES)
|
|
@@ -288,54 +271,64 @@ Answer:
|
|
| 288 |
if q.lower() in self.GREETINGS_TRIGGERS:
|
| 289 |
return random.choice(self.GREETINGS)
|
| 290 |
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
-MAX_CONVERSATION_HISTORY:
|
| 296 |
-
]
|
| 297 |
-
|
| 298 |
-
docs = self.retriever.invoke(q)
|
| 299 |
-
# print("Retrieved docs:", docs)
|
| 300 |
|
| 301 |
if not docs:
|
| 302 |
return random.choice(self.FALLBACK_RESPONSES)
|
| 303 |
|
| 304 |
context = "\n".join([d.page_content for d in docs])
|
| 305 |
-
# print("Context string:\n", context)
|
| 306 |
-
|
| 307 |
fallback = self.handle_unknown_query()
|
| 308 |
prompt = self.PROMPT_TEMPLATE.format(
|
| 309 |
context=context, question=q, fallback_response=fallback
|
| 310 |
)
|
| 311 |
|
| 312 |
-
messages =
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
+ [
|
| 321 |
-
{"role": "user", "content": prompt},
|
| 322 |
-
]
|
| 323 |
-
)
|
| 324 |
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
)
|
| 334 |
-
response = completion.choices[0].message.content
|
| 335 |
-
if response and response.strip():
|
| 336 |
-
return response.strip()
|
| 337 |
-
else:
|
| 338 |
-
return "Sorry, I didn't quite get that. Could you please rephrase your question?"
|
| 339 |
|
| 340 |
-
|
| 341 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
from uuid import uuid4
|
| 6 |
from groq import Groq
|
| 7 |
from langchain_core.documents import Document
|
| 8 |
+
|
| 9 |
+
# CHANGED: Replaced HuggingFaceEndpointEmbeddings with HuggingFaceEmbeddings for local inference
|
| 10 |
from langchain_huggingface import HuggingFaceEmbeddings
|
| 11 |
from langchain_chroma import Chroma
|
| 12 |
from dotenv import load_dotenv
|
|
|
|
| 29 |
MMR = str(os.getenv("MMR", "mmr"))
|
| 30 |
G_FETCH_K = int(os.getenv("G_FETCH_K", 20))
|
| 31 |
LAMBDA_MULT = float(os.getenv("LAMBDA_MULT", 0.5))
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
|
| 34 |
class GroqClient:
|
| 35 |
def __init__(self):
|
|
|
|
| 36 |
|
| 37 |
self.documents = self.load_json_data(DATA_PATH)
|
| 38 |
if not self.documents:
|
| 39 |
raise RuntimeError("No data loaded")
|
| 40 |
|
| 41 |
self.vector_store = self.init_vector_store(self.documents)
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
self.retriever = self.vector_store.as_retriever(
|
| 44 |
search_type=MMR, # Use Maximal Marginal Relevance
|
|
|
|
| 60 |
"If knowledge is limited, give the most relevant answer possible without making things up. "
|
| 61 |
"Avoid repetitive openings such as 'I'm happy to...' or 'Sure, I'd be glad to...'. "
|
| 62 |
"Begin responses naturally, varying the first sentence. "
|
|
|
|
| 63 |
"Use third person when the question explicitly asks about Moses."
|
| 64 |
+
"IMPORTANT VOICE GUIDELINES:\n"
|
| 65 |
+
"Always use first person: 'I developed...', 'My experience includes...', 'I'm skilled in...'\n"
|
| 66 |
+
"Only use third person if someone explicitly asks 'Tell me about Moses as a person' or similar formal introductions\n"
|
| 67 |
+
"Speak as if you're having a direct conversation with the visitor\n"
|
| 68 |
+
"Be personable and authentic while staying professional\n"
|
| 69 |
+
"If a response is too brief, expand it contextually while keeping it accurate."
|
| 70 |
)
|
| 71 |
|
| 72 |
self.PROMPT_TEMPLATE = """
|
|
|
|
| 233 |
return []
|
| 234 |
|
| 235 |
def init_vector_store(self, documents):
|
| 236 |
+
# CHANGED: Replaced online HuggingFaceEndpointEmbeddings with local HuggingFaceEmbeddings
|
| 237 |
+
# This downloads and stores the embedding model locally, eliminating API dependency
|
| 238 |
embeddings_model = HuggingFaceEmbeddings(
|
| 239 |
model_name="sentence-transformers/all-MiniLM-L6-v2"
|
| 240 |
)
|
|
|
|
| 251 |
persist_directory=CHROMA_PATH,
|
| 252 |
)
|
| 253 |
|
| 254 |
+
# CHANGED: This now processes embeddings locally instead of making API calls
|
| 255 |
vector_store.add_documents(documents=documents, ids=uuids)
|
| 256 |
return vector_store
|
| 257 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
def handle_unknown_query(self):
|
| 259 |
return random.choice(self.FALLBACK_RESPONSES)
|
| 260 |
|
| 261 |
def get_next_questions(self):
|
| 262 |
+
return random.sample(OPTIMIZED_QUESTIONS, 3)
|
|
|
|
|
|
|
|
|
|
| 263 |
|
| 264 |
# ---------------MAIN-----------------
|
| 265 |
|
| 266 |
def ask(self, raw_query: str) -> str:
|
|
|
|
|
|
|
|
|
|
| 267 |
q = raw_query
|
| 268 |
if q is None or q == "":
|
| 269 |
return random.choice(self.FALLBACK_RESPONSES)
|
|
|
|
| 271 |
if q.lower() in self.GREETINGS_TRIGGERS:
|
| 272 |
return random.choice(self.GREETINGS)
|
| 273 |
|
| 274 |
+
try:
|
| 275 |
+
docs = self.retriever.invoke(q)
|
| 276 |
+
except Exception as e:
|
| 277 |
+
return f"Error retrieving documents: {e}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
|
| 279 |
if not docs:
|
| 280 |
return random.choice(self.FALLBACK_RESPONSES)
|
| 281 |
|
| 282 |
context = "\n".join([d.page_content for d in docs])
|
|
|
|
|
|
|
| 283 |
fallback = self.handle_unknown_query()
|
| 284 |
prompt = self.PROMPT_TEMPLATE.format(
|
| 285 |
context=context, question=q, fallback_response=fallback
|
| 286 |
)
|
| 287 |
|
| 288 |
+
messages = [
|
| 289 |
+
{
|
| 290 |
+
"role": "system",
|
| 291 |
+
"content": self.SYSTEM_MESSSAGE,
|
| 292 |
+
},
|
| 293 |
+
] + [
|
| 294 |
+
{"role": "user", "content": prompt},
|
| 295 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
|
| 297 |
+
# Try multiple models with fallback
|
| 298 |
+
# Add fallback models if compound models fail
|
| 299 |
+
models_to_try = [
|
| 300 |
+
"compound-beta-mini",
|
| 301 |
+
"llama-3.1-8b-instant",
|
| 302 |
+
"gemma2-9b-it",
|
| 303 |
+
|
| 304 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
|
| 306 |
+
random.shuffle(models_to_try)
|
| 307 |
+
|
| 308 |
+
for model in models_to_try:
|
| 309 |
+
try:
|
| 310 |
+
completion = self.client.chat.completions.create(
|
| 311 |
+
model=model,
|
| 312 |
+
messages=messages,
|
| 313 |
+
temperature=TEMPERATURE,
|
| 314 |
+
max_completion_tokens=MAX_TOKENS,
|
| 315 |
+
top_p=TOP_P,
|
| 316 |
+
stream=False,
|
| 317 |
+
)
|
| 318 |
+
response = completion.choices[0].message.content
|
| 319 |
+
if response and response.strip():
|
| 320 |
+
return response.strip()
|
| 321 |
+
else:
|
| 322 |
+
continue # Try next model
|
| 323 |
+
|
| 324 |
+
except Exception as e:
|
| 325 |
+
# Check if it's a rate limit error
|
| 326 |
+
if "rate_limit_exceeded" in str(e) or "429" in str(e):
|
| 327 |
+
print(f"Rate limit hit for model {model}, trying fallback...")
|
| 328 |
+
continue
|
| 329 |
+
else:
|
| 330 |
+
# For other errors, return immediately
|
| 331 |
+
return f"Error while calling LLM: {e}"
|
| 332 |
+
|
| 333 |
+
# If all models fail
|
| 334 |
+
return "I'm temporarily experiencing high demand. Please try again in a few minutes or rephrase your question."
|
data.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
| 18 |
{
|
| 19 |
"category": "Education",
|
| 20 |
"question": "What is your primary school education background?",
|
| 21 |
-
"answer": "I attended Getenga PAG Primary School from 2009 to
|
| 22 |
},
|
| 23 |
|
| 24 |
{
|
|
@@ -384,6 +384,16 @@
|
|
| 384 |
"answer": "I use Docker, Git/GitHub, Linux, Windows, Kicad, Matlab, Tinkercad, and Microsoft Office."
|
| 385 |
},
|
| 386 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 387 |
{
|
| 388 |
"category": "Projects",
|
| 389 |
"question": "What is the Equity Online project about?",
|
|
@@ -515,9 +525,9 @@
|
|
| 515 |
"answer": "Yes, I was the Class Representative for class 4D at Cardinal Otunga Boys from March 2013 to December 2016."
|
| 516 |
},
|
| 517 |
{
|
| 518 |
-
"category": "---------------------
|
| 519 |
-
"question": "
|
| 520 |
-
"answer": "
|
| 521 |
},
|
| 522 |
{
|
| 523 |
"category": "Personal",
|
|
@@ -547,7 +557,7 @@
|
|
| 547 |
{
|
| 548 |
"category": "Tools",
|
| 549 |
"question": "What's your preferred development environment?",
|
| 550 |
-
"answer": "VS Code and IntelliJ IDEA."
|
| 551 |
},
|
| 552 |
{
|
| 553 |
"category": "Contact",
|
|
|
|
| 18 |
{
|
| 19 |
"category": "Education",
|
| 20 |
"question": "What is your primary school education background?",
|
| 21 |
+
"answer": "I attended Getenga PAG Primary School from 2009 to 2012. Prior to that, I studied at Nyamoronga D.O.K until 2009."
|
| 22 |
},
|
| 23 |
|
| 24 |
{
|
|
|
|
| 384 |
"answer": "I use Docker, Git/GitHub, Linux, Windows, Kicad, Matlab, Tinkercad, and Microsoft Office."
|
| 385 |
},
|
| 386 |
|
| 387 |
+
{
|
| 388 |
+
"category": "---------------------",
|
| 389 |
+
"question": "---------------------",
|
| 390 |
+
"answer": "--------------------------"
|
| 391 |
+
},
|
| 392 |
+
{
|
| 393 |
+
"category": "Projects",
|
| 394 |
+
"question": "Explain the MusAI Chatbot project",
|
| 395 |
+
"answer": "MusAI is a personal AI chatbot built with RAG technology that provides accurate, contextual answers to user queries. The system integrates vector databases, embeddings, and large language models for an intelligent conversational experience. It uses LangChain to manage embeddings and retrieval. Hugging Face transformers (via API) generate the embeddings, which are stored in ChromaDB as the vector database. At query time, relevant context is retrieved from Chroma and passed to LLMs in a RAG pipeline to generate answers. Workflow: User Query → Hugging Face Embeddings → ChromaDB → Retriever (MMR Search) → LLMs → Final Answer. The frontend is built with Angular 20, while the backend follows a microservices architecture. The chatbot engine is powered by FastAPI, and a Spring Boot bridge service manages communication across services and handles the user input. Data is stored in PostgreSQL, hosted on Supabase. Backend services are containerized with Docker and deployed on Render while frontend is hosted on vercel."
|
| 396 |
+
},
|
| 397 |
{
|
| 398 |
"category": "Projects",
|
| 399 |
"question": "What is the Equity Online project about?",
|
|
|
|
| 525 |
"answer": "Yes, I was the Class Representative for class 4D at Cardinal Otunga Boys from March 2013 to December 2016."
|
| 526 |
},
|
| 527 |
{
|
| 528 |
+
"category": "---------------------",
|
| 529 |
+
"question": "---------------------",
|
| 530 |
+
"answer": "--------------------------"
|
| 531 |
},
|
| 532 |
{
|
| 533 |
"category": "Personal",
|
|
|
|
| 557 |
{
|
| 558 |
"category": "Tools",
|
| 559 |
"question": "What's your preferred development environment?",
|
| 560 |
+
"answer": "VS Code for frontend and IntelliJ IDEA for backend. I use postman for api testing and swagger for documentation."
|
| 561 |
},
|
| 562 |
{
|
| 563 |
"category": "Contact",
|
main.py
CHANGED
|
@@ -1,10 +1,28 @@
|
|
| 1 |
from fastapi import FastAPI
|
|
|
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from functools import lru_cache
|
| 4 |
from clients.groq_client import GroqClient
|
| 5 |
|
| 6 |
app = FastAPI()
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
class QueryRequest(BaseModel):
|
| 9 |
query: str
|
| 10 |
|
|
@@ -30,4 +48,6 @@ async def chat_endpoint(request: QueryRequest):
|
|
| 30 |
|
| 31 |
@app.get("/")
|
| 32 |
def healthcheck():
|
| 33 |
-
return {"status": "ok"}
|
|
|
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
from pydantic import BaseModel
|
| 4 |
from functools import lru_cache
|
| 5 |
from clients.groq_client import GroqClient
|
| 6 |
|
| 7 |
app = FastAPI()
|
| 8 |
|
| 9 |
+
|
| 10 |
+
# ✅ Allowed origins
|
| 11 |
+
origins = [
|
| 12 |
+
"http://localhost:4200",
|
| 13 |
+
"https://mosesmangabo.vercel.app",
|
| 14 |
+
"https://chatbot-bridge-service.onrender.com"
|
| 15 |
+
]
|
| 16 |
+
|
| 17 |
+
app.add_middleware(
|
| 18 |
+
CORSMiddleware,
|
| 19 |
+
allow_origins=origins,
|
| 20 |
+
allow_credentials=True,
|
| 21 |
+
allow_methods=["*"], # allow all HTTP methods (GET, POST, etc.)
|
| 22 |
+
allow_headers=["*"], # allow all headers
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
class QueryRequest(BaseModel):
|
| 27 |
query: str
|
| 28 |
|
|
|
|
| 48 |
|
| 49 |
@app.get("/")
|
| 50 |
def healthcheck():
|
| 51 |
+
return {"status": "ok"}
|
| 52 |
+
|
| 53 |
+
#python -m uvicorn main:app --reload
|
optimized_quiz.py
CHANGED
|
@@ -1,93 +1,73 @@
|
|
| 1 |
OPTIMIZED_QUESTIONS = [
|
| 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 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
"
|
| 45 |
-
"
|
| 46 |
-
"
|
| 47 |
-
"What
|
| 48 |
-
"
|
| 49 |
-
"What
|
| 50 |
-
"
|
| 51 |
-
"
|
| 52 |
-
"
|
| 53 |
-
"
|
| 54 |
-
"
|
| 55 |
-
"
|
| 56 |
-
"
|
| 57 |
-
"
|
| 58 |
-
"
|
| 59 |
-
"
|
| 60 |
-
"
|
| 61 |
-
"What
|
| 62 |
-
"
|
| 63 |
-
"What
|
| 64 |
-
"
|
| 65 |
-
"What
|
| 66 |
-
"
|
| 67 |
-
"What
|
| 68 |
-
"
|
| 69 |
-
"What
|
| 70 |
-
"
|
| 71 |
-
"
|
| 72 |
-
"
|
| 73 |
-
|
| 74 |
-
"What were your responsibilities as Vice President of the Machakos University Equity Leaders Club?",
|
| 75 |
-
"What did you accomplish as President of the Machakos University Equity Leaders Club?",
|
| 76 |
-
"What was your role in the Engineering Club?",
|
| 77 |
-
"Did you hold any representative roles during secondary school?",
|
| 78 |
-
"Where are you from?",
|
| 79 |
-
"How many years of experience do you have in software development?",
|
| 80 |
-
"Which languages do you speak?",
|
| 81 |
-
"What outdoor activities do you enjoy?",
|
| 82 |
-
"What kind of content do you enjoy watching?",
|
| 83 |
-
"What's your preferred development environment?",
|
| 84 |
-
"What are your communication channels?",
|
| 85 |
-
"How can someone reach you or learn more about your work?",
|
| 86 |
-
"What IoT projects did you work on during your undergraduate studies?",
|
| 87 |
-
"What is your experience with embedded programming and control systems?",
|
| 88 |
-
"Can you describe your role in developing the Energy Management System at E&M Technology?",
|
| 89 |
-
"What are your key skills in Retrieval-Augmented Generation (RAG) workflows?",
|
| 90 |
-
"What volunteer or community engagement activities have you participated in?",
|
| 91 |
-
"What is your proficiency level in Java, JavaScript, and TypeScript?",
|
| 92 |
-
"What tools do you use for testing and version control in your development work?"
|
| 93 |
-
]
|
|
|
|
| 1 |
OPTIMIZED_QUESTIONS = [
|
| 2 |
+
"What's your full name?",
|
| 3 |
+
"Where are you from?",
|
| 4 |
+
"What's your educational background?",
|
| 5 |
+
"What languages do you speak?",
|
| 6 |
+
"Whats your professional summary?",
|
| 7 |
+
"How did you implement MusAI Chatbot?"
|
| 8 |
+
"What technologies or programming languages do you use?",
|
| 9 |
+
"Can you summarize all your projects?",
|
| 10 |
+
"Do you have links to your portfolio or GitHub?",
|
| 11 |
+
"What's your most impactful project?",
|
| 12 |
+
"Can you tell me about your energy management system project?",
|
| 13 |
+
"What kind of projects have you worked on?",
|
| 14 |
+
"How can I contact you?",
|
| 15 |
+
"What kind of roles are you most interested in?",
|
| 16 |
+
"Do you have experience with AI/ML, IoT, or databases?",
|
| 17 |
+
"What are your strongest technical skills?",
|
| 18 |
+
"What are your hobbies or interests outside coding?",
|
| 19 |
+
"What databases do you specialize in?",
|
| 20 |
+
"Have you built microservices before?",
|
| 21 |
+
"Which frameworks do you enjoy using the most?",
|
| 22 |
+
"What technologies are you currently learning?",
|
| 23 |
+
"What are some fun facts about you?",
|
| 24 |
+
"Which hobbies fuel your creativity and sustain work-life balance?",
|
| 25 |
+
"How did your engineering degree prepare you for software development?",
|
| 26 |
+
"Which undergraduate projects best demonstrate your hardware and IoT skills?",
|
| 27 |
+
"Which certifications most improved your capabilities in generative AI?",
|
| 28 |
+
"How does the EMS handle token transfers and remote meter controls?",
|
| 29 |
+
"What lessons from the Goldbach project improved your algorithmic thinking?",
|
| 30 |
+
"What inspired your passion for electrical engineering?",
|
| 31 |
+
"How did you contribute to science club activities?",
|
| 32 |
+
"What motivated your national-level engineering fair project?",
|
| 33 |
+
"How do you implement RAG in AI projects?",
|
| 34 |
+
"How do you leverage CNNs in your projects?",
|
| 35 |
+
"How did you streamline healthcare in the hackathon?",
|
| 36 |
+
"What banking operations did you learn from Moody's?",
|
| 37 |
+
"How do you apply TypeScript in Angular projects?",
|
| 38 |
+
"How did you contribute to the EMS project?",
|
| 39 |
+
"How do you conduct effective client training?",
|
| 40 |
+
"How did you mentor Wings to Fly scholars?",
|
| 41 |
+
"What environmental initiatives did you lead?",
|
| 42 |
+
"How do you integrate AI/ML in projects?",
|
| 43 |
+
"What features make the EMS system efficient?",
|
| 44 |
+
"How does the Goldbach Verifier project work?",
|
| 45 |
+
"How did AI improve Equity Afya operations?",
|
| 46 |
+
"What hardware did you use in undergrad projects?",
|
| 47 |
+
"What inspired your leadership in community initiatives?",
|
| 48 |
+
"How did you mobilize Equity Leaders Club?",
|
| 49 |
+
"What documentaries inspire your technical curiosity?",
|
| 50 |
+
"Which primary school did Moses attend, and in which years?",
|
| 51 |
+
"Which high school did Moses study at, and what years was he enrolled there?",
|
| 52 |
+
"Which university did you attend, what course, and when?",
|
| 53 |
+
"Summarize your schooling journey, primary through university.",
|
| 54 |
+
"Have you held any leadership roles before",
|
| 55 |
+
"Have you taken on leadership responsibilities in the past?",
|
| 56 |
+
"Which coding certifications has Moses earned?",
|
| 57 |
+
"Which certification does do you hold in Java?",
|
| 58 |
+
"Do you hold any certification in Artificial Intelligence or Machine Learning?",
|
| 59 |
+
"What skills did you gain from Generative AI certification?",
|
| 60 |
+
"How does Certified AI Foundations enhance your ML expertise?",
|
| 61 |
+
"What deep learning concepts did Simplilearn's course cover?",
|
| 62 |
+
"How did AWS ML certification boost your AI skills?",
|
| 63 |
+
"What AI solutions did you build in Equity Hackathon?",
|
| 64 |
+
"How did HackerRank's Angular certification test your skills?",
|
| 65 |
+
"What SQL techniques did you master in HackerRank's course?",
|
| 66 |
+
"How did LinkedIn's JavaScript certification improve your coding?",
|
| 67 |
+
"What Java algorithms did you learn from LinkedIn's course?",
|
| 68 |
+
"Show a diagram of how MusAI works operates",
|
| 69 |
+
"What technologies power the MusAI chatbot?",
|
| 70 |
+
"Can you explain how the RAG pipeline works in MusAI?",
|
| 71 |
+
"How is data stored and managed in the MusAI project?",
|
| 72 |
+
"Where is MusAI deployed and how is it containerized?"
|
| 73 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|