Replies: 1 comment
-
Your code might be getting stuck at
Additionally, make sure that the from unittest.mock import MagicMock, patch
def test_openai_invoke(mock_completion: dict) -> None:
llm = ChatOpenAI(api_key=openai_api_key, base_url=base_url)
mock_client = MagicMock()
completed = False
def mock_create(*args: Any, **kwargs: Any) -> Any:
nonlocal completed
completed = True
return mock_completion
mock_client.create = mock_create
with patch.object(llm, "client", mock_client):
res = llm.invoke("hi")
assert res.content == "Expected Response"
assert completed If you are using the Azure OpenAI integration, ensure that the following environment variables are set:
To enable detailed logs for debugging, you can use the from langchain.globals import set_debug
set_debug(True)
llm = ChatOpenAI(api_key=openai_api_key, base_url=base_url)
output = llm.invoke("hi") This will print the inputs and outputs of all LangChain components, providing a comprehensive view of the chain's execution [1][2]. |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
When i run my demo,It just stuck at llm.invoke().I can't figure what wrong with it
System Info
in windows10 with pycharm
Beta Was this translation helpful? Give feedback.
All reactions