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

feat : convert from openai to ollama model #24

Closed
wants to merge 8 commits into from

Conversation

rajadilipkolli
Copy link
Owner

@rajadilipkolli rajadilipkolli commented Mar 27, 2024

Summary by CodeRabbit

  • New Features

    • Updated the AI model for chat options to "llama2".
    • Introduced "llama2" as a new model for embedding options.
    • Added a new configuration property to support enhanced AI functionalities.
  • Tests

    • Enhanced testing capabilities with new imports and bean declaration for improved AI model testing.

Copy link
Contributor

coderabbitai bot commented Mar 27, 2024

Warning

Rate Limit Exceeded

@rajadilipkolli has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 31 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between e75393d and 2d8c0ac.

Walkthrough

The update transitions the AI model in a Spring application from "gpt-3.5-turbo" to "llama2" for chat and embedding functionalities. It also introduces a configuration for vector storage dimensionality. Additionally, the test environment is enhanced with an OllamaContainer bean to accommodate these changes.

Changes

File Path Change Summary
.../resources/application.properties Switched AI model to "llama2" for chat and embedding; Added spring.ai.vectorstore.pgvector.dimensions=4096.
.../test/.../TestLlmRagWithSpringAiApplication.java Added imports and OllamaContainer bean for test environment setup.

🐇✨
In a world of code and AI dreams,
A leap from GPT to LLaMA it seems.
With vectors wide and storage keen,
Spring blooms anew, in the machine.
🌼🖥️🐰

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?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@rajadilipkolli rajadilipkolli self-assigned this Mar 27, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 04d7894 and 4c09e19.
Files ignored due to path filters (1)
  • llm-rag-with-springai/pom.xml is excluded by: !**/*.xml
Files selected for processing (1)
  • llm-rag-with-springai/src/test/java/com/learning/ai/llmragwithspringai/TestLlmRagWithSpringAiApplication.java (2 hunks)
Additional comments: 2
llm-rag-with-springai/src/test/java/com/learning/ai/llmragwithspringai/TestLlmRagWithSpringAiApplication.java (2)
  • 3-3: The import of java.io.IOException is appropriate given the operations within the ollama bean method that can throw this exception.
  • 9-9: The addition of org.springframework.test.context.DynamicPropertyRegistry is crucial for dynamically configuring properties, which is used effectively in the ollama bean method.

Comment on lines 23 to 30
@Bean
OllamaContainer ollama(DynamicPropertyRegistry properties) throws UnsupportedOperationException, IOException, InterruptedException {
OllamaContainer ollama = new OllamaContainer("ollama/ollama");
ollama.start();
ollama.execInContainer("ollama", "pull", "mistral");
properties.add("spring.ai.ollama.base-url", ollama::getEndpoint);
return ollama;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ollama bean method is well-structured and follows good practices for initializing and configuring the OllamaContainer. However, there are a few points to consider for improvement:

  1. Exception Handling: The method declares it can throw UnsupportedOperationException, IOException, and InterruptedException. While IOException and InterruptedException are justified due to ollama.execInContainer and ollama.start(), UnsupportedOperationException is not explicitly thrown within the method. Ensure that this exception is necessary or remove it from the method signature if it's not.

  2. Hardcoded Values: The method contains hardcoded values such as the Docker image name "ollama/ollama" and the command parameters "ollama", "pull", "mistral". Consider externalizing these values to configuration properties or constants for easier maintenance and configuration.

  3. Error Handling: The method starts the container and executes a command within it but does not explicitly handle potential errors from these operations. Consider adding error handling or logging to improve resilience and debuggability.

- OllamaContainer ollama(DynamicPropertyRegistry properties) throws UnsupportedOperationException, IOException, InterruptedException {
+ OllamaContainer ollama(DynamicPropertyRegistry properties) throws IOException, InterruptedException {
  OllamaContainer ollama = new OllamaContainer("ollama/ollama");
  ollama.start();
  try {
      ollama.execInContainer("ollama", "pull", "mistral");
  } catch (Exception e) {
      // Handle or log the exception
      throw new RuntimeException("Failed to execute command in Ollama container", e);
  }
  properties.add("spring.ai.ollama.base-url", ollama::getEndpoint);
  return ollama;
}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
@Bean
OllamaContainer ollama(DynamicPropertyRegistry properties) throws UnsupportedOperationException, IOException, InterruptedException {
OllamaContainer ollama = new OllamaContainer("ollama/ollama");
ollama.start();
ollama.execInContainer("ollama", "pull", "mistral");
properties.add("spring.ai.ollama.base-url", ollama::getEndpoint);
return ollama;
}
@Bean
OllamaContainer ollama(DynamicPropertyRegistry properties) throws IOException, InterruptedException {
OllamaContainer ollama = new OllamaContainer("ollama/ollama");
ollama.start();
try {
ollama.execInContainer("ollama", "pull", "mistral");
} catch (Exception e) {
// Handle or log the exception
throw new RuntimeException("Failed to execute command in Ollama container", e);
}
properties.add("spring.ai.ollama.base-url", ollama::getEndpoint);
return ollama;
}

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 4c09e19 and 9d1ed61.
Files selected for processing (2)
  • llm-rag-with-springai/src/main/resources/application.properties (1 hunks)
  • llm-rag-with-springai/src/test/java/com/learning/ai/llmragwithspringai/TestLlmRagWithSpringAiApplication.java (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • llm-rag-with-springai/src/test/java/com/learning/ai/llmragwithspringai/TestLlmRagWithSpringAiApplication.java
Additional comments: 4
llm-rag-with-springai/src/main/resources/application.properties (4)
  • 5-6: The update from "gpt-3.5-turbo" to "llama2" for chat options and the setting of the response format to "json_object" align well with the PR's objective of transitioning to the Ollama model. This change should be reflected in the documentation and any relevant parts of the application that interact with the AI model to ensure seamless integration and usage.
  • 5-5: Ensure that the "llama2" model is compatible with all existing functionalities and that any necessary adjustments have been made to accommodate the new model's requirements or limitations. It might be beneficial to add comments or documentation specifying why "llama2" was chosen and any significant differences from "gpt-3.5-turbo" that could affect the application's behavior.
  • 6-6: Setting the response format to "json_object" is a good practice for ensuring structured and predictable responses from the AI model. Verify that the application's logic that processes these responses is updated accordingly to handle the "json_object" format efficiently.
  • 8-8: The commented-out configuration for the OpenAI image model (dall-e-3) suggests that image generation features might either be deprecated or transitioned to a different model. If this is an intentional deprecation, consider removing the line entirely to avoid confusion. If transitioning to a different model for image generation, ensure that the new model's configuration is added and documented appropriately.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 9d1ed61 and 493bf50.
Files selected for processing (1)
  • llm-rag-with-springai/src/main/resources/application.properties (1 hunks)
Additional comments: 3
llm-rag-with-springai/src/main/resources/application.properties (3)
  • 5-6: The update to use "llama2" for chat options and specifying the response format as json_object aligns well with the PR objectives and is a good practice for handling structured data.
  • 8-8: The change to "llama2" for embedding options is consistent with the transition to the Ollama model and is approved.
  • 10-10: The addition of spring.ai.vectorstore.pgvector.dimensions=1536 seems to be aligned with leveraging the Ollama model's capabilities. It's important to verify that 1536 matches the expected dimensions for embeddings as per the Ollama model's documentation.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 493bf50 and 788b538.
Files selected for processing (1)
  • llm-rag-with-springai/src/main/resources/application.properties (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • llm-rag-with-springai/src/main/resources/application.properties

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 788b538 and eb40dbf.
Files selected for processing (1)
  • llm-rag-with-springai/src/main/resources/application.properties (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • llm-rag-with-springai/src/main/resources/application.properties

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between eb40dbf and e75393d.
Files ignored due to path filters (1)
  • llm-rag-with-springai/pom.xml is excluded by !**/*.xml
Files selected for processing (2)
  • llm-rag-with-springai/src/main/resources/application.properties (1 hunks)
  • llm-rag-with-springai/src/test/java/com/learning/ai/llmragwithspringai/TestLlmRagWithSpringAiApplication.java (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • llm-rag-with-springai/src/main/resources/application.properties
  • llm-rag-with-springai/src/test/java/com/learning/ai/llmragwithspringai/TestLlmRagWithSpringAiApplication.java

@rajadilipkolli
Copy link
Owner Author

closing in favor of #26

@rajadilipkolli rajadilipkolli deleted the ollama-model branch March 28, 2024 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant