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
I searched the LangChain documentation with the integrated search.
I used the GitHub search to find a similar question and didn't find it.
I am sure that this is a bug in LangChain rather than my code.
The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
Example Code
from langchain_community.chat_models import ChatZhipuAI
llm = ChatZhipuAI(
model="glm-4",
api_key=os.getenv("ZHIPUAI_API_KEY"),
temperature=temperature,
max_tokens=1024,
)
messages = [
AIMessage(content="Hi."),
SystemMessage(content="Your role is a poet."),
HumanMessage(content="Write a short poem about AI in four lines."),
]
response = chat.invoke(messages)
I'm sorry. I found the reason for the mistake. Because I set the temperature to 0.
I saw a hint in The source code: “What sampling temperature to use. The value ranges from 0.0 to 1.0 and cannot be equal to 0.”
Checked other resources
Example Code
from langchain_community.chat_models import ChatZhipuAI
llm = ChatZhipuAI(
model="glm-4",
api_key=os.getenv("ZHIPUAI_API_KEY"),
temperature=temperature,
max_tokens=1024,
)
messages = [
AIMessage(content="Hi."),
SystemMessage(content="Your role is a poet."),
HumanMessage(content="Write a short poem about AI in four lines."),
]
response = chat.invoke(messages)
Error Message and Stack Trace (if applicable)
When code runs to the invoke function, an error occurs:
httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://open.bigmodel.cn/api/paas/v4/chat/completions'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400
Description
When code runs to the invoke function, an error occurs:
httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://open.bigmodel.cn/api/paas/v4/chat/completions'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400
System Info
langchain==0.1.14
langchain-community==0.0.33
langchain-core==0.1.44
zhipuai==2.0.1.20240429
platform: linux
python: 3.8
The text was updated successfully, but these errors were encountered: