Skip to content

Commit 0eb0c9b

Browse files
committed
fix: extract env vars to constants
1 parent 54f289e commit 0eb0c9b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

gptme/llm/llm_anthropic.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
process_image_file,
2424
)
2525

26+
ENV_REASONING = "GPTME_REASONING"
27+
ENV_REASONING_BUDGET = "GPTME_REASONING_BUDGET"
28+
2629
if TYPE_CHECKING:
2730
# noreorder
2831
import anthropic.types # fmt: skip
@@ -70,7 +73,7 @@ def _record_usage(
7073

7174
def _should_use_thinking(model_meta: ModelMeta, tools: list[ToolSpec] | None) -> bool:
7275
# Support environment variable to override reasoning behavior
73-
env_reasoning = os.environ.get("GPTME_REASONING")
76+
env_reasoning = os.environ.get(ENV_REASONING)
7477
if env_reasoning and env_reasoning.lower() in ("1", "true", "yes"):
7578
return True
7679
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
173176

174177
model_meta = get_model(f"anthropic/{model}")
175178
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"))
177180
max_tokens = model_meta.max_output or 4096
178181

179182
response = _anthropic.messages.create(
@@ -223,7 +226,7 @@ def stream(
223226
model_meta = get_model(f"anthropic/{model}")
224227
use_thinking = _should_use_thinking(model_meta, tools)
225228
# 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"))
227230
max_tokens = model_meta.max_output or 4096
228231

229232
with _anthropic.messages.stream(

0 commit comments

Comments
 (0)