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: Use poetry run generate to generate embeddings for FastAPI #41

Merged
merged 1 commit into from
Apr 9, 2024

Conversation

thucpn
Copy link
Collaborator

@thucpn thucpn commented Apr 8, 2024

  • remove simple chat engine
  • always allow generate context data
  • add python script: poetry run generate

Summary by CodeRabbit

  • Refactor
    • Improved command readability and structure in data generation for the fastapi framework.
    • Enhanced code organization in Python chat engine and vector database generation scripts.
  • New Features
    • Standardized script execution process across various components and documentation.
  • Documentation
    • Updated README files for consistent script execution instructions.

Copy link

changeset-bot bot commented Apr 8, 2024

🦋 Changeset detected

Latest commit: b693118

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 streamline command execution and improve code organization across several components. By adopting poetry run generate for script execution and restructuring code to utilize a main() function for main code execution, the changes enhance readability, maintainability, and standardize the development process.

Changes

Files Summary
helpers/index.ts, helpers/typescript.ts Updated command execution for fastapi and modified conditional checks in updatePackageJson.
templates/components/engines/python/chat/__init__.py Changed command to poetry run generate for Python chat engine component.
templates/components/vectordbs/python/astra/generate.py, milvus/generate.py, mongo/generate.py, none/generate.py, pg/generate.py, pinecone/generate.py Moved main code execution to main() function for better structure.
templates/types/streaming/fastapi/README-template.md, pyproject.toml Standardized script execution with poetry run generate.
.changeset/four-tools-buy.md Introduces a change related to using poetry run generate to generate embeddings for FastAPI.

🐇✨
In the land of code and byte,
We hop through updates, day and night.
With poetry run, we set the stage,
For scripts to dance, from page to page.
In functions neat, our logic we tuck,
A leap towards clarity, with a dash of luck.
🌟🐾


Recent Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 753229d and b693118.
Files selected for processing (13)
  • .changeset/four-tools-buy.md (1 hunks)
  • README.md (1 hunks)
  • helpers/index.ts (2 hunks)
  • helpers/typescript.ts (1 hunks)
  • templates/components/engines/python/chat/init.py (1 hunks)
  • templates/components/vectordbs/python/astra/generate.py (2 hunks)
  • templates/components/vectordbs/python/milvus/generate.py (2 hunks)
  • templates/components/vectordbs/python/mongo/generate.py (2 hunks)
  • templates/components/vectordbs/python/none/generate.py (2 hunks)
  • templates/components/vectordbs/python/pg/generate.py (2 hunks)
  • templates/components/vectordbs/python/pinecone/generate.py (2 hunks)
  • templates/types/streaming/fastapi/README-template.md (2 hunks)
  • templates/types/streaming/fastapi/pyproject.toml (1 hunks)
Files skipped from review as they are similar to previous changes (4)
  • helpers/index.ts
  • helpers/typescript.ts
  • templates/components/engines/python/chat/init.py
  • templates/types/streaming/fastapi/pyproject.toml
Additional comments not posted (10)
.changeset/four-tools-buy.md (1)

5-5: The changeset description is clear and aligns with the PR's objective to standardize command execution. Good to go!

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

Line range hint 1-11: The structure of imports, including the early call to load_dotenv(), is appropriate given the need to set environment variables before other imports. Ensure any environment-dependent imports follow this pattern.

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

Line range hint 1-11: The structure of imports, including the early call to load_dotenv(), is appropriate given the need to set environment variables before other imports. Ensure any environment-dependent imports follow this pattern.

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

Line range hint 1-11: The structure of imports, including the early call to load_dotenv(), is appropriate given the need to set environment variables before other imports. Ensure any environment-dependent imports follow this pattern.

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

Line range hint 1-11: The structure of imports, including the early call to load_dotenv(), is appropriate given the need to set environment variables before other imports. Ensure any environment-dependent imports follow this pattern.

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

Line range hint 1-11: The structure of imports, including the early call to load_dotenv(), is appropriate given the need to set environment variables before other imports. Ensure any environment-dependent imports follow this pattern.

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

Line range hint 1-11: The structure of imports, including the early call to load_dotenv(), is appropriate given the need to set environment variables before other imports. Ensure any environment-dependent imports follow this pattern.

templates/types/streaming/fastapi/README-template.md (2)

27-27: Updating the command to poetry run generate in the README ensures consistency with the project setup and standardizes the approach for running the generation script. This is a positive change for usability and clarity.


87-87: The update to use poetry run generate for Docker commands is consistent with the project's standardization efforts. This change enhances clarity and consistency in the documentation.

README.md (1)

48-48: Simplify command execution for Python backend indexing.

This change aligns with the PR's objective to streamline context data generation by standardizing command execution across different components. It enhances readability and consistency in the documentation.

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 5331e02.
Files selected for processing (11)
  • helpers/index.ts (2 hunks)
  • helpers/typescript.ts (1 hunks)
  • templates/components/engines/python/chat/init.py (1 hunks)
  • templates/components/vectordbs/python/astra/generate.py (1 hunks)
  • templates/components/vectordbs/python/milvus/generate.py (1 hunks)
  • templates/components/vectordbs/python/mongo/generate.py (1 hunks)
  • templates/components/vectordbs/python/none/generate.py (1 hunks)
  • templates/components/vectordbs/python/pg/generate.py (1 hunks)
  • templates/components/vectordbs/python/pinecone/generate.py (1 hunks)
  • templates/types/streaming/fastapi/README-template.md (2 hunks)
  • templates/types/streaming/fastapi/pyproject.toml (1 hunks)
Additional comments not posted (10)
templates/components/engines/python/chat/__init__.py (1)

12-12: Update the command in the exception message to poetry run generate aligns with the PR's goal of standardizing script execution commands. This change enhances consistency and simplifies the command execution process across the project.

templates/types/streaming/fastapi/pyproject.toml (1)

8-10: Adding the generate script under tool.poetry.scripts is a positive change that standardizes script execution within the project. This addition makes it easier to manage and execute the script across different environments, aligning with the PR's goal of improving the generation of context data.

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

30-30: Moving the main execution logic to a main() function is a good practice that enhances the script's organization and readability. This change facilitates better code management and aligns with the PR's objective of improving code structure across the project.

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

35-35: Moving the main execution logic into a main() function improves the script's organization and readability. This restructuring aligns with the PR's goal of enhancing code management and readability across the project.

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

37-37: Moving the main execution logic into a main() function is a commendable change that enhances the script's organization and readability. This restructuring supports the PR's objective of improving code management and readability across the project.

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

41-41: Moving the main execution logic into a main() function is an effective way to improve the script's organization and readability. This change aligns with the PR's goal of enhancing code management and readability across the project.

templates/types/streaming/fastapi/README-template.md (2)

27-27: Standardizing the command execution to poetry run generate enhances consistency and simplifies the process. Good change.


87-87: Consistent use of poetry run generate within Docker commands aligns with the project's standardization efforts. Well done.

helpers/index.ts (1)

33-39: > 📝 NOTE

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

Simplifying the command for generating context data to poetry run generate for the fastapi framework enhances readability and consistency. The conditional logic used here is a good practice for maintainability.

helpers/typescript.ts (1)

203-203: Simplifying the condition for adding the generate script in packageJson could make the process more straightforward. Ensure that the new condition accurately reflects all scenarios where the script is needed.

@marcusschiesser marcusschiesser force-pushed the feat/always-generate-context-data branch from 5331e02 to 99bf33b Compare April 9, 2024 06:38
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 (3)
templates/components/vectordbs/python/none/generate.py (1)

Line range hint 1-11: Move module level imports to the top of the file to conform to PEP 8 guidelines.

+ from dotenv import load_dotenv
+ import logging
+ from llama_index.core.indices import VectorStoreIndex
+ from app.engine.constants import STORAGE_DIR
+ from app.engine.loaders import get_documents
+ from app.settings import init_settings

+ load_dotenv()
- from dotenv import load_dotenv
- load_dotenv()
templates/components/vectordbs/python/pg/generate.py (1)

Line range hint 1-11: Move module level imports to the top of the file to conform to PEP 8 guidelines.

+ from dotenv import load_dotenv
+ import logging
+ from llama_index.core.indices import VectorStoreIndex
+ from llama_index.core.storage import StorageContext
+ from app.engine.loaders import get_documents
+ from app.settings import init_settings
+ from app.engine.utils import init_pg_vector_store_from_env

+ load_dotenv()
- from dotenv import load_dotenv
- load_dotenv()
templates/components/vectordbs/python/astra/generate.py (1)

Line range hint 1-11: Move module level imports to the top of the file to conform to PEP 8 guidelines.

+ from dotenv import load_dotenv
+ import os
+ import logging
+ from llama_index.core.storage import StorageContext
+ from llama_index.core.indices import VectorStoreIndex
+ from llama_index.vector_stores.astra_db import AstraDBVectorStore
+ from app.settings import init_settings
+ from app.engine.loaders import get_documents

+ load_dotenv()
- from dotenv import load_dotenv
- load_dotenv()

@marcusschiesser marcusschiesser force-pushed the feat/always-generate-context-data branch from 99bf33b to b693118 Compare April 9, 2024 06:44
@marcusschiesser marcusschiesser changed the title feat: always generate context data feat: Use poetry run generate to generate embeddings for FastAPI Apr 9, 2024
@marcusschiesser marcusschiesser merged commit 6acccd2 into main Apr 9, 2024
5 checks passed
@marcusschiesser marcusschiesser deleted the feat/always-generate-context-data branch April 9, 2024 06:45
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 (2)
templates/components/vectordbs/python/astra/generate.py (1)

Line range hint 33-33: Remove the f-string as it does not contain any placeholders, simplifying the logging statement.

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

Line range hint 35-35: Remove the f-string as it does not contain any placeholders, simplifying the logging statement.

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

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.

3 participants