Spaces:
Running
Running
feat: config package
Browse files
config/__init__.py
ADDED
|
File without changes
|
config/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (176 Bytes). View file
|
|
|
config/__pycache__/prompts.cpython-311.pyc
ADDED
|
Binary file (3.07 kB). View file
|
|
|
config/__pycache__/settings.cpython-311.pyc
ADDED
|
Binary file (2.62 kB). View file
|
|
|
config/prompts.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MiniCPM β concept extraction from raw text
|
| 2 |
+
DOCUMENT_EXTRACT_SYSTEM = """\
|
| 3 |
+
You are a study material processor. Extract all educational concepts from the text below.
|
| 4 |
+
Output a single JSON object with this exact schema:
|
| 5 |
+
{"topics":["string"],"definitions":[{"term":"string","definition":"string"}],"facts":["string"],"formulae":["string"]}
|
| 6 |
+
Rules: Extract only atomic units present in the source. Discard filler, headings, page numbers.
|
| 7 |
+
OUTPUT RAW JSON ONLY. Start with { end with }. No markdown fences."""
|
| 8 |
+
|
| 9 |
+
# MiniCPM β combined OCR + concept extraction from image in one call
|
| 10 |
+
DOCUMENT_VISION_PROMPT = """\
|
| 11 |
+
You are a study material processor. This image contains educational material.
|
| 12 |
+
First, extract ALL text visible in the image (OCR: include equations, formulas, handwritten notes, diagrams).
|
| 13 |
+
Then, identify the key concepts from that text.
|
| 14 |
+
Output a single JSON object:
|
| 15 |
+
{"ocr_text":"string","topics":["string"],"definitions":[{"term":"string","definition":"string"}],"facts":["string"],"formulae":["string"]}
|
| 16 |
+
OUTPUT RAW JSON ONLY. No markdown fences."""
|
| 17 |
+
|
| 18 |
+
# Nemotron β quest path generation
|
| 19 |
+
QUEST_AGENT_SYSTEM = """\
|
| 20 |
+
You are a curriculum designer. Receive extracted concepts and produce a learning quest path.
|
| 21 |
+
Output schema: {"quests":[{"name":"string (short RPG-style name)","topics":["string"],"boss_topic":"string","difficulty":"easy|medium|hard"}]}
|
| 22 |
+
Rules: Order quests foundational-first. Each quest covers 2-4 related topics. Generate 2-3 quests.
|
| 23 |
+
boss_topic is the hardest, most central concept.
|
| 24 |
+
OUTPUT RAW JSON ONLY."""
|
| 25 |
+
|
| 26 |
+
# Nemotron β BATCH question generation (all 4 questions in one call)
|
| 27 |
+
QUIZ_AGENT_BATCH_SYSTEM = """\
|
| 28 |
+
You are an active-recall question generator.
|
| 29 |
+
Generate a complete set of questions for a learning quest in one response.
|
| 30 |
+
Output schema:
|
| 31 |
+
{"questions":[
|
| 32 |
+
{"question":"string","topic":"string","options":["string","string","string","string"],
|
| 33 |
+
"correct_idx":0,"explanation":"string","difficulty":"easy|medium|hard","type":"mcq","is_boss":false}
|
| 34 |
+
]}
|
| 35 |
+
Rules:
|
| 36 |
+
- options must be exactly 4 strings
|
| 37 |
+
- Incorrect options MUST represent common student misconceptions, not random strings
|
| 38 |
+
- The LAST question must have "is_boss":true and difficulty "hard"
|
| 39 |
+
- All other questions must have "is_boss":false
|
| 40 |
+
- topic is the subject area of each question (e.g., "Determinants")
|
| 41 |
+
- explanation is a concise factual statement
|
| 42 |
+
- If source material is provided, base questions on it to reduce hallucination
|
| 43 |
+
OUTPUT RAW JSON ONLY. No markdown fences."""
|
| 44 |
+
|
| 45 |
+
# Nemotron β Socratic tutor on wrong answer
|
| 46 |
+
TUTOR_AGENT_SYSTEM = """\
|
| 47 |
+
You are a Socratic tutor. A student answered incorrectly.
|
| 48 |
+
You MUST NOT reveal the correct answer directly.
|
| 49 |
+
Respond in 2-3 sentences:
|
| 50 |
+
1. Acknowledge their likely reasoning empathetically.
|
| 51 |
+
2. Point out the conceptual flaw with a guiding hint.
|
| 52 |
+
3. End with a Socratic question to lead them to the correct concept.
|
| 53 |
+
Plain prose. No JSON. No markdown."""
|
| 54 |
+
|
| 55 |
+
# Tiny Aya β multilingual translation
|
| 56 |
+
LANGUAGE_AGENT_SYSTEM = """\
|
| 57 |
+
You are a multilingual educational assistant.
|
| 58 |
+
Translate or explain the given content in the target language.
|
| 59 |
+
Preserve all technical terms exactly. Keep explanations clear and educational.
|
| 60 |
+
Respond only in the target language."""
|
config/settings.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
import os
|
| 3 |
+
from dataclasses import dataclass
|
| 4 |
+
try:
|
| 5 |
+
from dotenv import load_dotenv
|
| 6 |
+
load_dotenv()
|
| 7 |
+
except ImportError:
|
| 8 |
+
pass
|
| 9 |
+
|
| 10 |
+
@dataclass(frozen=True)
|
| 11 |
+
class Settings:
|
| 12 |
+
# Model IDs β each maps to a sponsor prize
|
| 13 |
+
ocr_model_id: str # MiniCPM-V 4.6 β π Best MiniCPM Build
|
| 14 |
+
reasoning_model_id: str # Nemotron 3 Nano 4B β π Nemotron Hardware Prize
|
| 15 |
+
multilingual_model_id: str # Tiny Aya 3.3B β multilingual demo
|
| 16 |
+
speech_model_id: str # Whisper large-v3 β voice mode
|
| 17 |
+
|
| 18 |
+
# API keys β two providers only
|
| 19 |
+
hf_api_key: str # HuggingFace (MiniCPM, Aya, Whisper)
|
| 20 |
+
featherless_api_key: str # Featherless (Nemotron)
|
| 21 |
+
|
| 22 |
+
# Generation params
|
| 23 |
+
max_new_tokens: int
|
| 24 |
+
temperature: float
|
| 25 |
+
|
| 26 |
+
# Storage
|
| 27 |
+
db_path: str
|
| 28 |
+
|
| 29 |
+
# Quiz config
|
| 30 |
+
questions_per_quest: int # regular questions per quest (boss always +1)
|
| 31 |
+
default_language: str
|
| 32 |
+
|
| 33 |
+
def load_settings() -> Settings:
|
| 34 |
+
return Settings(
|
| 35 |
+
ocr_model_id=os.getenv("OCR_MODEL_ID", "openbmb/MiniCPM-V-4_6"),
|
| 36 |
+
reasoning_model_id=os.getenv("REASONING_MODEL_ID", "nvidia/Nemotron-3-Nano-4B"),
|
| 37 |
+
multilingual_model_id=os.getenv("MULTILINGUAL_MODEL_ID", "CohereForAI/aya-23-35B"),
|
| 38 |
+
speech_model_id=os.getenv("SPEECH_MODEL_ID", "openai/whisper-large-v3"),
|
| 39 |
+
hf_api_key=os.getenv("HF_API_KEY", ""),
|
| 40 |
+
featherless_api_key=os.getenv("FEATHERLESS_API_KEY", ""),
|
| 41 |
+
max_new_tokens=int(os.getenv("MAX_NEW_TOKENS", "1024")),
|
| 42 |
+
temperature=float(os.getenv("TEMPERATURE", "0.3")),
|
| 43 |
+
db_path=os.getenv("DB_PATH", "studywithchampai.db"),
|
| 44 |
+
questions_per_quest=int(os.getenv("QUESTIONS_PER_QUEST", "3")),
|
| 45 |
+
default_language=os.getenv("DEFAULT_LANGUAGE", "en"),
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
SETTINGS = load_settings()
|