Skip to content

AttributeError: module 'openai' has no attribute 'DefaultHttpxClient' when running LangGraph example in Chainlit backend #198

Description

@sh-js

I encountered an error when trying to run the LangGraph example inside the Chainlit backend. Specifically, I cloned the Chainlit repository and added the LangGraph example code in backend/chainlit/hello.py.

However, when I ran the code, I got the following error:

from langchain_openai.chat_models import AzureChatOpenAI, ChatOpenAI
  File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/__init__.py", line 1, in <module>
    from langchain_openai.chat_models.azure import AzureChatOpenAI
  File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/azure.py", line 21, in <module>
    from langchain_openai.chat_models.base import BaseChatOpenAI
  File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/base.py", line 105, in <module>
    from langchain_openai.chat_models._client_utils import (
  File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/_client_utils.py", line 17, in <module>
    class _SyncHttpxClientWrapper(openai.DefaultHttpxClient):
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'openai' has no attribute 'DefaultHttpxClient'

Steps to Reproduce:

Clone the Chainlit repo.

Add the LangGraph example ( https://docs.chainlit.io/integrations/langchain#with-langgraph ) code to backend/chainlit/hello.py.

Run the backend.

Environment:

Python version: 3.12

Poetry-managed virtualenv

Latest versions of chainlit(2.6.0), langchain (0.3.26), langchain_openai (0.3.27), and openai (1.93.3)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions