Description
Checks
- I have updated to the lastest minor and patch version of Strands
- I have checked the documentation and this is not expected behavior
- I have searched ./issues and there are no duplicates of my issue
Strands Version
v0.1.7
Python Version
3.11
Operating System
macos 12
Installation Method
pip
Steps to Reproduce
from source code review,
sdk-python/src/strands/models/openai.py
Line 80 in 7c5f7a7
@OverRide
def stream(self, request: dict[str, Any]) -> Iterable[dict[str, Any]]:
"""Send the request to the OpenAI model and get the streaming response.
Args:
request: The formatted request to send to the OpenAI model.
Returns:
An iterable of response events from the OpenAI model.
"""
response = self.client.chat.completions.create(**request)
this does not work if the caller does not explicitly set stream=True, in the request, or set to False
The OpenAI API will not stream responses unless stream=True is set.
So it is an easy fix
Before passing the request dictionary to self.client.chat.completions.create(**request), override or set the stream key to True:
request["stream"] = True
response = self.client.chat.completions.create(**request)
Expected Behavior
see comment above for the fix
Actual Behavior
see comment above for the fix
Additional Context
No response
Possible Solution
see comment above for the fix
Related Issues
No response