You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"delta" is supposed to be something like { "role": "", content: "" } instead of ""
Version
0.8.25
Steps to Reproduce
Run the following code to reproduce the issue:
import os
from llama_index.llms import OpenAI, AzureOpenAI
from llama_index.llms.base import ChatMessage
use_azure = True
if use_azure:
os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_VERSION"] = "2023-07-01-preview"
os.environ["OPENAI_API_BASE"] = "https://xxxx.openai.azure.com/"
os.environ["OPENAI_API_KEY"] = "xxxxxxxxxxxxxxxxxxxxxxx"
llm = AzureOpenAI(engine = "gpt-35-turbo")
else:
os.environ["OPENAI_API_TYPE"] = "open_ai"
os.environ["OPENAI_API_KEY"] = "sk-xxxxxxxxxxxxxxxxxxxxxxx"
os.environ["OPENAI_API_BASE"] = "https://api.openai.com/v1"
llm = OpenAI()
for delta in llm.stream_chat([ChatMessage(content = "Hello!")]):
print(delta)
Relevant Logs/Tracbacks
$ python3 test.py
Traceback (most recent call last):
File "/home/ubuntuuser/LlamaIndex_env/project/test.py", line 19, in<module>fordeltain llm.stream_chat([ChatMessage(content = "Hello!")]):
File "/home/ubuntuuser/LlamaIndex_env/lib/python3.10/site-packages/llama_index/llms/base.py", line 157, in wrapped_gen
forxin f_return_val:
File "/home/ubuntuuser/LlamaIndex_env/lib/python3.10/site-packages/llama_index/llms/openai.py", line 233, in gen
role = delta.get("role", "assistant")
AttributeError: 'str' object has no attribute 'get'
The text was updated successfully, but these errors were encountered:
Thanks for reporting this issue. It seems like the 'delta' object is expected to be a dictionary but it's getting a string instead, which is causing the AttributeError.
To help me investigate this further, could you please provide the following additional information:
Can you confirm if this issue is happening consistently or intermittently?
Are there any specific conditions under which this error occurs?
Could you provide the version of Python you're using?
Are there any other dependencies or packages that you're using in your environment which might be relevant to this issue?
This information will help me understand the context better and find a solution for you.
Thanks for your cooperation.
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
Bug Description
PR #7646 has introduced another issue instead of fixing the bug #7640
Now, AzureOpenAI.stream_chat causes AttributeError.
Look here:
https://github.com/jerryjliu/llama_index/blob/276d976c1cadbee316e6a777b2b37cccfd1d59f0/llama_index/llms/openai.py#L229-L234
and here:
https://github.com/jerryjliu/llama_index/blob/276d976c1cadbee316e6a777b2b37cccfd1d59f0/llama_index/llms/openai.py#L448-L453
"delta" is supposed to be something like { "role": "", content: "" } instead of ""
Version
0.8.25
Steps to Reproduce
Run the following code to reproduce the issue:
Relevant Logs/Tracbacks
The text was updated successfully, but these errors were encountered: