-
Notifications
You must be signed in to change notification settings - Fork 23
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
don't return the full chat object on the prepare and answer endpoints of the REST API #242
Comments
Thanks @peachkeel for opening this. I agree and had the task of opening an issue about this in my backlog. I'm hitting the same in #185 (comment) in a worse way. TBH, this was a premature optimization. We should remove it. The only upside for client in always returning the chat is that they don't have to track it. But this is only one API call away, so I guess this ok. Maybe later there is an actual use case, but we don't need to care right now. |
You're welcome regarding opening the issue. And thank you for getting v0.1.2 out and being such an active maintainer! One thing I want to bring up related to this issue is that the ragna/ragna/core/_components.py Lines 85 to 94 in 1e256e9
The corresponding Lines 35 to 39 in 1e256e9
Thus, Maybe this problem should be a separate issue, but I wanted to bring it up here since we're talking about changing the API. |
This is intentional and warrants a separate issue. TL;DR: when "live answering" we have access to the source content and thus could just send it back to the client. However, this doesn't work when we are recreating the chat from our state database unless we also store the source content inside the database. See #248. |
Feature description
I've noticed that the
/chats/{id}/answer
endpoint returns both the latestmessage
and the fullchat
:ragna/ragna/_api/core.py
Lines 210 to 227 in 1e256e9
I thought that maybe the UI needed all that state about the chat for some distributed system reason, but it looks like it does not:
ragna/ragna/_ui/central_view.py
Lines 361 to 369 in 1e256e9
Assuming there is a need to maintain API backward compatibility, could we add a
/chats/{id}/quick_answer
endpoint to Ragna that only returns aschemas.Message
object as opposed to a heavyweightschemas.MessageOutput
object?Value and/or benefit
Every call to
/chats/{id}/answer
appends another message to the chat. This means that each time the endpoint is called, the amount of data that needs to be sent over the wire increases. Over time, this O(m) growth makes getting answers more and more sluggish. Ideally, the/chats/{id}/answer
endpoint would be O(1) from a messages in the chat perspective. The proposed/chats/{id}/quick_answer
endpoint would act in that constant time/space manner.Anything else?
No response
The text was updated successfully, but these errors were encountered: