mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-23 10:19:28 +00:00
refactor(reasoning_effort_grid): tighten test helpers per Greptile review
Two P2 nits flagged by Greptile on PR 28036: 1. _build_completion_kwargs() defaulted vertex_project to "vertex-check-481318" when VERTEX_PROJECT was unset. That value is a specific GCP project that doesn't belong to this repo, so if the env-var skip guard were ever bypassed (misconfig, direct helper call), the test would silently issue calls to a foreign project rather than failing loudly. Drop the fallback and read os.environ["VERTEX_PROJECT"] directly, mirroring how AZURE_FOUNDRY_* are handled. 2. _build_messages_kwargs() was a one-liner that returned the result of _build_completion_kwargs() unchanged -- a dead abstraction with one caller. Inline at the _call_messages call site and delete the helper.
This commit is contained in:
@@ -65,20 +65,13 @@ def _build_completion_kwargs(model: ModelEntry, effort: str) -> Dict[str, Any]:
|
||||
if effort != "__omit__":
|
||||
kwargs["reasoning_effort"] = effort
|
||||
if model.model.startswith("vertex_ai/"):
|
||||
kwargs["vertex_project"] = os.environ.get(
|
||||
"VERTEX_PROJECT", "vertex-check-481318"
|
||||
)
|
||||
kwargs["vertex_project"] = os.environ["VERTEX_PROJECT"]
|
||||
if model.model.startswith("azure_ai/"):
|
||||
kwargs["api_base"] = os.environ["AZURE_FOUNDRY_API_BASE"]
|
||||
kwargs["api_key"] = os.environ["AZURE_FOUNDRY_API_KEY"]
|
||||
return kwargs
|
||||
|
||||
|
||||
def _build_messages_kwargs(model: ModelEntry, effort: str) -> Dict[str, Any]:
|
||||
kwargs = _build_completion_kwargs(model, effort)
|
||||
return kwargs
|
||||
|
||||
|
||||
def _converse_subbody(body: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""Return the dict that holds thinking/output_config for a Converse wire body."""
|
||||
return body.get("additionalModelRequestFields", body)
|
||||
@@ -185,7 +178,7 @@ async def _call_chat(model: ModelEntry, effort: str) -> Tuple[int, Optional[Exce
|
||||
async def _call_messages(
|
||||
model: ModelEntry, effort: str
|
||||
) -> Tuple[int, Optional[Exception]]:
|
||||
kwargs = _build_messages_kwargs(model, effort)
|
||||
kwargs = _build_completion_kwargs(model, effort)
|
||||
try:
|
||||
await litellm.anthropic_messages(**kwargs)
|
||||
return 200, None
|
||||
|
||||
Reference in New Issue
Block a user