-
Notifications
You must be signed in to change notification settings - Fork 2
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 Example for Spring AI #114
base: master
Are you sure you want to change the base?
Conversation
Important Auto Review SkippedDraft detected. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the WalkthroughThis update enriches a Java-based AI project with Spring Boot, emphasizing AI interactions and historical data retrieval. It orchestrates the project environment, establishes dependencies for Spring AI and web development, and introduces classes for application execution and chat history management. Testing ensures the functionality of the application components, while configuration settings fine-tune the AI chat feature for an enhanced user experience. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (10)
- ai/.gitignore (1 hunks)
- ai/build.gradle (1 hunks)
- ai/settings.gradle (1 hunks)
- ai/src/main/java/zin/rashidi/boot/ai/AiApplication.java (1 hunks)
- ai/src/main/java/zin/rashidi/boot/ai/history/ChatHistoryRepository.java (1 hunks)
- ai/src/main/java/zin/rashidi/boot/ai/history/History.java (1 hunks)
- ai/src/main/java/zin/rashidi/boot/ai/history/HistoryRepository.java (1 hunks)
- ai/src/main/resources/application.properties (1 hunks)
- ai/src/test/java/zin/rashidi/boot/ai/AiApplicationTests.java (1 hunks)
- ai/src/test/java/zin/rashidi/boot/ai/history/HistoryRepositoryTests.java (1 hunks)
Files skipped from review due to trivial changes (3)
- ai/.gitignore
- ai/settings.gradle
- ai/src/main/java/zin/rashidi/boot/ai/AiApplication.java
Additional comments: 7
ai/src/main/java/zin/rashidi/boot/ai/history/History.java (1)
- 1-9: The
History
record is well-defined and follows Java best practices for immutable data structures. It's a concise way to encapsulate historical event data.ai/src/main/resources/application.properties (1)
- 1-4: The configuration for the Spring AI OpenAI chat options is correctly set up, with sensible defaults for the model, temperature, top-p, and response format. This setup is crucial for tailoring the AI's behavior and response format.
ai/src/main/java/zin/rashidi/boot/ai/history/HistoryRepository.java (1)
- 1-12: The
HistoryRepository
interface is well-designed, with a clear and focused responsibility. The methodfindByCountryAndYear
is appropriately named and usesjava.time.Year
, which is a good choice for handling years.ai/src/test/java/zin/rashidi/boot/ai/AiApplicationTests.java (1)
- 1-13: The
AiApplicationTests
class is correctly set up for Spring Boot testing, ensuring the application context loads successfully. This is a standard and essential test for Spring Boot applications.ai/build.gradle (1)
- 1-34: The
build.gradle
file is well-configured for a Spring Boot project, including the necessary plugins, repositories, and dependencies for Spring AI and OpenAI integration. However, consider verifying thesourceCompatibility
set to '21' with the development team to ensure compatibility with their environments.ai/src/test/java/zin/rashidi/boot/ai/history/HistoryRepositoryTests.java (1)
- 1-44: The
HistoryRepositoryTests
class provides thorough and well-structured tests for theHistoryRepository
functionality, using clear descriptions and appropriate assertions. These tests effectively validate the retrieval of historical information based on country and year.ai/src/main/java/zin/rashidi/boot/ai/history/ChatHistoryRepository.java (1)
- 1-60: The
ChatHistoryRepository
class is well-implemented, effectively using Spring AI'sChatClient
,EmbeddingClient
, and anObjectMapper
to process historical chat data. The approach to constructing messages and parsing the AI's response is innovative and well-crafted. However, consider adding error handling for the external calls to AI services to ensure robustness.
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- settings.gradle (1 hunks)
Additional comments: 1
settings.gradle (1)
- 17-17: The addition of the
ai
module to thesettings.gradle
file aligns with the PR's objectives to integrate AI capabilities into the Spring Boot application. Ensure that the module nameai
aligns with any existing project naming conventions and does not conflict with other modules in the project.
This commit introduces a whole new AI application along with a 'history' feature. The AI application includes necessary initial files including '.gitignore', 'build.gradle', 'settings.gradle', and 'application.properties'. The 'history' feature has an implementation through 'HistoryRepository', 'ChatHistoryRepository' and tests under 'HistoryRepositoryTests'.
Removed the EmbeddingClient from ChatHistoryRepository. This involved removing the EmbeddingClient field, its use in the constructor, and its use in creating a response. This change simplified the ChatHistoryRepository class by decoupling it from direct use of the EmbeddingClient.
New environment variable SPRING_AI_OPENAI_API_KEY is added in Github gradle workflow file to support running the Spring AI model. It is set with the same secret as LANGCHAIN4J_CHAT_MODEL_OPENAI_API_KEY for now.
The Spring Boot version in the build.gradle file has been updated from 3.2.2 to 3.2.3. This update keeps the build configuration synchronized with the latest stable version of the framework.
Quality Gate passedIssues Measures |
Summary by CodeRabbit