Skip to content

Commit b84d06e

Browse files
authored
fix(pdf): add t, top-p and top-k params (flare-foundation#105)
2 parents 73a644f + 5d4fc44 commit b84d06e

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ wheels/
1717

1818

1919
# sqlite
20-
*.db
20+
*.db
21+
*.pdf

examples/05_ingest_pdf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ async def main() -> None:
128128
model=app_settings.agent.gemini_model,
129129
tools=[read_pdf_text_tool],
130130
instruction=pdf_agent_instruction,
131+
generate_content_config=types.GenerateContentConfig(
132+
temperature=0.0, top_k=1, top_p=0.3, candidate_count=1
133+
),
131134
)
132135

133136
# Mock onchain contract posting
-1.83 KB
Binary file not shown.

examples/data/sample_invoice.pdf

-1.83 KB
Binary file not shown.

src/flare_ai_kit/ingestion/settings.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,23 @@ class PDFFieldExtractionSettings(BaseSettings):
6464
"""Specifies fields to extract from a PDF and their locations."""
6565

6666
field_name: str = Field(description="The name of the field to extract.")
67-
x0: int = Field(description="The starting x-coordinate of the bounding box.")
68-
y0: int = Field(description="The starting y-coordinate of the bounding box.")
69-
x1: int = Field(description="The ending x-coordinate of the bounding box.")
70-
y1: int = Field(description="The ending y-coordinate of the bounding box.")
7167
data_type: str = Field(
7268
"string",
7369
description="The data type of the field (e.g., 'string', 'integer', 'date').",
7470
)
71+
# For deterministic extraction pipeline
72+
x0: int | None = Field(
73+
default=None, description="The starting x-coordinate of the bounding box."
74+
)
75+
y0: int | None = Field(
76+
default=None, description="The starting y-coordinate of the bounding box."
77+
)
78+
x1: int | None = Field(
79+
default=None, description="The ending x-coordinate of the bounding box."
80+
)
81+
y1: int | None = Field(
82+
default=None, description="The ending y-coordinate of the bounding box."
83+
)
7584

7685

7786
class PDFTemplateSettings(BaseSettings):

0 commit comments

Comments
 (0)