Skip to content

chore: bump llama_index version for fastapi template #156

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

Merged
merged 1 commit into from
Jul 5, 2024

Conversation

leehuwuj
Copy link
Collaborator

@leehuwuj leehuwuj commented Jul 5, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new LlamaCloud Index functionality, allowing users to configure and use LlamaCloud for indexing based on environment variables.
  • Improvements

    • Updated llama-index and llama-index-core dependencies to versions 0.10.52 and 0.10.52.post1, respectively, improving compatibility and performance.
  • Configuration

    • Added new environment variables for LlamaCloud configuration.
    • Enhanced logging and error handling for LlamaCloud connections.

Copy link

changeset-bot bot commented Jul 5, 2024

⚠️ No Changeset found

Latest commit: 2ddb481

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@leehuwuj leehuwuj requested a review from marcusschiesser July 5, 2024 08:43
Copy link

coderabbitai bot commented Jul 5, 2024

Walkthrough

The recent changes introduce a support feature for LlamaCloud indexes within the FastAPI application. This includes the addition of a get_llama_cloud_index() function and an update to the existing get_index() function to handle LlamaCloud configurations. Furthermore, the pyproject.toml file has been updated to include newer versions of llama-index and llama-index-core dependencies.

Changes

Files Change Summary
templates/components/vectordbs/python/none/index.py Added get_llama_cloud_index() function and modified get_index() to conditionally use LlamaCloud index.
templates/types/streaming/fastapi/app/engine/index.py Similar updates as above for LlamaCloud index handling and related configurations, logging, and error checking.
templates/types/streaming/fastapi/pyproject.toml Updated llama-index and llama-index-core dependencies to versions 0.10.52 and 0.10.52.post1, respectively.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FastAPI
    participant LlamaCloudIndex
    participant VectorStore

    User->>FastAPI: Request to get an index
    FastAPI->>FastAPI: Check USE_LLAMA_CLOUD variable
    alt LlamaCloud enabled
        FastAPI->>LlamaCloudIndex: Create LlamaCloud index using get_llama_cloud_index()
        LlamaCloudIndex-->>FastAPI: LlamaCloud index instance
    else LlamaCloud disabled
        FastAPI->>VectorStore: Create VectorStore index
        VectorStore -->> FastAPI: VectorStore index instance
    end
    FastAPI-->>User: Return index instance
Loading

Poem

In the realm of code with APIs,
A LlamaCloud index now flies high,
Configurations set with care,
New versions bring flair,
FastAPI and LlamaCloud, reaching new skies. 🌤️🦙


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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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

Outside diff range and nitpick comments (4)
templates/types/streaming/fastapi/app/engine/index.py (2)

11-21: Improve configuration management and error message clarity.

Consider using a configuration management library like pydantic or dynaconf for handling environment variables. This can provide better validation and default value management. Also, clarify the error message to guide the user on how to set the environment variables.

# Consider using pydantic for configuration management
from pydantic import BaseSettings

class Settings(BaseSettings):
    llama_cloud_index_name: str
    llama_cloud_project_name: str
    llama_cloud_api_key: str
    llama_cloud_base_url: str = None

    class Config:
        env_prefix = 'LLAMA_CLOUD_'

settings = Settings()

# Use settings in the function
def get_llama_cloud_index():
    if not settings.llama_cloud_index_name or not settings.llama_cloud_project_name or not settings.llama_cloud_api_key:
        raise ValueError(
            "LLAMA_CLOUD_INDEX_NAME, LLAMA_CLOUD_PROJECT_NAME, and LLAMA_CLOUD_API_KEY are required environment variables."
        )

    index = LlamaCloudIndex(
        name=settings.llama_cloud_index_name,
        project_name=settings.llama_cloud_project_name,
        api_key=settings.llama_cloud_api_key,
        base_url=settings.llama_cloud_base_url,
    )
    return index

32-45: Improve configuration management.

Consider using a configuration management library like pydantic or dynaconf for handling environment variables. This can provide better validation and default value management.

# Use settings in the function
def get_index():
    use_llama_cloud = settings.use_llama_cloud.lower() == "true"
    if use_llama_cloud:
        logger.info("Connecting to LlamaCloud...")
        return get_llama_cloud_index()
    else:
        logger.info("Connecting vector store...")
        store = get_vector_store()
        index = VectorStoreIndex.from_vector_store(store)
        logger.info("Finished load index from vector store.")
        return index
templates/components/vectordbs/python/none/index.py (2)

13-23: Improve configuration management and error message clarity.

Consider using a configuration management library like pydantic or dynaconf for handling environment variables. This can provide better validation and default value management. Also, clarify the error message to guide the user on how to set the environment variables.

# Consider using pydantic for configuration management
from pydantic import BaseSettings

class Settings(BaseSettings):
    llama_cloud_index_name: str
    llama_cloud_project_name: str
    llama_cloud_api_key: str
    llama_cloud_base_url: str = None

    class Config:
        env_prefix = 'LLAMA_CLOUD_'

settings = Settings()

# Use settings in the function
def get_llama_cloud_index():
    if not settings.llama_cloud_index_name or not settings.llama_cloud_project_name or not settings.llama_cloud_api_key:
        raise ValueError(
            "LLAMA_CLOUD_INDEX_NAME, LLAMA_CLOUD_PROJECT_NAME, and LLAMA_CLOUD_API_KEY are required environment variables."
        )

    index = LlamaCloudIndex(
        name=settings.llama_cloud_index_name,
        project_name=settings.llama_cloud_project_name,
        api_key=settings.llama_cloud_api_key,
        base_url=settings.llama_cloud_base_url,
    )
    return index

43-47: Improve configuration management.

Consider using a configuration management library like pydantic or dynaconf for handling environment variables. This can provide better validation and default value management.

# Use settings in the function
def get_index():
    use_llama_cloud = settings.use_llama_cloud.lower() == "true"
    if use_llama_cloud:
        logger.info("Connecting to LlamaCloud...")
        return get_llama_cloud_index()
    else:
        storage_dir = settings.storage_dir
        # check if storage already exists
        if not os.path.exists(storage_dir):
            return None
        # load the existing index
        logger.info(f"Loading index from {storage_dir}...")
        storage_context = get_storage_context(storage_dir)
        index = load_index_from_storage(storage_context)
        logger.info(f"Finished loading index from {storage_dir}")
        return index
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 07fcefd and bedb36c.

Files selected for processing (3)
  • templates/components/vectordbs/python/none/index.py (2 hunks)
  • templates/types/streaming/fastapi/app/engine/index.py (1 hunks)
  • templates/types/streaming/fastapi/pyproject.toml (1 hunks)
Files skipped from review due to trivial changes (1)
  • templates/types/streaming/fastapi/pyproject.toml

@leehuwuj leehuwuj changed the title chore: bump llama_index version and add using llama_cloud index chore: bump llama_index version for fastapi template Jul 5, 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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bedb36c and 2ddb481.

Files selected for processing (1)
  • templates/types/streaming/fastapi/pyproject.toml (1 hunks)
Files skipped from review due to trivial changes (1)
  • templates/types/streaming/fastapi/pyproject.toml

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