Spaces:
Sleeping
Sleeping
Update app.py
Browse files4 unmodified lines567891011121314151617181920108 unmodified lines1291301311321331341354 unmodified linesfrom pypdf import PdfReaderfrom docx import Documentfrom sentence_transformers import SentenceTransformerfrom huggingface_hub import InferenceClient# ---------- الإعدادات ----------MODEL_ID = os.environ.get("MODEL_ID", "Qwen/Qwen2.5-72B-Instruct")EMBED_ID = "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"CHUNK_WORDS = 220OVERLAP_WORDS = 40embedder = SentenceTransformer(EMBED_ID)client = InferenceClient(model=MODEL_ID, token=os.environ.get("HF_TOKEN"))SYSTEM_PROMPT = """You are a strict teaching assistant for ONE specific course.You will receive: (1) the course LEVEL description, (2) EXCERPTS from the course108 unmodified lines)try:resp = client.chat_completion(messages=[{"role": "system", "content": SYSTEM_PROMPT},{"role": "user", "content": user_msg},4 unmodified lines567891011121314151617181920108 unmodified lines1291301311321331341351364 unmodified linesfrom pypdf import PdfReaderfrom docx import Documentfrom sentence_transformers import SentenceTransformerfrom groq import Groq# ---------- الإعدادات ----------MODEL_ID = os.environ.get("MODEL_ID", "llama-3.3-70b-versatile")EMBED_ID = "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"CHUNK_WORDS = 220OVERLAP_WORDS = 40embedder = SentenceTransformer(EMBED_ID)client = Groq(api_key=os.environ.get("GROQ_API_KEY"))SYSTEM_PROMPT = """You are a strict teaching assistant for ONE specific course.You will receive: (1) the course LEVEL description, (2) EXCERPTS from the course108 unmodified lines)try:resp = client.chat.completions.create(model=MODEL_ID,messages=[{"role": "system", "content": SYSTEM_PROMPT},{"role": "user", "content": user_msg},
app.py+5-4