-
Notifications
You must be signed in to change notification settings - Fork 104
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
Make @RegisterAiService beans request scoped by default #96
Conversation
@jmartisk pinecone test still failing after merging your PR :) |
That must be because https://github.com/quarkiverse/quarkus-langchain4j/actions/runs/7101672400 and https://github.com/quarkiverse/quarkus-langchain4j/actions/runs/7101669612 were triggered at about the same time. |
We'll need to submit PRs from forks unless absolutely necessary :) |
Ah gotcha, thanks! |
I think I'm gonna take out the pinecone test altogether and only enable it in the nightly build. |
I’m not sure about that. Typically, rest clients are application-scoped. We should change how we handle memory instead. |
Unfortunately it's not easy (or possible at all). The basic problem is that memory is also used when using |
Yeah I kinda agree. You can disable it by removing the propagation of secrets into workflows. The test runs when it sees a non-empty value of |
Are you sure this will continue to work with the web socket? It will create many instances of the AI service, which is what we want to avoid. I do not get the issue with the creation part. I would need to have a look. Maybe we need to prioritize the scope thingy. |
See the changes to the examples :). Essentially it works if you use context propagation |
What happens is that although the |
What if we use a proxy/facade in-between that uses the ARC API to instantiate the memory in the proper context? |
Also, what about having AiServicesContext in a special scope and not the AIService? |
I thought of that. The problem is producing it, but I'll look into it |
@jmartisk the nightly build with the pinecone test is failing very weirdly: https://github.com/quarkiverse/quarkus-langchain4j/actions/runs/7108550795/job/19352035493 |
Holy * that test is obnoxious. Looking into it... |
Nice, Pinecone has changed the response format and they now don't include an empty |
Thanks! |
This is what I am trying now, but so far it has subtle issues, not to mention that the code is a lot more complicated than what I have pushed here. |
Also, the more I think about it, the more it makes sense to me that the context (which is an entity unknown to the user) should have the same scope as the bean itself. |
a736eed
to
cf17b8c
Compare
I have updated the PR with something slightly better. As for the websockets, the scope is opened, but it is never closed unfortunately... So for those samples I made the services singleton. If we agree on this approach, then I'll need to update the docs. |
749fb9a
to
ee75189
Compare
Ah Ah! I knew web sockets would be problematic. I won’t have time to look before next week (traveling). So let’s go with this approach and extend the doc, for now. We need to go back to the whiteboard to find a proper way to deal with this. |
I totally agree |
ae6d811
to
645cc73
Compare
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 a typo.
core/runtime/src/main/java/io/quarkiverse/langchain4j/RegisterAiService.java
Outdated
Show resolved
Hide resolved
This is done because otherwise the chat memory does not get cleared properly. Furthermore, add a way to remove memory entries when the service goes out of scope Fixes: #95
This is done because otherwise the chat memory
does not get cleared properly.
Fixes: #95
Do we need a docs update to go along with this?