8000 Rag cli refactor by cihankaradogan · Pull Request #193 · supercog-ai/agentic · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Rag cli refactor #193

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/interacting-with-agents/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
index delete - Delete an index
index search - Search in an index

index document add - Add a document to an index
index document list - List documents in an index
index document show - Show document details
index document delete - Delete a document from an index
index document add_doc - Add a document to an index
index document list_docs - List documents in an index
index document show_doc - Show document details
index document delete_doc - Delete a document from an index

## Model Operations

Expand Down
12 changes: 6 additions & 6 deletions docs/rag-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ You can manage vectorstore indexes using the CLI:
```sh

# Chunk a file, calculate chunk embeddings, and add them to the vectorstore
agentic index document add <index name> <file path>
agentic index document add_doc <index name> <file path>

# Remove all the chunks of a file from the vector store
agentic index document delete <index name> <file path|document ID>
agentic index document delete_doc <index name> <file path|document ID>

# list the indexes
agentic index list
Expand All @@ -22,10 +22,10 @@ agentic index rename <from name> <to name>
agentic index delete <index name>

# List the documents in a vector store
agentic index document list <index name>
agentic index document list_docs <index name>

# Show the metadata for a doc in the vector store
agentic index document show <index name> <file path|document ID>
agentic index document show_doc <index name> <file path|document ID>

# Perform a search of the vector store. Searches by vector by default, or can do hybrid search
agentic index search <index name> <query> [--hybrid]
Expand All @@ -36,9 +36,9 @@ Example usage:

```sh

$ agentic index document add index1 tests/data/agentic_reasoning.pdf
$ agentic index document add_doc index1 tests/data/agentic_reasoning.pdf

$ agentic index document list index1
$ agentic index document list_docs index1
Documents in 'index1' (3)
- agentic_reasoning.pdf
ID: 27c0600f... | Chunks: 19 | Last indexed: 2025-02-22 05:54:51+00:00
Expand Down
8 changes: 4 additions & 4 deletions src/agentic/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def index_search(
client.close()

# Index document commands
@index_document_app.command("add")
@index_document_app.command("add_doc")
def document_add(
index_name: str,
file_path: str,
Expand Down Expand Up @@ -571,7 +571,7 @@ def document_add(
console.print(f"[bold red]Error: {str(e)}")
raise typer.Exit(1)

@index_document_app.command("list")
@index_document_app.command("list_docs")
def document_list(index_name: str):
"""List all documents in an index with basic info"""
from agentic.utils.rag_helper import (
Expand Down Expand Up @@ -602,7 +602,7 @@ def document_list(index_name: str):
if client:
client.close()

@index_document_app.command("show")
@index_document_app.command("show_doc")
def document_show(index_name: str, document_identifier: str):
"""Show detailed metadata for a specific document using its ID or filename/path"""
from agentic.utils.rag_helper import (
Expand Down Expand Up @@ -648,7 +648,7 @@ def document_show(index_name: str, document_identifier: str):
if client:
client.close()

@index_document_app.command("delete")
@index_document_app.command("delete_doc")
def document_delete(
index_name: str,
document_identifier: str, # Changed from file_path to accept both
Expand Down
14 changes: 7 additions & 7 deletions tests/cli/test_cli_index_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_document_add(mock_weaviate_client, tmp_path):
with patch('agentic.utils.rag_helper.rag_index_file') as mock_index:
result = runner.invoke(
app,
['index', 'document', 'add', 'test_index', str(test_file)]
['index', 'document', 'add_doc', 'test_index', str(test_file)]
)

assert result.exit_code == 0
Expand All @@ -63,7 +63,7 @@ def test_document_list(mock_weaviate_client, mock_collection):
)
]

result = runner.invoke(app, ['index', 'document', 'list', 'test_index'])
result = runner.invoke(app, ['index', 'document', 'list_docs', 'test_index'])

assert result.exit_code == 0
assert 'test.txt' in result.stdout
Expand All @@ -90,7 +90,7 @@ def test_document_show(mock_weaviate_client, mock_collection):

result = runner.invoke(
app,
['index', 'document', 'show', 'test_index', document_id]
['index', 'document', 'show_doc', 'test_index', document_id]
)

assert result.exit_code == 0
Expand All @@ -110,7 +110,7 @@ def test_document_delete(mock_weaviate_client, mock_collection):
# Test with --yes flag to skip confirmation
result = runner.invoke(
app,
['index', 'document', 'delete', 'test_index', 'doc123', '--yes']
['index', 'document', 'delete_doc', 'test_index', 'doc123', '--yes']
)

assert result.exit_code == 0
Expand All @@ -124,7 +124,7 @@ def test_document_delete_nonexistent(mock_weaviate_client, mock_collection):

result = runner.invoke(
app,
['index', 'document', 'delete', 'test_index', 'nonexistent', '--yes']
['index', 'document', 'delete_doc', 'test_index', 'nonexistent', '--yes']
)

assert result.exit_code == 0
Expand All @@ -133,7 +133,7 @@ def test_document_delete_nonexistent(mock_weaviate_client, mock_collection):
def test_document_add_invalid_file(mock_weaviate_client):
result = runner.invoke(
app,
['index', 'document', 'add', 'test_index', 'nonexistent.txt']
['index', 'document', 'add_doc', 'test_index', 'nonexistent.txt']
)

assert result.exit_code == 1
Expand All @@ -142,7 +142,7 @@ def test_document_add_invalid_file(mock_weaviate_client):
def test_document_list_nonexistent_index(mock_weaviate_client):
mock_weaviate_client.collections.exists.return_value = False

result = runner.invoke(app, ['index', 'document', 'list', 'nonexistent'])
result = runner.invoke(app, ['index', 'document', 'list_docs', 'nonexistent'])

assert result.exit_code == 0
assert 'does not exist' in result.stdout
0