(
repo_path: Annotated[str, Argument(..., help="The path to the repository to set up.")],
repository_name: Annotated[str, Option("--repository-name", help="The name of the repository.", prompt=True)],
language: Annotated[Optional[str], Option(help="The programming language of the repository.", prompt=True)],
commit: Annotated[str, Option("--commit", help="The commit to set up.")] = "",
local_agent: Annotated[Optional[str], Option("--local-agent", help="local agent path")]=DEFAULT_LOCAL_AGENT,
devices: Annotated[Optional[str], Option("--devices", help="devices to use for inference")]=DEFAULT_DEVICES,
clone_dir: Annotated[Optional[str], Option("--clone-dir", help="The directory to clone the repository to.")]=DEFAULT_CLONE_DIR,
gh_token: Annotated[Optional[str], Option("--gh-token", help="The GitHub token to use for cloning private repositories.")]=DEFAULT_GH_TOKEN,
)
| 53 | |
| 54 | @setup_app.callback(invoke_without_command=True) |
| 55 | def setup( |
| 56 | repo_path: Annotated[str, Argument(..., help="The path to the repository to set up.")], |
| 57 | repository_name: Annotated[str, Option("--repository-name", help="The name of the repository.", prompt=True)], |
| 58 | language: Annotated[Optional[str], Option(help="The programming language of the repository.", prompt=True)], |
| 59 | commit: Annotated[str, Option("--commit", help="The commit to set up.")] = "", |
| 60 | local_agent: Annotated[Optional[str], Option("--local-agent", help="local agent path")]=DEFAULT_LOCAL_AGENT, |
| 61 | devices: Annotated[Optional[str], Option("--devices", help="devices to use for inference")]=DEFAULT_DEVICES, |
| 62 | clone_dir: Annotated[Optional[str], Option("--clone-dir", help="The directory to clone the repository to.")]=DEFAULT_CLONE_DIR, |
| 63 | gh_token: Annotated[Optional[str], Option("--gh-token", help="The GitHub token to use for cloning private repositories.")]=DEFAULT_GH_TOKEN, |
| 64 | ): |
| 65 | console.info("Setting up repo...") |
| 66 | is_local, repo_path = check_local_or_remote(repo_path) |
| 67 | repo_dir = clone_repo(repo_path, commit, clone_dir, gh_token, logger) if not is_local else repo_path |
| 68 | repo_dir = os.path.join(os.getcwd(), repo_dir) |
| 69 | console.info("Setting up LLM...") |
| 70 | if local_agent != "None": |
| 71 | def run_cmd(): |
| 72 | with open(os.devnull, 'w') as devnull: |
| 73 | env = os.environ.copy() |
| 74 | env["CUDA_VISIBLE_DEVICES"] = devices |
| 75 | subprocess.run(["python", "-m", |
| 76 | "vllm.entrypoints.openai.api_server", |
| 77 | "--model", str(DEFAULT_LOCAL_AGENT), |
| 78 | "--trust-remote-code", |
| 79 | "--tensor-parallel-size", str(len(devices.split(","))), |
| 80 | "--port", str(DEFAULT_VLLM_PORT)], |
| 81 | stdout=devnull, stderr=devnull, env=env) |
| 82 | thread = threading.Thread(target=run_cmd) |
| 83 | thread.daemon = True |
| 84 | thread.start() |
| 85 | |
| 86 | console.info("Setting up tools...") |
| 87 | tools = [] |
| 88 | for tool_class in tool_classes: |
| 89 | if tool_class == SemanticCodeSearchTool: |
| 90 | tools.append(tool_class(repo_dir, language=language, db_path=SEMANTIC_CODE_SEARCH_DB_PATH+repository_name, build=True)) |
| 91 | elif tool_class == CodeSearchTool: |
| 92 | tools.append(tool_class(repo_dir, language=language, index_path=ZOEKT_CODE_SEARCH_INDEX_PATH+repository_name, build=True)) |
| 93 | |
| 94 | necessary_infos = { |
| 95 | "repo_dir": repo_dir, |
| 96 | "local_agent": local_agent, |
| 97 | "language": language, |
| 98 | } |
| 99 | save_infos_to_folder(necessary_infos, repository_name, DEFAULT_WORKDIR_CLI) |
| 100 | console.info("Your repository is indexed!") |
| 101 | |
| 102 | @list_app.callback(invoke_without_command=True) |
| 103 | def list(): |
no test coverage detected