Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"column_break_zgpf",
"google_gemini_flash_25",
"google_gemini_pro_25",
"column_break_clde",
"claude_haiku_45",
"pdf_processor_section",
"pdftotext",
"ocrmypdf",
Expand Down Expand Up @@ -183,6 +185,17 @@
"fieldtype": "Check",
"label": "Google Gemini Flash-2.5"
},
{
"fieldname": "column_break_clde",
"fieldtype": "Column Break"
},
{
"allow_on_submit": 1,
"default": "0",
"fieldname": "claude_haiku_45",
"fieldtype": "Check",
"label": "Claude Haiku-4.5"
},
{
"fieldname": "pdf_processor_section",
"fieldtype": "Section Break",
Expand Down Expand Up @@ -301,7 +314,7 @@
"link_fieldname": "dataset"
}
],
"modified": "2026-04-13 09:37:12.298195",
"modified": "2026-04-15 12:00:20.190290",
"modified_by": "Administrator",
"module": "Parser Benchmark",
"name": "Parser Benchmark Dataset",
Expand All @@ -326,4 +339,4 @@
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"openai_gpt_5_mini": "OpenAI gpt-5-mini",
"google_gemini_pro_25": "Google Gemini Pro-2.5",
"google_gemini_flash_25": "Google Gemini Flash-2.5",
"claude_haiku_45": "Claude Haiku-4.5",
}

PDF_PROCESSOR_FIELD_MAP = {
Expand Down Expand Up @@ -43,6 +44,7 @@ class ParserBenchmarkDataset(Document):
)

amended_from: DF.Link | None
claude_haiku_45: DF.Check
company: DF.Link | None
country: DF.Literal["India", "Other"]
deepseek_chat: DF.Check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"fieldtype": "Select",
"in_list_view": 1,
"label": "AI Model",
"options": "DeepSeek Chat\nDeepSeek Reasoner\nOpenAI gpt-4o\nOpenAI gpt-4o-mini\nOpenAI gpt-5\nOpenAI gpt-5-mini\nGoogle Gemini Pro-2.5\nGoogle Gemini Flash-2.5",
"options": "DeepSeek Chat\nDeepSeek Reasoner\nOpenAI gpt-4o\nOpenAI gpt-4o-mini\nOpenAI gpt-5\nOpenAI gpt-5-mini\nGoogle Gemini Pro-2.5\nGoogle Gemini Flash-2.5\nClaude Haiku-4.5",
"read_only": 1
},
{
Expand Down Expand Up @@ -423,7 +423,7 @@
"in_create": 1,
"index_web_pages_for_search": 1,
"links": [],
"modified": "2026-04-13 09:38:44.604789",
"modified": "2026-04-15 12:00:33.722723",
"modified_by": "Administrator",
"module": "Parser Benchmark",
"name": "Parser Benchmark Log",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ParserBenchmarkLog(Document):
"OpenAI gpt-5-mini",
"Google Gemini Pro-2.5",
"Google Gemini Flash-2.5",
"Claude Haiku-4.5",
]
ai_parse_time: DF.Float
ai_response: DF.Code | None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"fieldtype": "Select",
"in_list_view": 1,
"label": "AI Model",
"options": "DeepSeek Chat\nDeepSeek Reasoner\nOpenAI gpt-4o\nOpenAI gpt-4o-mini\nOpenAI gpt-5\nOpenAI gpt-5-mini\nGoogle Gemini Pro-2.5\nGoogle Gemini Flash-2.5",
"options": "DeepSeek Chat\nDeepSeek Reasoner\nOpenAI gpt-4o\nOpenAI gpt-4o-mini\nOpenAI gpt-5\nOpenAI gpt-5-mini\nGoogle Gemini Pro-2.5\nGoogle Gemini Flash-2.5\nClaude Haiku-4.5",
"reqd": 1
},
{
Expand Down Expand Up @@ -56,7 +56,7 @@
],
"istable": 1,
"links": [],
"modified": "2026-03-27 10:36:00.699499",
"modified": "2026-04-15 12:01:24.501498",
"modified_by": "Administrator",
"module": "Parser Benchmark",
"name": "Parser Benchmark Token Cost",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ParserBenchmarkTokenCost(Document):
"OpenAI gpt-5-mini",
"Google Gemini Pro-2.5",
"Google Gemini Flash-2.5",
"Claude Haiku-4.5",
]
currency: DF.Link
input_cost_per_million: DF.Currency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const AI_MODELS = [
"OpenAI gpt-5-mini",
"Google Gemini Pro-2.5",
"Google Gemini Flash-2.5",
"Claude Haiku-4.5",
];

const PDF_PROCESSORS = ["PDFtoText", "OCRMyPDF", "Docling"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
"OpenAI gpt-4o-mini": 3,
"Google Gemini Pro-2.5": 4,
"Google Gemini Flash-2.5": 5,
"DeepSeek Reasoner": 6,
"DeepSeek Chat": 7,
"Claude Haiku-4.5": 6,
"DeepSeek Reasoner": 7,
"DeepSeek Chat": 8,
}

_PDF_PROCESSOR_ORDER = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const AI_MODELS = [
"OpenAI gpt-5-mini",
"Google Gemini Pro-2.5",
"Google Gemini Flash-2.5",
"Claude Haiku-4.5",
];

const PDF_PROCESSORS = ["OCRMyPDF", "Docling"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const AI_MODELS = [
"OpenAI gpt-5-mini",
"Google Gemini Pro-2.5",
"Google Gemini Flash-2.5",
"Claude Haiku-4.5",
];

const PDF_PROCESSORS = ["PDFtoText", "OCRMyPDF", "Docling"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
"OpenAI gpt-4o-mini": 3,
"Google Gemini Pro-2.5": 4,
"Google Gemini Flash-2.5": 5,
"DeepSeek Reasoner": 6,
"DeepSeek Chat": 7,
"Claude Haiku-4.5": 6,
"DeepSeek Reasoner": 7,
"DeepSeek Chat": 8,
}

_PDF_PROCESSOR_ORDER = {
Expand Down
23 changes: 23 additions & 0 deletions transaction_parser/transaction_parser/ai_integration/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Model:
base_url: str
response_format: str
supports_temperature: bool = True
supports_response_format: bool = True


### DeepSeek Models
Expand Down Expand Up @@ -111,6 +112,27 @@ class GeminiFlash(Model):
response_format: str = ResponseFormat.JSON.value


### Anthropic Models


@dataclass
class ClaudeHaiku(Model):
"""Anthropic Claude Haiku 4.5 model configuration.

- `response_format` is not sent because Anthropic's compatibility layer
rejects `json_object` and silently ignores other values.
- JSON output is not guaranteed.

- https://platform.claude.com/docs/en/api/openai-sdk
"""

name: str = "claude-haiku-4-5"
service_provider: str = "Anthropic"
base_url: str = "https://api.anthropic.com/v1/"
response_format: str = ResponseFormat.TEXT.value
supports_response_format: bool = False


### Model Registry

MODELS = {
Expand All @@ -122,4 +144,5 @@ class GeminiFlash(Model):
"OpenAI gpt-5-mini": OpenAIGPT5Mini(),
"Google Gemini Pro-2.5": GeminiPro(),
"Google Gemini Flash-2.5": GeminiFlash(),
"Claude Haiku-4.5": ClaudeHaiku(),
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,12 @@ def _build_request_params(self, messages: tuple) -> dict:
request_params = {
"model": self.model.name,
"messages": messages,
"response_format": {"type": self.model.response_format},
"stream": False,
}

if self.model.supports_response_format:
request_params["response_format"] = {"type": self.model.response_format}

# Only include temperature if the model supports it
if self.model.supports_temperature:
request_params["temperature"] = 0.7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"engine": "InnoDB",
"field_order": [
"service_provider",
"column_break_ogyu",
"api_key"
],
"fields": [
Expand All @@ -15,7 +16,7 @@
"fieldtype": "Select",
"in_list_view": 1,
"label": "Service Provider",
"options": "DeepSeek\nOpenAI\nGoogle",
"options": "DeepSeek\nOpenAI\nGoogle\nAnthropic",
"reqd": 1
},
{
Expand All @@ -24,18 +25,23 @@
"in_list_view": 1,
"label": "API Key",
"reqd": 1
},
{
"fieldname": "column_break_ogyu",
"fieldtype": "Column Break"
}
],
"grid_page_length": 50,
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2025-04-01 13:08:21.049741",
"modified": "2026-04-15 12:02:09.481616",
"modified_by": "Administrator",
"module": "Transaction Parser",
"name": "Transaction Parser API Key Item",
"owner": "Administrator",
"permissions": [],
"row_format": "Dynamic",
"sort_field": "modified",
"sort_order": "DESC",
"states": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,18 @@


class TransactionParserAPIKeyItem(Document):
# begin: auto-generated types
# This code is auto-generated. Do not modify anything in this block.

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from frappe.types import DF

api_key: DF.Password
parent: DF.Data
parentfield: DF.Data
parenttype: DF.Data
service_provider: DF.Literal["DeepSeek", "OpenAI", "Google", "Anthropic"]
# end: auto-generated types
pass
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"fieldtype": "Select",
"label": "Default AI Model",
"mandatory_depends_on": "eval: doc.enabled",
"options": "DeepSeek Chat\nDeepSeek Reasoner\nOpenAI gpt-4o\nOpenAI gpt-4o-mini\nOpenAI gpt-5\nOpenAI gpt-5-mini\nGoogle Gemini Pro-2.5\nGoogle Gemini Flash-2.5"
"options": "DeepSeek Chat\nDeepSeek Reasoner\nOpenAI gpt-4o\nOpenAI gpt-4o-mini\nOpenAI gpt-5\nOpenAI gpt-5-mini\nGoogle Gemini Pro-2.5\nGoogle Gemini Flash-2.5\nClaude Haiku-4.5"
},
{
"default": "PDFtoText",
Expand Down Expand Up @@ -175,7 +175,7 @@
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2026-04-13 09:09:13.061580",
"modified": "2026-04-15 12:02:29.008840",
"modified_by": "Administrator",
"module": "Transaction Parser",
"name": "Transaction Parser Settings",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class TransactionParserSettings(Document):
"OpenAI gpt-5-mini",
"Google Gemini Pro-2.5",
"Google Gemini Flash-2.5",
"Claude Haiku-4.5",
]
enabled: DF.Check
incoming_email_accounts: DF.Table[TransactionParserEmailAccount]
Expand Down
Loading