-
Notifications
You must be signed in to change notification settings - Fork 616
feat. Support AG UI protocol #230
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
Looks good besides the comments. The protocol seems a little immature and I'm not sure about the long term maintenance (seems like maybe a startup created it?). But, it's not a huge addition after refactors so I don't think it's a high cost to have it in this project, and several people upvoted in the issue. |
This protocol is a protocol layer hatched from the CopilotKit Agent front-end library. In theory, it can be directly used in CopilotKit, but I have not studied the CopilotKit front-end library in depth. |
I have provided a single page to run a simple example, but this front-end page will not be a production-level feature. |
const response = await fetch('/chatbot/stream', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Accept': 'text/event-stream', | ||
}, | ||
body: JSON.stringify({ | ||
message: userMessage, | ||
stream_protocol: 'agui', | ||
thread_id: threadId, | ||
user_id: generateUUID(), | ||
model: selectedModel, | ||
stream_tokens: true | ||
}) | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So a few concerns about this and the handleAgUIEvent
method below:
- Seems to just re-implement the client part of the ag-ui protocol from scratch
- Doesn't support tool messages which are important
- Chatbot is hard coded
To prove it works as expected, seems like it would be much better to use the provided agui typescript sdk, such as with the HttpAgent and AgentSubscriber classes to manage the handling.
I think it might mean the shape of the server endpoint needs to change, but that's probably desirable if we're trying to make something that's actually compatible with the protocol? Otherwise, I'm not sure this PR makes sense if it only implements the protocol halfway.
An alternate approach to this html page - I saw one of the provided ag-ui examples just writes a CLI in typescript. If it's easier to just provide a CLI that uses the typescript sdk instead of a full website, that seems sufficient to me.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The official one does provide one typescript-sdk
|
||
@app.get("/agui/") | ||
async def agui_root(): | ||
with open("web-agui/index.html", encoding="utf-8") as file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noting that this only works currently if the service is run from the root of the repo, and does not work if the service is in docker. If we move to a CLI or a website that just be launched directly from browser (no server interaction) we could just remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is indeed a difficult decision. If you want the agent to be a pure API service, then the web-agui function should also be separated into a rendering service like streamlit_app
.
Although the ag-ui output library has been added, I think this protocol is not a mature protocol and even lacks many functions.
Completed issue:#227