Skip to content

Conversation

@tanakachitsamba
Copy link
Owner

Summary

  • replace manual sys.argv parsing with argparse flags that accept JSON strings or file paths
  • validate and load CLI payloads as JSON before inserting into the Chroma collection
  • configure the OpenAI embedding function when retrieving the persistent collection and improve error handling

Testing

  • not run

https://chatgpt.com/codex/tasks/task_e_68e42c0e7a0c83288b60fe361a987144

Copilot AI review requested due to automatic review settings October 6, 2025 20:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR modernizes the CLI interface for adding documents to a Chroma collection by replacing manual argument parsing with argparse and adding comprehensive input validation. The changes improve error handling and ensure the embedding function is properly configured for the collection.

  • Replaced manual sys.argv parsing with argparse for better CLI handling
  • Added JSON validation and file input support for CLI arguments
  • Configured OpenAI embedding function when creating/retrieving the collection

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 28 to 95
def add_to_openai_collection(collection, documents, metadatas, ids):
"""Insert the provided payload into ``collection`` and report basic failures."""
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

This function lacks type hints while other functions in the file have been updated with proper typing. Add type annotations for consistency and better maintainability.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

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

@codex fix comments

Choose a reason for hiding this comment

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

Summary

  • Quoted the Chroma client and collection annotations so the module no longer dereferences unavailable chromadb internals at import time. add_documents.pyL38-L46
  • Added explicit typing to add_to_openai_collection inputs for consistency with the rest of the module. add_documents.pyL94-L110

Testing

  • ⚠️ No automated tests were run (not requested).

View task →

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

add_documents.py Outdated
Comment on lines 38 to 40
def create_or_get_collection(client: chromadb.ClientAPI,
embedding_function: embedding_functions.OpenAIEmbeddingFunction
) -> chromadb.api.models.Collection.Collection:

Choose a reason for hiding this comment

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

P1 Badge Guard type annotations that access chromadb internals

The new annotations in create_or_get_collection dereference chromadb.ClientAPI and chromadb.api.models.Collection.Collection at definition time. Because from __future__ import annotations is not used, these expressions are evaluated when the module is imported and the top-level chromadb package does not expose ClientAPI (and may not preload chromadb.api.models). Importing the CLI now raises AttributeError before any logic runs. Quote these annotations or import the specific types from chromadb.api so the script can execute.

Useful? React with 👍 / 👎.

Copy link
Owner Author

Choose a reason for hiding this comment

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

@codex fix comments

Choose a reason for hiding this comment

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

Summary

Testing

  • ⚠️ Not run (not requested).

View task →

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants