Provide best practices for LMOps, as well as elegant and convenient access to the features of the Qianfan MaaS Platform. (提供大模型工具链最佳实践,以及优雅且便捷地访问千帆大模型平台)
from langchain.tools import tool
@tool
def greeting(name: str) -> str:
"""Greetings from external System."""
return f"{name}, Warmly welcome from External System"
def test_full():
from langchain_community.chat_models import QianfanChatEndpoint
import os
model = QianfanChatEndpoint(
endpoint="ernie-4.0-turbo-8k",
api_key=os.getenv("API_KEY_QIANFAN_AK"),
secret_key=os.getenv("API_KEY_QIANFAN_SK")
)
prompt = ChatPromptTemplate.from_messages(
[
(
"system",
"You just make sure to use the 'greeting' tool for each talk and output the tool output.",
),
("placeholder", "{chat_history}"),
("human", "{input}"),
("placeholder", "{agent_scratchpad}"),
]
)
tools = [greeting]
agent = create_openai_functions_agent(model, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
content = agent_executor.invoke({"input": "My name is Hao"})
assert "Hao" in content["output"] # failed in here, content["output"] is ""
The unittest failed but works with the other ChatModel. not sure what's the problem it is.
System Info
qianfan version: 0.3.0 langchain:0.2.16 python: 3.10
Reproduction
The unittest failed but works with the other ChatModel. not sure what's the problem it is.