diff options
| author | Nate Sesti <33237525+sestinj@users.noreply.github.com> | 2023-07-10 23:36:46 -0700 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-10 23:36:46 -0700 | 
| commit | 3f9e7a1fa59c4f684aef544436062f8825d77b31 (patch) | |
| tree | f8429e4b4898188e2490d7241043f4d61ed1d909 /extension/scripts/query.py | |
| parent | 1f050f737f7fa426bc4e3340abee7753095e792e (diff) | |
| parent | efa4c87a31bc5f35fff30bf3642681713834a58a (diff) | |
| download | sncontinue-3f9e7a1fa59c4f684aef544436062f8825d77b31.tar.gz sncontinue-3f9e7a1fa59c4f684aef544436062f8825d77b31.tar.bz2 sncontinue-3f9e7a1fa59c4f684aef544436062f8825d77b31.zip | |
Merge pull request #233 from continuedev/faster-load
Faster load
Diffstat (limited to 'extension/scripts/query.py')
| -rw-r--r-- | extension/scripts/query.py | 63 | 
1 files changed, 0 insertions, 63 deletions
| diff --git a/extension/scripts/query.py b/extension/scripts/query.py deleted file mode 100644 index f2e44413..00000000 --- a/extension/scripts/query.py +++ /dev/null @@ -1,63 +0,0 @@ -import subprocess -import sys -from gpt_index import GPTSimpleVectorIndex, GPTFaissIndex -import os -from typer import Typer -from enum import Enum -from update import update_codebase_index, create_codebase_index, index_dir_for, get_current_branch -from replace import replace_additional_index - -app = Typer() - -def query_codebase_index(query: str) -> str: -    """Query the codebase index.""" -    branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).decode("utf-8").strip() -    path = 'data/{branch}/index.json' -    if not os.path.exists(path): -        print("No index found for the codebase") -        return "" -    index = GPTFaissIndex.load_from_disk(path) -    return index.query(query) - -def query_additional_index(query: str) -> str: -    """Query the additional index.""" -    index = GPTSimpleVectorIndex.load_from_disk('data/additional_index.json') -    return index.query(query) - -class IndexTypeOption(str, Enum): -    codebase = "codebase" -    additional = "additional" - -@app.command() -def query(context: IndexTypeOption, query: str): -    if context == IndexTypeOption.additional: -        response = query_additional_index(query) -    elif context == IndexTypeOption.codebase: -        response = query_codebase_index(query) -    else: -        print("Error: unknown context") -    print({ "response": response }) - -@app.command() -def check_index_exists(root_path: str): -    branch = get_current_branch() -    exists = os.path.exists(index_dir_for(branch)) -    print({ "exists": exists }) - -@app.command() -def update(): -    update_codebase_index() -    print("Updated codebase index") - -@app.command() -def create_index(path: str): -    create_codebase_index() -    print("Created file index") - -@app.command() -def replace_additional_index(info: str): -    replace_additional_index() -    print("Replaced additional index") - -if __name__ == '__main__': -    app()
\ No newline at end of file | 
