chore: fixed validation and used better model and api
Browse files- Backend/app/api/v1/endpoints/prompts.py +1 -1
- Backend/app/config.py +1 -1
- Backend/app/llm.py +3 -3
- Backend/app/schema/models.py +5 -5
Backend/app/api/v1/endpoints/prompts.py
CHANGED
|
@@ -23,7 +23,7 @@ GENERATION RULES
|
|
| 23 |
REQUIRED JSON FORMAT FOR EACH QUESTION
|
| 24 |
-----------------------
|
| 25 |
{{
|
| 26 |
-
"
|
| 27 |
"options": [
|
| 28 |
"rm",
|
| 29 |
"mv",
|
|
|
|
| 23 |
REQUIRED JSON FORMAT FOR EACH QUESTION
|
| 24 |
-----------------------
|
| 25 |
{{
|
| 26 |
+
"question": "Which of the following CLI command can also be used to rename files?",
|
| 27 |
"options": [
|
| 28 |
"rm",
|
| 29 |
"mv",
|
Backend/app/config.py
CHANGED
|
@@ -16,7 +16,7 @@ class Settings(BaseSettings):
|
|
| 16 |
chroma_port: int
|
| 17 |
chroma_collection: str
|
| 18 |
|
| 19 |
-
|
| 20 |
|
| 21 |
class Config:
|
| 22 |
env_file = ".env"
|
|
|
|
| 16 |
chroma_port: int
|
| 17 |
chroma_collection: str
|
| 18 |
|
| 19 |
+
GROQ_API_KEY:str
|
| 20 |
|
| 21 |
class Config:
|
| 22 |
env_file = ".env"
|
Backend/app/llm.py
CHANGED
|
@@ -6,15 +6,15 @@ from app.schema.models import QuizOutput, QuizQuestion
|
|
| 6 |
from app.config import settings
|
| 7 |
|
| 8 |
client = OpenAI(
|
| 9 |
-
base_url="https://
|
| 10 |
-
api_key=
|
| 11 |
)
|
| 12 |
|
| 13 |
async def call_llm(prompt:str):
|
| 14 |
try:
|
| 15 |
response = client.chat.completions.create(
|
| 16 |
# CRUCIAL: Use the LiteLLM format: 'gemini/gemini-2.5-pro'
|
| 17 |
-
model="
|
| 18 |
messages=[
|
| 19 |
{"role": "user", "content": prompt}
|
| 20 |
],
|
|
|
|
| 6 |
from app.config import settings
|
| 7 |
|
| 8 |
client = OpenAI(
|
| 9 |
+
base_url="https://api.groq.com/openai/v1",
|
| 10 |
+
api_key=settings.GROQ_API_KEY
|
| 11 |
)
|
| 12 |
|
| 13 |
async def call_llm(prompt:str):
|
| 14 |
try:
|
| 15 |
response = client.chat.completions.create(
|
| 16 |
# CRUCIAL: Use the LiteLLM format: 'gemini/gemini-2.5-pro'
|
| 17 |
+
model="openai/gpt-oss-20b",
|
| 18 |
messages=[
|
| 19 |
{"role": "user", "content": prompt}
|
| 20 |
],
|
Backend/app/schema/models.py
CHANGED
|
@@ -54,11 +54,11 @@ class Quiz_input(BaseModel):
|
|
| 54 |
# choice: Literal["mcq", "code"]
|
| 55 |
|
| 56 |
class QuizQuestion(BaseModel):
|
| 57 |
-
|
| 58 |
-
options: List[str] = Field(..., min_items=
|
| 59 |
-
answer: str
|
| 60 |
-
explanation: str
|
| 61 |
-
|
| 62 |
|
| 63 |
class QuizOutput(BaseModel):
|
| 64 |
quiz: List[QuizQuestion] = Field(..., description="A list of 10 generated MCQ questions.")
|
|
|
|
| 54 |
# choice: Literal["mcq", "code"]
|
| 55 |
|
| 56 |
class QuizQuestion(BaseModel):
|
| 57 |
+
question: str
|
| 58 |
+
options: List[str] = Field(..., min_items=2)
|
| 59 |
+
answer: str = Field(..., description="Correct answer key")
|
| 60 |
+
explanation: str
|
| 61 |
+
User_response: str = Field("", alias="User_response")
|
| 62 |
|
| 63 |
class QuizOutput(BaseModel):
|
| 64 |
quiz: List[QuizQuestion] = Field(..., description="A list of 10 generated MCQ questions.")
|