Skip to content

Commit 77331de

Browse files
authored
fix bedrock streaming token tracking (#8431)
1 parent c27eff3 commit 77331de

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

dspy/clients/lm.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ def _get_stream_completion_fn(
269269
stream = cast(MemoryObjectSendStream, stream)
270270
caller_predict_id = id(caller_predict) if caller_predict else None
271271

272+
if dspy.settings.track_usage:
273+
request["stream_options"] = {"include_usage": True}
274+
272275
async def stream_completion(request: Dict[str, Any], cache_kwargs: Dict[str, Any]):
273276
response = await litellm.acompletion(
274277
cache=cache_kwargs,

0 commit comments

Comments
 (0)