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: optionally ask to select AI models and use default models #40

Merged
merged 7 commits into from
Apr 9, 2024

Conversation

thucpn
Copy link
Collaborator

@thucpn thucpn commented Apr 8, 2024

Summary by CodeRabbit

  • New Features
    • Introduced an option to select Language Learning Models (LLMs) and embedding models through the CLI with --ask-models.
    • Added support for customizing embedding models and their dimensions via environment variables.
  • Enhancements
    • Improved the user selection process for embedding models with a new toggle prompt.
  • Refactor
    • Updated various components to dynamically use embedding dimensions from environment variables, enhancing flexibility and customization.

@thucpn thucpn requested a review from marcusschiesser April 8, 2024 09:14
Copy link

changeset-bot bot commented Apr 8, 2024

🦋 Changeset detected

Latest commit: cc52db7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-llama Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

coderabbitai bot commented Apr 8, 2024

Walkthrough

The recent updates focus on enhancing the flexibility and customization of embedding models across the application. By introducing environment variables for embedding model selection (EMBEDDING_MODEL) and dimension (EMBEDDING_DIM), the changes allow dynamic configuration based on user input or predefined options. This includes adjustments in CLI options, backend settings, and vector database components to support varying embedding dimensions and model types, streamlining the integration of different embedding models within the system.

Changes

Files Change Summary
helpers/env-variables.ts Added EMBEDDING_MODEL and EMBEDDING_DIM to createBackendEnvFile function.
questions.ts Modified embeddingModel logic with a toggle prompt and updated model selection conditions.
templates/.../express/src/controllers/engine/settings.ts, templates/.../nextjs/app/api/chat/engine/settings.ts Imported OpenAIEmbedding and initialized Settings.embedModel with EMBEDDING_MODEL.
index.ts Enabled model selection via --ask-models CLI option, setting program.askModels to true.
templates/components/vectordbs/.../astra/generate.py, templates/components/vectordbs/.../astra/index.py, templates/components/vectordbs/.../milvus/generate.py, templates/components/vectordbs/.../milvus/index.py, templates/components/vectordbs/.../astra/generate.ts, templates/components/vectordbs/.../astra/shared.ts Altered to dynamically set embedding_dimension or dim from EMBEDDING_DIM environment variable.

🐰✨
In a world of code and binary streams,
A rabbit hopped, chasing its dreams.
With variables set and models aligned,
It crafted a space, uniquely designed.
🌟📐 To dimensions it leaped, with ease and vim,
Celebrating the changes, on a whim!
🥕💻 "To flexibility and beyond!" it cheered,
As into the digital sunset, it veered.
✨🐰


Recent Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 37a552c and cc52db7.
Files selected for processing (12)
  • README.md (3 hunks)
  • helpers/env-variables.ts (4 hunks)
  • index.ts (4 hunks)
  • questions.ts (8 hunks)
  • templates/components/vectordbs/python/astra/generate.py (1 hunks)
  • templates/components/vectordbs/python/astra/index.py (1 hunks)
  • templates/components/vectordbs/python/milvus/generate.py (1 hunks)
  • templates/components/vectordbs/python/milvus/index.py (1 hunks)
  • templates/components/vectordbs/typescript/astra/generate.ts (1 hunks)
  • templates/components/vectordbs/typescript/astra/shared.ts (1 hunks)
  • templates/types/streaming/express/src/controllers/engine/settings.ts (2 hunks)
  • templates/types/streaming/nextjs/app/api/chat/engine/settings.ts (2 hunks)
Files skipped from review as they are similar to previous changes (5)
  • helpers/env-variables.ts
  • index.ts
  • questions.ts
  • templates/types/streaming/express/src/controllers/engine/settings.ts
  • templates/types/streaming/nextjs/app/api/chat/engine/settings.ts
Additional comments not posted (7)
templates/components/vectordbs/typescript/astra/shared.ts (1)

5-5: Ensure EMBEDDING_DIM is documented and validated as a positive integer.

templates/components/vectordbs/python/milvus/index.py (1)

18-18: Validate EMBEDDING_DIM as a positive integer and handle conversion errors.

templates/components/vectordbs/python/astra/index.py (1)

17-17: Validate EMBEDDING_DIM as a positive integer and handle conversion errors.

templates/components/vectordbs/python/astra/generate.py (1)

24-24: Validate EMBEDDING_DIM as a positive integer and handle conversion errors.

templates/components/vectordbs/python/milvus/generate.py (1)

26-26: Validate EMBEDDING_DIM as a positive integer and handle conversion errors.

templates/components/vectordbs/typescript/astra/generate.ts (1)

22-25: Ensure EMBEDDING_DIM is validated as a positive integer before use.

README.md (1)

40-67: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [21-99]

Review and correct minor grammatical issues for clarity and professionalism.

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 testing code 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 testing code 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 testing code.
    • @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.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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.

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 9efcffe and 36f2880.
Files selected for processing (4)
  • helpers/env-variables.ts (2 hunks)
  • questions.ts (1 hunks)
  • templates/types/streaming/express/src/controllers/engine/settings.ts (2 hunks)
  • templates/types/streaming/nextjs/app/api/chat/engine/settings.ts (2 hunks)
Additional comments not posted (6)
templates/types/streaming/express/src/controllers/engine/settings.ts (3)

1-1: The import of OpenAIEmbedding is correctly implemented.


5-5: The declaration of EMBEDDING_MODEL using environment variables is correctly implemented.


14-16: The initialization of Settings.embedModel with OpenAIEmbedding is correctly implemented, aligning with the PR objectives.

templates/types/streaming/nextjs/app/api/chat/engine/settings.ts (3)

1-1: The import of OpenAIEmbedding is correctly implemented.


5-5: The declaration of EMBEDDING_MODEL using environment variables is correctly implemented.


14-16: The initialization of Settings.embedModel with OpenAIEmbedding is correctly implemented, aligning with the PR objectives.

questions.ts Outdated Show resolved Hide resolved
Copy link

@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.

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 36f2880 and 3ec70ee.
Files selected for processing (2)
  • index.ts (2 hunks)
  • questions.ts (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • questions.ts
Additional comments not posted (2)
index.ts (2)

180-185: The addition of the --use-embed-model CLI option is correctly implemented and follows the established pattern for adding new options in Commander. The description is clear and aligns with the PR objectives.


201-203: The handling of the --use-embed-model option, setting program.useEmbedModel to true when present, is correctly implemented. Ensure to verify how program.useEmbedModel is utilized throughout the application to fully understand its impact.

Verification successful

The usage of the --use-embed-model option and its corresponding program.useEmbedModel flag within the application, as seen in the index.ts and questions.ts files, is correctly implemented and integrated. The conditional logic in questions.ts that depends on this flag is consistent with an optional feature toggle, taking into account the execution environment (CI systems). This confirms the appropriate handling and integration of the --use-embed-model option within the application's logic.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the usage of `program.useEmbedModel` throughout the application.
rg --type ts "useEmbedModel"

Length of output: 171

@thucpn thucpn requested a review from marcusschiesser April 8, 2024 12:13
Copy link

@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.

Actionable comments posted: 1

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3ec70ee and 0e3e1fc.
Files selected for processing (1)
  • .changeset/curvy-eels-boil.md (1 hunks)

.changeset/curvy-eels-boil.md Outdated Show resolved Hide resolved
Copy link

@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.

Actionable comments posted: 1

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 0e3e1fc and 74504fa.
Files selected for processing (3)
  • .changeset/curvy-eels-boil.md (1 hunks)
  • index.ts (2 hunks)
  • questions.ts (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • index.ts
  • questions.ts
Additional comments not posted (1)
.changeset/curvy-eels-boil.md (1)

5-5: The CLI parameter name seems to have changed from --use-embed-model to --change-embed-model. Please confirm this change is intentional and correctly documented across all relevant parts of the application.

.changeset/curvy-eels-boil.md Outdated Show resolved Hide resolved
@marcusschiesser marcusschiesser force-pushed the feat/ask-to-use-embedding-model branch from 74504fa to 37a552c Compare April 9, 2024 04:04
Copy link

@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.

Actionable comments posted: 1

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 0e3e1fc and 37a552c.
Files selected for processing (6)
  • .changeset/curvy-eels-boil.md (1 hunks)
  • e2e/utils.ts (2 hunks)
  • index.ts (2 hunks)
  • questions.ts (4 hunks)
  • templates/types/streaming/express/src/controllers/engine/settings.ts (2 hunks)
  • templates/types/streaming/nextjs/app/api/chat/engine/settings.ts (2 hunks)
Files skipped from review as they are similar to previous changes (4)
  • index.ts
  • questions.ts
  • templates/types/streaming/express/src/controllers/engine/settings.ts
  • templates/types/streaming/nextjs/app/api/chat/engine/settings.ts
Additional comments not posted (1)
e2e/utils.ts (1)

12-18: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-62]

The changes in e2e/utils.ts align with the PR objectives to simplify model configuration by removing specific constants and their usage. Ensure that the removal of MODEL and EMBEDDING_MODEL constants and their related logic does not impact other parts of the test suite or the application's functionality.

.changeset/curvy-eels-boil.md Show resolved Hide resolved
@marcusschiesser marcusschiesser changed the title feat: ask to use embedding model feat: optionally ask to select AI models and use default models Apr 9, 2024
Copy link

@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.

Actionable comments posted: 0

Actionable comments outside the diff hunks (4)
templates/components/vectordbs/python/astra/generate.py (2)

Line range hint 5-11: Reorder imports to follow PEP 8 guidelines.

+ import os
+ import logging
from dotenv import load_dotenv
- import os
- import logging

Line range hint 32-32: Remove unnecessary f-string.

- logger.info(f"Successfully created embeddings in the AstraDB")
+ logger.info("Successfully created embeddings in the AstraDB")
templates/components/vectordbs/python/milvus/generate.py (2)

Line range hint 5-11: Reorder imports to follow PEP 8 guidelines.

+ import os
+ import logging
from dotenv import load_dotenv
- import os
- import logging

Line range hint 34-34: Remove unnecessary f-string.

- logger.info(f"Successfully created embeddings in the Milvus")
+ logger.info("Successfully created embeddings in the Milvus")

@marcusschiesser marcusschiesser merged commit 753229d into main Apr 9, 2024
5 checks passed
@marcusschiesser marcusschiesser deleted the feat/ask-to-use-embedding-model branch April 9, 2024 06:25
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.

2 participants