langchain BadRequestError with vllm locally hosted Llama3 70B Model

nom7f22z  于 3个月前  发布在  其他
关注(0)|答案(2)|浏览(114)

检查其他资源

  • 我为这个问题添加了一个非常描述性的标题。
  • 我在集成搜索中搜索了 LangGraph /LangChain 文档。
  • 我使用 GitHub 搜索找到了一个类似的问题,但没有找到。
  • 我确信这是 LangGraph/LangChain 中的一个 bug,而不是我的代码。
  • 我确信这作为一个问题 rather than a GitHub discussion 更合适,因为这是一个 LangGraph bug 而不是设计问题。

示例代码

Following below example with locally hosted llama3 70B instruct model with ChatOpenAI
https://langchain-ai.github.io/langgraph/how-tos/create-react-agent/

Simlar issue with the following example: 
from langchain_core.tools import tool
from langgraph.graph import MessageGraph from langgraph.prebuilt import ToolNode, tools_condition

@tool def divide(a: float, b: float) -> int: """Return a / b.""" return a / b

llm = ChatOpenAI( model_name = 'Meta-Llama-3-70B-Instruct', base_url = "http://172.17.0.8:xxxx/v1/", api_key = "EMPTY", temperature=0).bind( response_format={"type": "json_object"} )

tools = [divide]

graph_builder = MessageGraph() 
graph_builder.add_node("tools", ToolNode(tools)) 
graph_builder.add_node("chatbot", llm.bind_tools(tools)) 
graph_builder.add_edge("tools", "chatbot") 
graph_builder.add_conditional_edges( ... "chatbot", tools_condition ... ) graph_builder.set_entry_point("chatbot") 
graph = graph_builder.compile() 

graph.invoke([("user", "What's 329993 divided by 13662?")])

错误信息和堆栈跟踪(如果适用)

BadRequestError: Error code: 400 - {'object': 'error', 'message': "[{'type': 'extra_forbidden', 'loc': ('body', 'tools'), 'msg': 'Extra inputs are not permitted', 'input': [{'type': 'function', 'function': {'name': 'get_weather', 'description': 'Use this to get weather information.', 'parameters': {'type': 'object', 'properties': {'city': {'enum': ['nyc', 'sf'], 'type': 'string'}}, 'required': ['city']}}}], 'url': 'https://errors.pydantic.dev/2.7/v/extra_forbidden'}]", 'type': 'BadRequestError', 'param': None, 'code': 400}

描述

我尝试如下示例化 ChatOpenAI:
llm = ChatOpenAI( model_name = 'Meta-Llama-3-70B-Instruct', base_url = "", api_key = "EMPTY", temperature=0)
llm = ChatOpenAI( model_name = 'Meta-Llama-3-70B-Instruct', base_url = "", api_key = "EMPTY", temperature=0).bind( response_format={"type": "json_object"} )

系统信息

Meta 的 llama 3 70B Instruct 本地托管在 vllm.
ChatOpenAI 对于其他应用程序(例如 RAG 和 LCEL)运行正常。

eqqqjvef

eqqqjvef1#

我认为这里的问题是关于llama工具调用,而不是关于LangGraph。

zkure5ic

zkure5ic2#

以下示例演示了对llama 3的支持,但是它使用的是Ollama。
https://github.com/langchain-ai/langgraph/blob/main/examples/rag/langgraph_rag_agent_llama3_local.ipynb
问题是在ChatOpenAI/vllm中吗?我们有一个vllm/ChatOpenAI的示例吗?

相关问题