MetaGLM / glm-cookbook

Examples and guides for using the GLM APIs
https://open.bigmodel.cn/
Apache License 2.0
797 stars 91 forks source link

跑glm_infomation_extraction.ipynb的时候报错 #5

Closed mashagua closed 7 months ago

mashagua commented 8 months ago

System Info / 系統信息

当代码跑到from langchain_community.chat_models import ChatZhipuAI

for question in question_prompt: messages = chat_template.format_messages(resume=data) messages.append( HumanMessage( content=question ) ) llm = ChatZhipuAI( temperature=0.01, model="glm-4", max_tokens=8192, stream=False, ) messages.append( AIMessage( content=llm(messages).content ) ) print(messages[-1].content)的时候,llm(message)会报TypeError: 'NoneType' object is not subscriptable,请问该怎么修改

Information / 问题信息

Reproduction / 复现过程

python 3.8,transformer=4.38.2

Expected behavior / 期待表现

我希望能返回你们notebook里的结果

zRzRzRzRzRzRzR commented 8 months ago

这个是没有执行代码,你试试8192调到8000呢

mashagua commented 7 months ago

我重新调了还是这个错误,/opt/conda/lib/python3.10/site-packages/langchain_core/_api/deprecation.py:117: LangChainDeprecationWarning: The function __call__ was deprecated in LangChain 0.1.7 and will be removed in 0.2.0. Use invoke instead. warn_deprecated( TypeError: 'NoneType' object is not subscriptable

hiwei93 commented 7 months ago

我重新调了还是这个错误,/opt/conda/lib/python3.10/site-packages/langchain_core/_api/deprecation.py:117: LangChainDeprecationWarning: The function __call__ was deprecated in LangChain 0.1.7 and will be removed in 0.2.0. Use invoke instead. warn_deprecated( TypeError: 'NoneType' object is not subscriptable

langchian 现在调用组件需要使用 invoke 方法,调用 llm 的时候使用 invoke 方法:llm.invoke(message)

注意:langchain里面的ChatZhipuAI实现没有兼容到最新的 zhipuai sdk,请确保依赖的版本:zhipuai==1.0.7

zRzRzRzRzRzRzR commented 7 months ago

langchain 智谱的PR没有通过,因此需要手动修改langchain community源代码支持

zRzRzRzRzRzRzR commented 7 months ago

下一个版本,langchain将支持GLM-4, 可以直接使用