Skip to content
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

Mistral AI - Make Client configurable via ChatModel #1416

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ThomasVitale
Copy link
Contributor

Change

The MistralAiClient provides a convenient way to provide a custom implementation of the underlying HTTP interaction. Using the MistralAiClientBuilderFactory SPI, it's possible to specify a custom static Builder for a MistralAiClient.

Since an instance of MistralAiClient is built internally from that static builder when building a MistralChatClient object, it's not possible to provide further customizations. For example, it's not possible to include additional configuration parameters to MistralAiClient, even though the Builder SPI would actually allow that. It's also not possible to initialise the MistralAiClient instance via dependency injection, resulting in not being able to manage it properly from a Spring application context.

This PR aims at solving that problem by making it possible to provide a MistralAiClient instance when building a MistralChatClient object. The additional benefit is making it clearer what parameters are specific to the model integration (like model and temperature) and what are the ones specific to the HTTP client (like timeout and API key).

The change extends the current setup to avoid any breaking change. It also marks the previous way of configuring a Client deprecated.

General checklist

  • There are no breaking changes
  • I have added unit and integration tests for my change
  • I have manually run all the unit and integration tests in the module I have added/changed, and they are all green
  • I have manually run all the unit and integration tests in the core and main modules, and they are all green
  • I have added/updated the documentation
  • I have added an example in the examples repo (only for "big" features)
  • I have added/updated Spring Boot starter(s) (if applicable)

@geoand
Copy link
Contributor

geoand commented Jul 18, 2024

+1 for this

@langchain4j
Copy link
Owner

Hi @ThomasVitale, thank you for the PR!

And I am sorry for not commenting on this in time! Because this PR is a foundation for langchain4j/langchain4j-spring#32, and I had questions there regarding the approach (e.g. allignment with #1103), I was waiting for langchain4j/langchain4j-spring#32 to settle before going forward with this PR, because it affects end users (parameter deprecations and a new way of creating MistralAiChatModel), and I did not want to bother users with constantly changing API.

Please ping me once you'll have some time, I am happy to discuss!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 High priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants