-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(ollama): add retry template integration to OllamaChatModel #1852
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
feat(ollama): add retry template integration to OllamaChatModel #1852
Conversation
Thanks for your contribution! |
@@ -198,7 +213,8 @@ public Flux<ChatResponse> stream(Prompt prompt) { | |||
|
|||
observation.parentObservation(contextView.getOrDefault(ObservationThreadLocalAccessor.KEY, null)).start(); | |||
|
|||
Flux<OllamaApi.ChatResponse> ollamaResponse = this.chatApi.streamingChat(request); | |||
Flux<OllamaApi.ChatResponse> ollamaResponse = this.retryTemplate |
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.
When in streaming mode, we don't use the RetryTemplate
as it's not gonna work with the reactive streams. There is pending design on how to configure retries for streaming. You can follow this issue for updates: #1193
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.
Thank you @ThomasVitale for pointing this out.
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.
Adding some context to this issue: a
RetryTemplate
is used to add retry capabilities to the blocking model calls. At first, the same strategy was used for the streaming calls. After realising that it wasn't working as expected in a reactive stream, the usage ofRetryTemplate
streaming calls has been removed. In this issue, we would need to come up with a design for a retry feature to adopt in all streaming implementations across the different model providers.
Its still in use in the code tho: https://github.com/search?q=repo%3Aspring-projects%2Fspring-ai+%22Flux%3CChatCompletionChunk%3E%22+this.retryTemplate+execute&type=code
should I open a PR removing it?
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.
I think we do need a PR to remove that and to create an EPIC issue that reviews all the stream implementations of call the models for retry when streaming.
...-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaChatModelFunctionCallingIT.java
Outdated
Show resolved
Hide resolved
3a28241
to
729b807
Compare
729b807
to
55d38fd
Compare
55d38fd
to
bfbc64b
Compare
@ilayaperumalg @ThomasVitale - If you have some availability in the coming days, I'd appreciate it if you could take a look. |
Signed-off-by: Alexandros Pappas <[email protected]>
Signed-off-by: Alexandros Pappas <[email protected]>
bfbc64b
to
201edde
Compare
Signed-off-by: Alexandros Pappas <[email protected]>
resolves #2372 |
Thanks for your patience! |
rebaesd and merged. updated to ollama 0.6.7 as well. modified one test that was supposed to fail, but took a long time to exhause the retry, so disabled retry for that test. merged in cfbefee |
Other AutoConfiguration classes located under I suspect it might be using the previous directory path because the PR was created about 6 months ago, so I’m leaving a comment about it. |
looks like you are correct . |
I have created a PR to address the mentioned part. |
thank you for the pr @dev-jonghoonpark . it looks like we were working on this at the same time. did you tried to compile the code and run the tests?
the I did n't had the time yet to check if this class is still needed as i can see seperate auto configuration classes for api, model, embeddings, etc, like on the |
In PR #3645 , Currently, I am running the tests, so I have marked it PR a draft. I will reopen the PR once the tests are completed. |
Run a build and make sure all tests pass prior to submission