-
Notifications
You must be signed in to change notification settings - Fork 47
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
Add Spring Boot Project Starter for Google Gemini API model - ChatLangauge, Streaming model and Embedding Model #74
base: main
Are you sure you want to change the base?
Conversation
@langchain4j hey can you please have a look at 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.
@Suhas-Koheda thanks a lot!
.topP(chatModelProperties.getTopP()) | ||
.topK(chatModelProperties.getTopK()) | ||
.maxOutputTokens(chatModelProperties.getMaxOutputTokens()) | ||
.responseFormat(ResponseFormat.JSON) |
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.
why is it json?
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.
Hi. Related to your question. AutoConfig it's not injecting logging properties and json format from the properties -> https://docs.langchain4j.dev/tutorials/logging/ is not working when this AutoConfig is used. I will wait until this PR is merged to create a PR to avoid conflicts or If you want to add this configuration in this PR. Whatever you consider better.
Thank you!
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.
Hey! can you provide me with some references
As i did not find the logging used in other starters
Or maybe i overlooked
Thank you!
@franglopez
.topP(chatModelProperties.getTopP()) | ||
.topK(chatModelProperties.getTopK()) | ||
.maxOutputTokens(chatModelProperties.getMaxOutputTokens()) | ||
.responseFormat(ResponseFormat.JSON) |
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.
same here
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.
In the docs it was using JSON format itself
And also mostly in spring boot we will prefer to transfer data in the form of json right i did continue without thinking?
If not JSON then what's the format to be used?
And if you don't mind... why?
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.
Here we need to configure only those properties that users have defined themselves, so please avoid setting default values.
The most common format is TEXT
(String). JSON is used only for structured outputs, but there user has to explicitly specify the Java class.
...ain4j-google-ai-gemini/src/main/java/dev/langchain4j/googleaigemini/ChatModelProperties.java
Outdated
Show resolved
Hide resolved
.../src/test/java/dev/langchain4j/googleaigemini/Langchain4jGoogleAiGeminiApplicationTests.java
Outdated
Show resolved
Hide resolved
langchain4j-google-ai-gemini/src/main/resources/application.properties.local
Outdated
Show resolved
Hide resolved
@langchain4j also in the timeout values i had doubt At present i have hardcoded used 60 secs |
@Suhas-Koheda you can see how timeouts are handled in OpenAI starter here, the same for .logRequests(chatModelProperties.logRequests()). |
@Suhas-Koheda |
Yeah sure I'll take care of it! |
@ddobrin hey for the response format i have kept the type of prop as ResponseFormat only which is user defined - not a primitive type? |
…urces/application.properties
@langchain4j |
@Suhas-Koheda on a 📱 let me come back to it at the beginning of the week |
Hi @Suhas-Koheda
|
@Suhas-Koheda - if you find this useful, and to test the starter, before a merge, I have this sample on Langchain4J Function Calling with Google AI for Developers and Gemini models available, on 0.37 SNAPSHOT |
I'll look into it and make the suggested changes ! |
@ddobrin hey th egemini safe setting function safetySettings has Map<GeminiHarmCategory, GeminiHarmBlockThreshold> safetySettingMap as args so i will be taking the args as two different properties and will be passing into the function as args thank you! |
On mobile.
Could you please add to the IT class, in order to have full coverage of all configured parameters? |
@ddobrin i have written tests for the chat language model with updated properties and it runs! the inconsistency in code i was mentioning about one method has list args and the other has map args actually i have seen just now
for the builder method of GoogleAiGeminiChatModelBuilder has been written explicitly which was not written for the GoogleAiGeminiStreamingChatModelBuilder |
@langchain4j hey i have written tests for embedding model hope they are correct and suggest if any changes |
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.
@Suhas-Koheda thanks a lot!
...mini-spring-boot-starter/src/main/java/dev/langchain4j/googleaigemini/spring/AutoConfig.java
Outdated
Show resolved
Hide resolved
...ng-boot-starter/src/main/java/dev/langchain4j/googleaigemini/spring/ChatModelProperties.java
Outdated
Show resolved
Hide resolved
...ni-spring-boot-starter/src/test/java/dev/langchain4j/googleaigemini/spring/AutoConfigIT.java
Outdated
Show resolved
Hide resolved
...ni-spring-boot-starter/src/test/java/dev/langchain4j/googleaigemini/spring/AutoConfigIT.java
Outdated
Show resolved
Hide resolved
...ni-spring-boot-starter/src/test/java/dev/langchain4j/googleaigemini/spring/AutoConfigIT.java
Outdated
Show resolved
Hide resolved
...ni-spring-boot-starter/src/test/java/dev/langchain4j/googleaigemini/spring/AutoConfigIT.java
Outdated
Show resolved
Hide resolved
...ni-spring-boot-starter/src/test/java/dev/langchain4j/googleaigemini/spring/AutoConfigIT.java
Show resolved
Hide resolved
@langchain4j hey i have resolved the issues and also can you please check the issue with streaming chat model |
@Suhas-Koheda thank you! |
@langchain4j - yes, Friday. Task overload until then |
Hi @Suhas-Koheda Re: streaming chat model not having a builder for safety settings I have revisited streaming, as well as the Vertex AI Gemini model. While that is missing, rather than making the starter config different between chat and streaming chat, can I suggest that we add this small missing bit in the /langchain4j/langchain4j-google-ai-gemini module first, and the starter would then come after. What do you think? |
Yeah! Happy to hear that!
Yeah sure! It works! |
If you like to add it and send a PR, that would be great |
@ddobrin hey i have opened a pr for the above in the main repo and also i have chnaged the tests here also to support the same ! |
This pull request is related to the issue #2103 of langchain4j project