AgentEra / Agently

[GenAI Application Development Framework] 🚀 Build GenAI application quick and easy 💬 Easy to interact with GenAI agent in code using structure data and chained-calls syntax 🧩 Use Event-Driven Flow *TriggerFlow* to manage complex GenAI working logic 🔀 Switch to any model without rewrite application code

Home Page:http://agently.tech

Repository from Github https://github.comAgentEra/AgentlyRepository from Github https://github.comAgentEra/Agently

调用本地llama3模型时提示,Expected either ('model' and 'prompt') or ('model', 'prompt' and 'stream') arguments to be given

lastrei opened this issue · comments

agent_factory \
    .set_settings("current_model", "OAIClient") \
    .set_settings("model.OpenAI.auth", {"api_key": "None"}) \
    .set_settings("model.OpenAI.url", "http://127.0.0.1:11434/v1/") \
    .set_settings("model.OpenAI.options", {"model": "llama3"}) \

错误提示如下:

Traceback (most recent call last):
  File "E:\model_zoo\faceswap\rag\Lib\threading.py", line 1045, in _bootstrap_inner
    self.run()
  File "E:\model_zoo\faceswap\rag\Lib\threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
  File "E:\model_zoo\faceswap\rag\Lib\site-packages\Agently\Agent\Agent.py", line 243, in start_in_theard
    raise Exception(f"[Agent Request] Error: { str(e) }")
Exception: [Agent Request] Error: Missing required arguments; Expected either ('model' and 'prompt') or ('model', 'prompt' and 'stream') arguments to be given

在直接对话时没有问题:

import Agently

agent = (
    Agently.create_agent()
    .set_settings("current_model", "OAIClient")
    .set_settings("model.OAIClient.auth", {"api_key": "None"})
    .set_settings("model.OAIClient.options", {"model": "llama3"})
    .set_settings("model.OAIClient.url", "http://127.0.0.1:11434/v1")
)

print(agent.input("hello").start())

Hello! It's nice to meet you. Is there something I can help you with, or would you like to chat?

但是在tool use的时候就会报错:

(前略)

from datetime import datetime
import pytz


def get_current_datetime(timezone):
    tz = pytz.timezone(timezone)
    return datetime.now().astimezone(tz)


# 自定义工具信息字典
tool_info = {
    "tool_name": "get_now",
    "desc": "get current data and time",
    "args": {
        "timezone": (
            "str",
            "[*Required] Timezone string used in pytz.timezone() in Python"
        )
    },
    "func": get_current_datetime
}
# 向Agent实例注册自定义工具
agent.register_tool(
    tool_name=tool_info["tool_name"],
    desc=tool_info["desc"],
    args=tool_info["args"],
    func=tool_info["func"],
)
"""发起请求"""
print(agent.input("我在乌鲁木齐,现在几点了?").start("completions"))

.set_settings("current_model", "OpenAI") \

直接使用OpenAI就可以正常工作了,close

.set_settings("current_model", "OpenAI") \

直接使用OpenAI就可以正常工作了,close

#在这里设定了启用的模型系列是OAIClient
.set_settings("current_model", "OAIClient") \
#这里的设置都指向的OpenAI
#等于OAIClient没有进行任何设置,就会报错
.set_settings("model.OpenAI.auth", {"api_key": "None"}) 
.set_settings("model.OpenAI.url", "http://127.0.0.1:11434/v1/") 
.set_settings("model.OpenAI.options", {"model": "llama3"})

使用OAIClient而不是OpenAI,能够帮助开发者避开号称OpenAI适配的模型潜藏的坑,比如只能传1条system消息,消息记录里必须用户先说模型才能回复