Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Parsing error while patching Openai calls using litellm.completion with gpt-4o #712

Open
2 of 3 tasks
fenilfaldu opened this issue Feb 28, 2025 · 0 comments
Open
2 of 3 tasks
Labels
bug Something isn't working

Comments

@fenilfaldu
Copy link

fenilfaldu commented Feb 28, 2025

Contact Details

[email protected]

πŸ“¦ Package Version

0.3.26

🎞️ Framework Version

Litellm 1.58.2

πŸ”Ž Describe the Bug

@areibman At first it seemed it was an error from Litellm, but using Litellm independently it works fine.

Reference Script:

import os
import litellm
import agentops
agentops.init(default_tags=["Openai Example"])
messages = [{"role": "user", "content": "hello from litellm"}]
response = litellm.completion(
    model="gpt-4o", 
    messages=messages
)
print(response.choices[0].message.content)
agentops.end_session("Success") 
Traceback (most recent call last):
  File "C:\Users\LENOVO\Documents\AgentOps\agentops\.venv\lib\site-packages\litellm\llms\openai\openai.py", line 429, in make_sync_openai_chat_completion_request       
    response = raw_response.parse()
AttributeError: 'str' object has no attribute 'parse'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\LENOVO\Documents\AgentOps\agentops\.venv\lib\site-packages\litellm\llms\openai\openai.py", line 691, in completion
    raise e
  File "C:\Users\LENOVO\Documents\AgentOps\agentops\.venv\lib\site-packages\litellm\llms\openai\openai.py", line 619, in completion
    self.make_sync_openai_chat_completion_request(
  File "C:\Users\LENOVO\Documents\AgentOps\agentops\.venv\lib\site-packages\litellm\llms\openai\openai.py", line 433, in make_sync_openai_chat_completion_request       
    raise Exception(
Exception: error - 'str' object has no attribute 'parse', Received response - <APIResponse [200 OK] type=<class 'openai.types.chat.chat_completion.ChatCompletion'>>, Type of response - <class 'str'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\LENOVO\Documents\AgentOps\agentops\.venv\lib\site-packages\litellm\main.py", line 1612, in completion
    raise e
  File "C:\Users\LENOVO\Documents\AgentOps\agentops\.venv\lib\site-packages\litellm\main.py", line 1585, in completion
    response = openai_chat_completions.completion(
  File "C:\Users\LENOVO\Documents\AgentOps\agentops\.venv\lib\site-packages\litellm\llms\openai\openai.py", line 701, in completion
    raise OpenAIError(
litellm.llms.openai.common_utils.OpenAIError: error - 'str' object has no attribute 'parse', Received response - <APIResponse [200 OK] type=<class 'openai.types.chat.chat_completion.ChatCompletion'>>, Type of response - <class 'str'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\LENOVO\Documents\AgentOps\agentops\Tracing.py", line 19, in <module>
    response = litellm.completion(
  File "C:\Users\LENOVO\Documents\AgentOps\agentops\agentops\llms\providers\litellm.py", line 197, in patched_function
    result = self.original_create(*args, **kwargs)
  File "C:\Users\LENOVO\Documents\AgentOps\agentops\.venv\lib\site-packages\litellm\utils.py", line 1030, in wrapper
    raise e
  File "C:\Users\LENOVO\Documents\AgentOps\agentops\.venv\lib\site-packages\litellm\utils.py", line 906, in wrapper
    result = original_function(*args, **kwargs)
  File "C:\Users\LENOVO\Documents\AgentOps\agentops\.venv\lib\site-packages\litellm\main.py", line 2967, in completion
    raise exception_type(
  File "C:\Users\LENOVO\Documents\AgentOps\agentops\.venv\lib\site-packages\litellm\litellm_core_utils\exception_mapping_utils.py", line 2189, in exception_type        
    raise e
  File "C:\Users\LENOVO\Documents\AgentOps\agentops\.venv\lib\site-packages\litellm\litellm_core_utils\exception_mapping_utils.py", line 449, in exception_type
    raise APIError(
litellm.exceptions.APIError: litellm.APIError: APIError: OpenAIException - error - 'str' object has no attribute 'parse', Received response - <APIResponse [200 OK] type=<class 'openai.types.chat.chat_completion.ChatCompletion'>>, Type of response - <class 'str'>

🀝 Contribution

  • Yes, I'd be happy to submit a pull request with these changes.
  • I need some guidance on how to contribute.
  • I'd prefer the AgentOps team to handle this update.
@fenilfaldu fenilfaldu added the bug Something isn't working label Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant