Support evaluation-local configuration and names overrides
This commit is contained in:
1 parent
0bb6f7d97c
commit
d4404e4c27
36 files changed
+409
-184
No files matched your search
@@ -48,9 +48,6 @@ def get_lcp(s1: str, s2: str) -> str:
|
||||
return lcp
|
||||
|
||||
|
||||
MODEL_ID = config.MODEL_LITE_ID
|
||||
api_key = config.API_KEY
|
||||
|
||||
# --- Modèles pour la Requête 1 ---
|
||||
class StatementContent(BaseModel):
|
||||
@field_validator("question_content", "solution_content", "context_content",
|
||||
@@ -246,7 +243,7 @@ def find_file(folder: Path, base_name: str) -> Path | None:
|
||||
|
||||
def _request_rubrics(client, group_context_text: str):
|
||||
response = client.models.generate_content(
|
||||
model=MODEL_ID,
|
||||
model=config.MODEL_LITE_ID,
|
||||
contents=[types.Content(role="user", parts=[
|
||||
types.Part.from_text(text=PROMPT_4),
|
||||
types.Part.from_text(text=f"--- CONTENU DU GROUPE ---\n{group_context_text}"),
|
||||
@@ -378,13 +375,13 @@ def refine_existing(workspace: EvaluationWorkspace, mode: str, *, api_client=Non
|
||||
questions[label] = "\n".join(parts)
|
||||
context = utils.enonce_total(workspace.root)
|
||||
if api_client is None:
|
||||
if not api_key:
|
||||
if not config.API_KEY:
|
||||
raise CliError("GEMINI_API_KEY is not configured")
|
||||
api_client = genai.Client(api_key=api_key)
|
||||
api_client = genai.Client(api_key=config.API_KEY)
|
||||
|
||||
if mode == "groups":
|
||||
response = api_client.models.generate_content(
|
||||
model=MODEL_ID,
|
||||
model=config.MODEL_LITE_ID,
|
||||
contents=[types.Content(role="user", parts=[types.Part.from_text(text=(
|
||||
"Regroupe ces questions d’examen en groupes cohérents pour la correction "
|
||||
"et l’annotation, selon leurs dépendances et leur contexte commun. "
|
||||
@@ -515,9 +512,9 @@ def process_exam(
|
||||
correction_text = correction_path.read_text(encoding="utf-8")
|
||||
|
||||
if api_client is None:
|
||||
if not api_key:
|
||||
if not config.API_KEY:
|
||||
raise CliError("GEMINI_API_KEY is not configured")
|
||||
api_client = genai.Client(api_key=api_key)
|
||||
api_client = genai.Client(api_key=config.API_KEY)
|
||||
client = api_client
|
||||
|
||||
# ==========================================
|
||||
@@ -543,7 +540,7 @@ def process_exam(
|
||||
|
||||
questions_data = ExamQuestions(questions=extract_stage(
|
||||
folder, 'questions', QuestionOnlyItem, 'question_content',
|
||||
lambda _pending: client.models.generate_content(model=MODEL_ID, contents=contents_1, config=config_1),
|
||||
lambda _pending: client.models.generate_content(model=config.MODEL_LITE_ID, contents=contents_1, config=config_1),
|
||||
))
|
||||
|
||||
# ==========================================
|
||||
@@ -567,7 +564,7 @@ def process_exam(
|
||||
types.Part.from_text(text='--- QUESTIONS EXTRAITES ---\n' + selected.model_dump_json(indent=2)),
|
||||
types.Part.from_text(text=f'--- CORRECTION SOURCE ({correction_path.name}) ---\n{correction_text}'),
|
||||
])]
|
||||
return client.models.generate_content(model=MODEL_ID, contents=contents, config=config_2)
|
||||
return client.models.generate_content(model=config.MODEL_LITE_ID, contents=contents, config=config_2)
|
||||
solutions_data = ExamSolutions(solutions=extract_stage(
|
||||
folder, 'solutions', SolutionOnlyItem, 'solution_content', request_solutions, labels=question_labels,
|
||||
))
|
||||
@@ -599,7 +596,7 @@ def process_exam(
|
||||
contents = [types.Content(role='user', parts=[*contents_3[0].parts,
|
||||
types.Part.from_text(text='Produis des contextes UNIQUEMENT pour les labels cibles suivants : '
|
||||
+ ', '.join(pending))])]
|
||||
return client.models.generate_content(model=MODEL_ID, contents=contents, config=config_3)
|
||||
return client.models.generate_content(model=config.MODEL_LITE_ID, contents=contents, config=config_3)
|
||||
context_data = ExamContext(contexts=extract_stage(
|
||||
folder, 'contexts', ExtractedContext, 'context_content', request_contexts, labels=question_labels,
|
||||
))
|
||||
@@ -1083,7 +1080,7 @@ def compile_existing_pdfs(workspace: EvaluationWorkspace) -> ExitCode:
|
||||
if not source_path.is_file():
|
||||
source_path = None
|
||||
fingerprint = hashlib.sha256((utils.fragment_latex_header(source_path)
|
||||
+ utils.LATEX_AFTER + str(source_path)).encode()).hexdigest()
|
||||
+ config.LATEX_AFTER + str(source_path)).encode()).hexdigest()
|
||||
status = json.loads(status_path.read_text()) if status_path.exists() else {}
|
||||
failed_before = not status.get('complete') or status.get('preamble_hash') != fingerprint
|
||||
if (pdf_path.is_file() and pdf_path.stat().st_size > 0
|
||||
|
||||
Reference in new issue
Block a user