Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

咨询下,agently对比langchain,最大的优势和亮点是什么 #96

Closed
godkun opened this issue May 25, 2024 · 9 comments
Closed
Labels
good first issue Good for newcomers solved For those issues already solved but stay open for more user can see

Comments

@godkun
Copy link

godkun commented May 25, 2024

No description provided.

@godkun
Copy link
Author

godkun commented May 27, 2024

image 没事了,reame.md文档中看到相关回答了

@Maplemx
Copy link
Owner

Maplemx commented May 29, 2024

还是可以补充一些说明:
LangChain是基于函数式编程的设计思想设计的,符合算法工程师的过往使用习惯,每一个步骤都通过一行或几行代码进行控制
Agently是基于面向对象编程的设计思想设计的,会希望把更多的互动封装到一个可交互的agent对象上,开发者开发的时候,主要是面向一个个agent对象实例来发出指令和获得请求结果

对于同样是请模型以结构化数据的格式输出一个笑话的实现代码,通过对比能更明显地看出二者的差别:

  • LangChain
from langchain.output_parsers.openai_tools import PydanticToolsParser

class Joke(BaseModel):
    """Joke to tell user."""

    setup: str = Field(description="question to set up a joke")
    punchline: str = Field(description="answer to resolve the joke")

    # You can add custom validation logic easily with Pydantic.
    @validator("setup")
    def question_ends_with_question_mark(cls, field):
        if field[-1] != "?":
            raise ValueError("Badly formed question!")
        return field

parser = PydanticToolsParser(tools=[Joke])

model = ChatOpenAI(model="gpt-3.5-turbo", temperature=0).bind_tools([Joke])
chain = prompt | model | parser

chain.invoke({"input": "tell me a joke"})

[Joke(setup="Why don't scientists trust atoms?", punchline='Because they make up everything!')]

资料来源:https://python.langchain.com/v0.1/docs/modules/model_io/output_parsers/types/openai_tools/#pydantictoolsparser

  • Agently
import Agently
agent = (
    Agently.create_agent()
        .set_settings("current_model", "OpenAI")
        .set_settings("model.OpenAI.auth.api_key", "xxxxxx")
        .set_settings(
            "model.OpenAI.options", 
            {
                "model": "gpt-3.5-turbo",
                "temperature": 0,
            }
        )
)

result = (
    agent
        .input("tell me a joke")
        .output({
            "setup": ("str", "question to set up a joke"),
            "punchline": ("str", "answer to resolve the joke"),
        })
        .start()
)

print(result)

{ "setup": "Why don't scientists trust atoms?", "punchline": "Because they make up everything!" }

@Maplemx Maplemx added good first issue Good for newcomers solved For those issues already solved but stay open for more user can see labels May 29, 2024
@Lizhen0628
Copy link

workflow 初看的时候眼前一亮,但实际体验的关联出参入参还是挺心累,不知道是不是我的打开方式不对。 @Maplemx

@Maplemx
Copy link
Owner

Maplemx commented Jun 6, 2024

workflow 初看的时候眼前一亮,但实际体验的关联出参入参还是挺心累,不知道是不是我的打开方式不对。 @Maplemx

不是,我们很快就会发布新的版本,优化了workflow的数据传递逻辑,你的感觉是对的,我们已经调整了

@Maplemx Maplemx pinned this issue Jun 7, 2024
@Lizhen0628
Copy link

workflow 初看的时候眼前一亮,但实际体验的关联出参入参还是挺心累,不知道是不是我的打开方式不对。 @Maplemx

不是,我们很快就会发布新的版本,优化了workflow的数据传递逻辑,你的感觉是对的,我们已经调整了

这两天也体验了一下metagpt 微软的autogpt 和 langgraph,整体感觉还是agently用起来会比较顺手【写代码的时候思路会更顺畅,祝做大做强!】。

@Lizhen0628
Copy link

另外,多agent自动交互这块感觉可能是agently比较欠缺的, @Maplemx 后续有啥规划吗?

@Maplemx
Copy link
Owner

Maplemx commented Jun 8, 2024

另外,多agent自动交互这块感觉可能是agently比较欠缺的, @Maplemx 后续有啥规划吗?

多Agent自动交互其实可以通过workflow和Agent之间的请求连接自主构建,你可以这样理解:

找到特定场景的Agent自动交互方法,是AI应用的一种最终形态(但不是唯一形态)

我们提供了由Agent代理工程师对模型的请求(点),可以承载Agent请求以及其他程序逻辑的Workflow Chunk(块),再支持将多个Workflow Chunk连接成单向有序可成环状的运行流(网),并在运行流中支持通过外部配置文件影响部分块的执行效果(分层),形成了对AI应用的基础框架架构。

多Agent自动交互可以在这个基础架构中,使用总控路由、Agent自发轮询、工作流事件触发等多种不同设计思路去完成设计。

我们之前也做过一些小型的样例,可以参考:

飞桨合作项目:https://aistudio.baidu.com/projectdetail/7178289 的第4部分

角色创作Agent和角色扮演Agent的单次信息交互:https://github.com/Maplemx/Agently/blob/main/playground/character_change_behaviours_according_mood_status.ipynb

@Maplemx
Copy link
Owner

Maplemx commented Jun 18, 2024

workflow 初看的时候眼前一亮,但实际体验的关联出参入参还是挺心累,不知道是不是我的打开方式不对。 @Maplemx

不是,我们很快就会发布新的版本,优化了workflow的数据传递逻辑,你的感觉是对的,我们已经调整了

3.3新版本已经发布,修订了workflow的数据传递逻辑,相关的开发手册正在撰写中

@Maplemx
Copy link
Owner

Maplemx commented Jul 26, 2024

workflow 初看的时候眼前一亮,但实际体验的关联出参入参还是挺心累,不知道是不是我的打开方式不对。 @Maplemx

不是,我们很快就会发布新的版本,优化了workflow的数据传递逻辑,你的感觉是对的,我们已经调整了

这两天也体验了一下metagpt 微软的autogpt 和 langgraph,整体感觉还是agently用起来会比较顺手【写代码的时候思路会更顺畅,祝做大做强!】。

教程已经更新:https://agently.cn/guides/workflow/index.html

@Maplemx Maplemx closed this as completed Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers solved For those issues already solved but stay open for more user can see
Projects
None yet
Development

No branches or pull requests

3 participants