|
23 | 23 | process_image_file, |
24 | 24 | ) |
25 | 25 |
|
| 26 | +ENV_REASONING = "GPTME_REASONING" |
| 27 | +ENV_REASONING_BUDGET = "GPTME_REASONING_BUDGET" |
| 28 | + |
26 | 29 | if TYPE_CHECKING: |
27 | 30 | # noreorder |
28 | 31 | import anthropic.types # fmt: skip |
@@ -70,7 +73,7 @@ def _record_usage( |
70 | 73 |
|
71 | 74 | def _should_use_thinking(model_meta: ModelMeta, tools: list[ToolSpec] | None) -> bool: |
72 | 75 | # Support environment variable to override reasoning behavior |
73 | | - env_reasoning = os.environ.get("GPTME_REASONING") |
| 76 | + env_reasoning = os.environ.get(ENV_REASONING) |
74 | 77 | if env_reasoning and env_reasoning.lower() in ("1", "true", "yes"): |
75 | 78 | return True |
76 | 79 | elif env_reasoning and env_reasoning.lower() in ("0", "false", "no"): |
@@ -173,7 +176,7 @@ def chat(messages: list[Message], model: str, tools: list[ToolSpec] | None) -> s |
173 | 176 |
|
174 | 177 | model_meta = get_model(f"anthropic/{model}") |
175 | 178 | use_thinking = _should_use_thinking(model_meta, tools) |
176 | | - thinking_budget = int(os.environ.get("GPTME_THINKING_BUDGET", "16000")) |
| 179 | + thinking_budget = int(os.environ.get(ENV_REASONING_BUDGET, "16000")) |
177 | 180 | max_tokens = model_meta.max_output or 4096 |
178 | 181 |
|
179 | 182 | response = _anthropic.messages.create( |
@@ -223,7 +226,7 @@ def stream( |
223 | 226 | model_meta = get_model(f"anthropic/{model}") |
224 | 227 | use_thinking = _should_use_thinking(model_meta, tools) |
225 | 228 | # Use the same configurable thinking budget as chat() |
226 | | - thinking_budget = int(os.environ.get("GPTME_THINKING_BUDGET", "16000")) |
| 229 | + thinking_budget = int(os.environ.get(ENV_REASONING_BUDGET, "16000")) |
227 | 230 | max_tokens = model_meta.max_output or 4096 |
228 | 231 |
|
229 | 232 | with _anthropic.messages.stream( |
|
0 commit comments