Skip to content

Commit 2c4a043

Browse files
committed
bug fixes
1 parent 58fd99f commit 2c4a043

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

lib/idp_common_pkg/idp_common/extraction/agentic_idp.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,13 @@ def extraction_tool(
251251
When you call this tool it overwrites the previous extraction, if you want to expand the extraction use jsonpatch.
252252
This tool needs to be Successfully invoked before the patch tool can be used."""
253253

254-
logger.info("extraction_tool called", extra={"models_extraction": extraction})
255-
extraction_model = model_class(**extraction) # pyright: ignore[reportAssignmentType]
256-
extraction_dict = extraction_model.model_dump()
254+
# Note: The @tool decorator passes data as a dict, not as a model instance
255+
# We need to validate it manually using the Pydantic model
256+
extraction_model = model_class.model_validate(extraction) # pyright: ignore[reportAssignmentType]
257+
extraction_dict = extraction_model.model_dump(mode="json")
258+
logger.info(
259+
"extraction_tool called", extra={"models_extraction": extraction_dict}
260+
)
257261
agent.state.set(key="current_extraction", value=extraction_dict)
258262
logger.debug(
259263
"Successfully stored extraction in state",
@@ -1000,7 +1004,9 @@ async def structured_output_async(
10001004
state={
10011005
"current_extraction": None,
10021006
"images": {},
1003-
"existing_data": existing_data.model_dump() if existing_data else None,
1007+
"existing_data": existing_data.model_dump(mode="json")
1008+
if existing_data
1009+
else None,
10041010
"extraction_schema_json": schema_json, # Store for schema reminder tool
10051011
},
10061012
conversation_manager=SummarizingConversationManager(

lib/idp_common_pkg/idp_common/extraction/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ def _invoke_extraction_model(
927927
context="Extraction",
928928
)
929929

930-
extracted_fields = structured_data.model_dump()
930+
extracted_fields = structured_data.model_dump(mode="json")
931931
metering = response_with_metering["metering"]
932932
parsing_succeeded = True
933933
else:

0 commit comments

Comments
 (0)