Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

fix(lm): forward headers to _get_stream_completion_fn in alitellm_completion (#9669)

Isaac Miller50fd9ea777d7
diff --git a/dspy/clients/lm.py b/dspy/clients/lm.py
index 29ec13dca..365b1b47c 100644
--- a/dspy/clients/lm.py
+++ b/dspy/clients/lm.py
@@ -434,14 +434,14 @@ async def alitellm_completion(request: dict[str, Any], num_retries: int, cache:
cache = cache or {"no-cache": True, "no-store": True}
request = dict(request)
request.pop("rollout_id", None)
- headers = request.pop("headers", None)
- stream_completion = _get_stream_completion_fn(request, cache, sync=False)
+ headers = _add_dspy_identifier_to_headers(request.pop("headers", None))
+ stream_completion = _get_stream_completion_fn(request, cache, sync=False, headers=headers)
if stream_completion is None:
return await litellm.acompletion(
cache=cache,
num_retries=num_retries,
retry_strategy="exponential_backoff_retry",
- headers=_add_dspy_identifier_to_headers(headers),
+ headers=headers,
**request,
)