LangChain with Chatopera Tool Calling

GitHub | Pypi | Demo

build Agent Services by integrating chatopera cloud services with langchain via tool calling.
在这里插入图片描述

Usage

  • Install via pip
pip install -U langchain_chatopera
  • Use in the code
base_url = ENV.get("OLLAMA_BASE_URL", "http://localhost:11434")
llm = ChatOllama(model=MODEL, streaming=True, base_url=base_url)
chatopera_bot_api = ChatoperaBotAPIWrapper(chatopera_bot_client_id="xxx", chatopera_bot_client_secret="xxx")
chatopera_bot = ChatoperaBotResults(max_results=2, api_wrapper=chatopera_bot_api)
tools = [chatopera_bot]
checkpoints_saver = MemorySaver()
agent_executor = create_react_agent(llm, tools, checkpointer=checkpoints_saver)

full_response = ""
for chunk, metadata in agent_executor.stream(
        {"messages": st.session_state.chat_history, "language": language},
        config,
        stream_mode="messages",
    ):
        
    if metadata["langgraph_node"] == "agent" and isinstance(chunk, AIMessage):  # Filter to just model responses
        text_chunk = chunk.content
        full_response += text_chunk
        response_container.markdown(full_response)

To get a fully setup demo, checkout LINK.

Contribute

  • Publish locally - scripts/install.sh.
  • Then, run against Demo.

License

LICENSE

Logo

火山引擎开发者社区是火山引擎打造的AI技术生态平台,聚焦Agent与大模型开发,提供豆包系列模型(图像/视频/视觉)、智能分析与会话工具,并配套评测集、动手实验室及行业案例库。社区通过技术沙龙、挑战赛等活动促进开发者成长,新用户可领50万Tokens权益,助力构建智能应用。

更多推荐