update Gemini API : use thinking levels
This commit is contained in:
1 parent
7bc588e9a1
commit
ec6ac9580b
9 files changed
+161
-21
No files matched your search
+19
-6
@@ -1,6 +1,8 @@
|
||||
from pathlib import Path
|
||||
import io
|
||||
from . import utils
|
||||
from . import configuration as settings
|
||||
from .gemini_config import thinking_config
|
||||
|
||||
PERSPECTIVE_GUIDANCE = (
|
||||
"Ce barème est indicatif, si une réponse est entièrement correcte mais utilise "
|
||||
@@ -173,8 +175,20 @@ UNROLLED_SCHEMA = {
|
||||
|
||||
from google.genai import types
|
||||
|
||||
def batch_generation_config(thinking_level):
|
||||
"""Build the REST generation config for a grading batch request."""
|
||||
config = {
|
||||
"maxOutputTokens": 65535,
|
||||
"responseMimeType": "application/json",
|
||||
"responseSchema": UNROLLED_SCHEMA,
|
||||
}
|
||||
thinking = thinking_config(thinking_level)
|
||||
if thinking is not None:
|
||||
config["thinkingConfig"] = thinking.model_dump(mode="json", by_alias=True, exclude_none=True)
|
||||
return config
|
||||
|
||||
# The root model for parsing is be: List[EvaluationEntry]
|
||||
def generate_request(input_dir, file, full_label):
|
||||
def generate_request(input_dir, file, full_label, *, thinking_level=settings.THINKING_LEVEL_PRO):
|
||||
"""Generates request for Gemini."""
|
||||
prompt = make_prompt(input_dir, full_label)
|
||||
image_path = Path(file)
|
||||
@@ -194,8 +208,7 @@ def generate_request(input_dir, file, full_label):
|
||||
|
||||
generate_content_config = types.GenerateContentConfig(
|
||||
automatic_function_calling=types.AutomaticFunctionCallingConfig(disable=True),
|
||||
temperature=1.0,
|
||||
top_p=0.95,
|
||||
thinking_config=thinking_config(thinking_level),
|
||||
seed=0,
|
||||
max_output_tokens=65535,
|
||||
response_mime_type= "application/json",
|
||||
@@ -272,7 +285,7 @@ Commentaires d'origine :
|
||||
|
||||
config = types.GenerateContentConfig(
|
||||
automatic_function_calling=types.AutomaticFunctionCallingConfig(disable=True),
|
||||
temperature=1.0,
|
||||
thinking_config=thinking_config(settings.THINKING_LEVEL_FLASH),
|
||||
response_mime_type="application/json",
|
||||
response_json_schema=TypeAdapter(List[FeedbackItem]).json_schema()
|
||||
)
|
||||
@@ -303,7 +316,7 @@ Voici les labels possibles. Ta réponse doit être l'un d'entre eux :
|
||||
types.Part.from_text(text=prompt)])]
|
||||
config = types.GenerateContentConfig(
|
||||
automatic_function_calling=types.AutomaticFunctionCallingConfig(disable=True),
|
||||
temperature=1.0,
|
||||
thinking_config=thinking_config(settings.THINKING_LEVEL_FLASH),
|
||||
)
|
||||
return contents, config
|
||||
|
||||
@@ -334,7 +347,7 @@ d'entre eux :
|
||||
])]
|
||||
config = types.GenerateContentConfig(
|
||||
automatic_function_calling=types.AutomaticFunctionCallingConfig(disable=True),
|
||||
temperature=1.0,
|
||||
thinking_config=thinking_config(settings.THINKING_LEVEL_FLASH),
|
||||
response_mime_type="application/json",
|
||||
)
|
||||
return contents, config
|
||||
Reference in new issue
Block a user