Vik Paruchuri commited on
Commit
c24d4f4
·
1 Parent(s): 08bcaca

Add thinking budget

Browse files
Files changed (1) hide show
  1. marker/services/gemini.py +9 -0
marker/services/gemini.py CHANGED
@@ -21,6 +21,9 @@ class BaseGeminiService(BaseService):
21
  gemini_model_name: Annotated[
22
  str, "The name of the Google model to use for the service."
23
  ] = "gemini-2.0-flash"
 
 
 
24
 
25
  def img_to_bytes(self, img: PIL.Image.Image):
26
  image_bytes = BytesIO()
@@ -66,6 +69,12 @@ class BaseGeminiService(BaseService):
66
  if self.max_output_tokens:
67
  config["max_output_tokens"] = self.max_output_tokens
68
 
 
 
 
 
 
 
69
  try:
70
  responses = client.models.generate_content(
71
  model=self.gemini_model_name,
 
21
  gemini_model_name: Annotated[
22
  str, "The name of the Google model to use for the service."
23
  ] = "gemini-2.0-flash"
24
+ thinking_budget: Annotated[
25
+ int, "The thinking token budget to use for the service."
26
+ ] = None
27
 
28
  def img_to_bytes(self, img: PIL.Image.Image):
29
  image_bytes = BytesIO()
 
69
  if self.max_output_tokens:
70
  config["max_output_tokens"] = self.max_output_tokens
71
 
72
+ if self.thinking_budget is not None:
73
+ # For gemini models, we can optionally set a thinking budget in the config
74
+ config["thinking_config"] = types.ThinkingConfig(
75
+ thinking_budget=self.thinking_budget
76
+ )
77
+
78
  try:
79
  responses = client.models.generate_content(
80
  model=self.gemini_model_name,