Maplemx / Agently

[AI Agent Application Development Framework] - 🚀 Build AI agent native application in very few code 💬 Easy to interact with AI agent in code using structure data and chained-calls syntax 🧩 Enhance AI Agent using plugins instead of rebuild a whole new agent
http://agently.tech
Apache License 2.0
935 stars 105 forks source link

一言的多轮对话支持请求 #44

Closed Liyulingyue closed 4 months ago

Liyulingyue commented 4 months ago

你好,https://github.com/Maplemx/Agently/blob/main/playground/survey_agent_asks_questions_according_form.ipynb 给出了一个有趣的应用示例。但是当我尝试将多轮对话的功能应用在文心一言上时,上述代码并不支持。希望能供提供示例展示如何使用文心一言进行多轮对话。

Maplemx commented 4 months ago

您好,正常来讲,切换模型只需要修改设置即可,不知道具体的不支持是指哪个部分?

要将原案例中的模型设置修改为文心一言API,只需要这样做:

# 注释掉下面这段设置
#agent_factory\
#    .set_settings("model.OpenAI.auth", { "api_key": "" })\
#    .set_settings("model.OpenAI.options", { "model": "gpt-3.5-turbo-1106" })

# 使用下面这段设置
(
    agent_factory
        .set_settings("current_model", "ERNIE")
        .set_settings("model.ERNIE.auth", { "aistudio": "YOUR-ACCESS-TOKEN" })
)
Liyulingyue commented 4 months ago

感谢回复,我确认了一下。是因为我尝试单独地运行下方代码中地append逻辑,从而导致了报错。更改为extend的逻辑,功能是完好的。

    chat_history.extend([
        { "role": "user", "content": "hi" },
        { "role": "assistant", "content": opening["opening"] }
    ])
    # This logic down below works perfect for OpenAI GPT
    '''
    chat_history.append({ "role": "assistant", "content": opening["opening"] })
    '''