Skip to content

Commit 14762c8

Browse files
committed
feat: update Claude Haiku model configuration and response format handling
1 parent b225cd3 commit 14762c8

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

transaction_parser/transaction_parser/ai_integration/models.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class Model:
1818
base_url: str
1919
response_format: str
2020
supports_temperature: bool = True
21+
supports_response_format: bool = True
2122

2223

2324
### DeepSeek Models
@@ -118,16 +119,18 @@ class GeminiFlash(Model):
118119
class ClaudeHaiku(Model):
119120
"""Anthropic Claude Haiku 4.5 model configuration.
120121
121-
- `response_format` is set to JSON but JSON output is not guaranteed,
122-
because Anthropic's compatibility layer silently ignores the `response_format` parameter.
122+
- `response_format` is not sent because Anthropic's compatibility layer
123+
rejects `json_object` and silently ignores other values.
124+
- JSON output is not guaranteed.
123125
124126
- https://platform.claude.com/docs/en/api/openai-sdk
125127
"""
126128

127129
name: str = "claude-haiku-4-5"
128130
service_provider: str = "Anthropic"
129131
base_url: str = "https://api.anthropic.com/v1/"
130-
response_format: str = ResponseFormat.JSON.value
132+
response_format: str = ResponseFormat.TEXT.value
133+
supports_response_format: bool = False
131134

132135

133136
### Model Registry

transaction_parser/transaction_parser/ai_integration/parser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,12 @@ def _build_request_params(self, messages: tuple) -> dict:
129129
request_params = {
130130
"model": self.model.name,
131131
"messages": messages,
132-
"response_format": {"type": self.model.response_format},
133132
"stream": False,
134133
}
135134

135+
if self.model.supports_response_format:
136+
request_params["response_format"] = {"type": self.model.response_format}
137+
136138
# Only include temperature if the model supports it
137139
if self.model.supports_temperature:
138140
request_params["temperature"] = 0.7

0 commit comments

Comments
 (0)