diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-07-16 16:25:02 -0700 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-07-16 16:25:02 -0700 |
commit | 4c3a25a1c8938f8132233e021c74d98eb19d7ddd (patch) | |
tree | 8460e5703f224e7ef5c2c7eca6b470f338b93e1e /extension/scripts/index.py | |
parent | 3ded151331933c9a1352cc46c3cc67c5733d1c86 (diff) | |
parent | a4a815628f702af806603015ec6805edd151328b (diff) | |
download | sncontinue-4c3a25a1c8938f8132233e021c74d98eb19d7ddd.tar.gz sncontinue-4c3a25a1c8938f8132233e021c74d98eb19d7ddd.tar.bz2 sncontinue-4c3a25a1c8938f8132233e021c74d98eb19d7ddd.zip |
Merge branch 'main' into ggml-server
Diffstat (limited to 'extension/scripts/index.py')
-rw-r--r-- | extension/scripts/index.py | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/extension/scripts/index.py b/extension/scripts/index.py deleted file mode 100644 index 3afc9131..00000000 --- a/extension/scripts/index.py +++ /dev/null @@ -1,52 +0,0 @@ -import sys -import os -from typing import TextIO -from chroma import update_collection, query_collection, create_collection, collection_exists, get_current_branch -from typer import Typer - -app = Typer() - -class SilenceStdoutContextManager: - saved_stdout: TextIO - - def __enter__(self): - self._original_stdout = sys.stdout - sys.stdout = open(os.devnull, 'w') - - def __exit__(self, exc_type, exc_val, exc_tb): - sys.stdout.close() - sys.stdout = self._original_stdout - -silence = SilenceStdoutContextManager() - -@app.command("exists") -def exists(cwd: str): - with silence: - exists = collection_exists(cwd) - print({"exists": exists}) - -@app.command("create") -def create(cwd: str): - with silence: - branch = get_current_branch(cwd) - create_collection(branch, cwd) - print({"success": True}) - -@app.command("update") -def update(cwd: str): - with silence: - update_collection(cwd) - print({"success": True}) - -@app.command("query") -def query(query: str, n_results: int, cwd: str): - with silence: - resp = query_collection(query, n_results, cwd) - results = [{ - "id": resp["ids"][0][i], - "document": resp["documents"][0][i] - } for i in range(len(resp["ids"][0]))] - print({"results": results}) - -if __name__ == "__main__": - app()
\ No newline at end of file |