AI-Engineer-Foundation / agent-protocol

Common interface for interacting with AI agents. The protocol is tech stack agnostic - you can use it with any framework for building agents.
https://agentprotocol.ai
MIT License
998 stars 119 forks source link

Proposal: Langchain Integration #74

Open jondwillis opened 1 year ago

jondwillis commented 1 year ago

Objective:

The primary advantage to be gained from integrating with Langchain is for Agent Protocol exposure/advocacy. Langchain docs and repos get a decent chunk of traffic! There is also greater potential for simple and quick interop between projects that adopt Langchain and/or the Agent Protocol already.

Additionally, the proposed Agent and AgentExecutor could be used as a reference implementation.

Background:

LangChain consists of a Python and Typescript library. There are also some other newer applications in the ecosystem such as LangSmith and LangServe. LangChain is a commonly used library that has built-in agents already.

Proposed:

TL;DR: Implement something like AgentProtocolAgent and AgentProtocolAgentExecutor, which would take an Agent Protocol API-compliant base URL. After there is a PR open for that, we can then evaluate if some other abstractions like Tool, Chain, Retriever, etc., would be worth implementing as well.

We can probably get by with following: https://github.com/langchain-ai/langchainjs/blob/main/.github/contributing/INTEGRATIONS.md Otherwise, we contact and work with the LangChain TS and Python maintainers so that we can have a high chance of success for having a set of pull requests merged into the upstream Langchain repos. The pull requests should consider integrating with the Agent Protocol in the following ways:

Examples:

TBD

Discussion Points:

Are the proposed abstractions the best to start with and sufficient?

I am happy to try to work on this initiative, but I also have limited time and would be more effective working on the Typescript portion.

davidzshi commented 1 year ago

First of all, excited that this proposal is in progress.

I think the abstractions make sense conceptually, but I'm having trouble understanding exactly how you would adapt a Langchain agent to the protocol.

Given that there are multiple agents and chains available in Langchain with many permutations for combining them, it'd be great to understand how an existing agent can become compliant and how that determination can be verified.

Some concrete examples detailing this would be fantastic - I'd be happy to contribute some after getting a better sense of what you're thinking.

jondwillis commented 1 year ago

First of all, excited that this proposal is in progress.

I think the abstractions make sense conceptually, but I'm having trouble understanding exactly how you would adapt a Langchain agent to the protocol.

Given that there are multiple agents and chains available in Langchain with many permutations for combining them, it'd be great to understand how an existing agent can become compliant and how that determination can be verified.

Some concrete examples detailing this would be fantastic - I'd be happy to contribute some after getting a better sense of what you're thinking.

I am working on this, and will link a few prototypes soon. After some basic research and discussion, the most clear path in my understand would be to write a custom AgentExecutor+Agent. (unfortunately AgentProtocolAgentExecutor, and AgentProtocolAgent do not exactly roll off the tongue 👅.) The primary new input to these would an Agent Protocol API-compliant base URL. This would basically serve as a reference implementation, and then I will consider exposing the Agent Protocol in other ways (Tools, Retrievers, Chains).

I may be oversimplifying or missing some details, so let me know if you have any specific suggestions or use-cases you want to support @davidzshi

hackgoofer commented 1 year ago

Given that there are multiple agents and chains available in Langchain with many permutations for combining them, it'd be great to understand how an existing agent can become compliant and how that determination can be verified.

This is how you can verify:

$ URL=http://127.0.0.1:8000 bash -c "$(curl -fsSL https://raw.githubusercontent.com/AI-Engineers-Foundation/agent-protocol/main/testing_suite/test.sh)"

where http://127.0.0.1:8000 is where your agent is running, and accepting REST calls that are compliant with the protocol.

davidzshi commented 1 year ago

Got it! Thanks @jondwillis @hackgoofer, that's helpful context. Looking forward to reading more about the reference implementation when it's ready.

I'm primarily interested in the potential of interoperable Langchain agents. In practice, this means that for a specific field, a number of specialist agents can be created and then called upon to solve complex problems. In Langchain, this would look like leveraging agents as tools, but what excites me most about Agent Protocol is the potential for multi-agent systems that are unaffiliated. If one generalist agent is able to, using the standardization of queries and responses, access the specialized skills of a specialist agent, it opens up an entire world of possibilities.