Hi,
I am trying to use Gemini Batch with a single image per batch, this works perfectly fine without batch but doesn't work with batch enabled.
I get this error for every question:
['Request Bad Request: {"error": {"code": 400, "message": "Invalid value at \'contents[0].parts[0]\' (text), Starting an object on a scalar field", "status": "INVALID_ARGUMENT", "details": [{"@type": "type.googleapis.com/google.rpc.BadRequest", "fieldViolations": [{"field": "contents[0].parts[0]", "description": "Invalid value at \'contents[0].parts[0]\' (text), Starting an object on a scalar field"}]}]}}']
My class:
class PageOCR(curator.LLM):
"""A page OCR that extracts text from an image of a page."""
def prompt(self, input: dict) -> str:
"""Generate a prompt using the image."""
prompt_text = (
"Please OCR the following text and return the text content in JSON format."
"Note that this is text from a 1791 book that uses the long S character, please replace with the normal s."
)
image_url: str = input["image_path"]
return prompt_text, curator.types.Image(
url=image_url, detail="scanned page", mime_type="image/png"
)
def parse(self, input: dict, response: str) -> dict:
"""Parse the model response along with the input to the model into the desired output format."""
return {
"text": response,
}
my call which fails:
llm = PageOCR(
model_name="gemini-2.5-flash-preview-05-20", backend="gemini", batch=True
)
my call which works:
llm = PageOCR(model_name="gemini-2.5-flash-preview-05-20", backend=None, batch=False)
And the execution code:
dataset_dict = {
"image_path": [item["image_path"] for item in dataset_input_list]
}
dataset = Dataset.from_dict(dataset_dict)
ds_result = llm(dataset)
where image_path values are GCP bucket paths (but not this works perfectly not in batch so I doubt this is the issue?)
Hi,
I am trying to use Gemini Batch with a single image per batch, this works perfectly fine without batch but doesn't work with batch enabled.
I get this error for every question:
['Request Bad Request: {"error": {"code": 400, "message": "Invalid value at \'contents[0].parts[0]\' (text), Starting an object on a scalar field", "status": "INVALID_ARGUMENT", "details": [{"@type": "type.googleapis.com/google.rpc.BadRequest", "fieldViolations": [{"field": "contents[0].parts[0]", "description": "Invalid value at \'contents[0].parts[0]\' (text), Starting an object on a scalar field"}]}]}}']My class:
my call which fails:
my call which works:
llm = PageOCR(model_name="gemini-2.5-flash-preview-05-20", backend=None, batch=False)And the execution code:
where
image_pathvalues are GCP bucket paths (but not this works perfectly not in batch so I doubt this is the issue?)