Skip to content

Commit f86f147

Browse files
authored
Merge pull request #522 from kikumoto/feature/add_suuport_thinking_for_sonnet4_opus4
feat: Add Claude-4 thinking support
2 parents ae8c32d + 27353f7 commit f86f147

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

examples/pipelines/providers/anthropic_manifold_pipeline.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ def get_anthropic_models(self):
6868
{"id": "claude-sonnet-4-20250514", "name": "claude-4-sonnet"},
6969
]
7070

71+
def get_thinking_supported_models(self):
72+
"""Returns list of model identifiers that support extended thinking"""
73+
return [
74+
"claude-3-7",
75+
"claude-sonnet-4",
76+
"claude-opus-4"
77+
]
78+
7179
async def on_startup(self):
7280
print(f"on_startup:{__name__}")
7381
pass
@@ -168,7 +176,7 @@ def pipe(
168176
}
169177

170178
if body.get("stream", False):
171-
supports_thinking = "claude-3-7" in model_id
179+
supports_thinking = any(model in model_id for model in self.get_thinking_supported_models())
172180
reasoning_effort = body.get("reasoning_effort", "none")
173181
budget_tokens = REASONING_EFFORT_BUDGET_TOKEN_MAP.get(reasoning_effort)
174182

examples/pipelines/providers/aws_bedrock_claude_pipeline.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,6 @@ def __init__(self):
5050
# self.id = "openai_pipeline"
5151
self.name = "Bedrock: "
5252

53-
self.valves = self.Valves(
54-
**{
55-
"AWS_ACCESS_KEY": os.getenv("AWS_ACCESS_KEY", "your-aws-access-key-here"),
56-
"AWS_SECRET_KEY": os.getenv("AWS_SECRET_KEY", "your-aws-secret-key-here"),
57-
"AWS_REGION_NAME": os.getenv("AWS_REGION_NAME", "your-aws-region-name-here"),
58-
}
59-
)
60-
6153
self.valves = self.Valves(
6254
**{
6355
"AWS_ACCESS_KEY": os.getenv("AWS_ACCESS_KEY", ""),
@@ -72,6 +64,13 @@ def __init__(self):
7264

7365
self.update_pipelines()
7466

67+
def get_thinking_supported_models(self):
68+
"""Returns list of model identifiers that support extended thinking"""
69+
return [
70+
"claude-3-7",
71+
"claude-sonnet-4",
72+
"claude-opus-4"
73+
]
7574

7675
async def on_startup(self):
7776
# This function is called when the server is started.
@@ -183,13 +182,14 @@ def pipe(
183182
}
184183

185184
if body.get("stream", False):
186-
supports_thinking = "claude-3-7" in model_id
185+
supports_thinking = any(model in model_id for model in self.get_thinking_supported_models())
187186
reasoning_effort = body.get("reasoning_effort", "none")
188187
budget_tokens = REASONING_EFFORT_BUDGET_TOKEN_MAP.get(reasoning_effort)
189188

190189
# Allow users to input an integer value representing budget tokens
191190
if (
192191
not budget_tokens
192+
and reasoning_effort is not None
193193
and reasoning_effort not in REASONING_EFFORT_BUDGET_TOKEN_MAP.keys()
194194
):
195195
try:

0 commit comments

Comments
 (0)