Skip to content

Github search tools

logger = logging.getLogger(__name__) module-attribute

FilterArgs

Bases: RepoArgs

Extend RepoArgs to add filter args common to many GitHub search tools.

chunk_type = Field(default=None, description=dedent(' Specific code type to search for. Generally not required.\n (note: can still be used with `text` query_embedding_type)')) class-attribute instance-attribute

file_path_end = Field(default=None, description="The end of the file path to filter by. (e.g. '.py', 'some_file.py', 'sub_dir/file.py')") class-attribute instance-attribute

file_path_start = Field(default=None, description="The start of the file path to filter by (from root of repo). (e.g. 'src/', 'src/main/')") class-attribute instance-attribute

language = Field(default=None, description='The file language to filter by. (e.g. `python`, `javascript`, `c`, etc., or `text`)') class-attribute instance-attribute

GithubNumPointsArgs

Bases: FilterArgs

Extend FilterArgs for getting the number of points that match the filter criteria (not via search).

GithubScrollArgs

Bases: FilterArgs

Extend FilterArgs for scrolling through vectorized points (not via search).

E.g., Get data on all points that match filter criteria (or first X starting from offset).

load_full_chunk_info = Field(default=True, description=dedent(' Whether to load additional metadata for results (e.g., line numbers, superclasses, import aliases, etc.). Adds a small overhead to search. Generally worth including unless specifically attempting to iterate through many results quickly.')) class-attribute instance-attribute

max_results = Field(default=10, description=dedent(" (default 10). The maximum number of results to return per request. (Only increase if previous requests don't\n return enough information in a single request, also note that scroll_from_id can be provided for pagination) ")) class-attribute instance-attribute

scroll_from_id = Field(default=None, description='(default None). The id of the last point returned from a previous scroll. Useful to get the next set of results.') class-attribute instance-attribute

GithubSearchArgs

Bases: FilterArgs

Extend FilterArgs for both the GithubSearchSpecificTool and the GithubSearchFilesTool.

load_full_chunk_info = Field(default=True, description=dedent(' Whether to load additional metadata for results (e.g., line numbers, superclasses, import aliases, etc.). Adds a small overhead to search. Generally worth including unless specifically attempting to iterate through many searches quickly.')) class-attribute instance-attribute

max_results = Field(default=5, description=dedent(' (default 5). The maximum number of results to return.\n (use best judgement on how many results are actually necessary)')) class-attribute instance-attribute

query_embedding_type = Field(default='text', description=dedent(' Whether the query should be embedded and searched as text or code. `code` should only be used for code snippets,\n and if the results are limited, searching again with `text` may yield more results.')) class-attribute instance-attribute

query_string = Field(description=dedent(' Text, code, or pseudo-code that will be embedded for similarity search. Either describe what is being searched for,\n or make a prediction of what the search result will look like. E.g. "search for a function that adds numbers" or\n "def add_numbers(a, b): return a + b".'), min_length=5, max_length=500) class-attribute instance-attribute

result_index_offset = Field(default=0, description=dedent(' (default 0). The index of the first result to return. Useful if repeating a search to get additional results. Set\n this to skip the first N results previously obtained.')) class-attribute instance-attribute

GithubSearchFilesTool

Bases: BaseTool

Tool wrapper around the github_search.search_file_results service.

args_schema = GithubSearchArgs class-attribute instance-attribute

description = 'Search for whole files within a repository that contain the most relevant code/text snippets to the query.' class-attribute instance-attribute

github_search_uow instance-attribute

name = ToolNames.GITHUB_SEARCH_FILES class-attribute instance-attribute

response_format = 'content_and_artifact' class-attribute instance-attribute

tags = Field(default=['github_search_specific']) class-attribute instance-attribute

GithubSearchNumPointsTool

Bases: BaseTool

args_schema = GithubNumPointsArgs class-attribute instance-attribute

description = 'Get the number of points that match the filter criteria. (Useful to use before scrolling to get an idea of how many results there are in total.)' class-attribute instance-attribute

github_search_uow instance-attribute

name = ToolNames.GITHUB_SEARCH_NUM_POINTS class-attribute instance-attribute

response_format = 'content_and_artifact' class-attribute instance-attribute

tags = Field(default=['github_search_num_points']) class-attribute instance-attribute

GithubSearchScrollTool

Bases: BaseTool

args_schema = GithubScrollArgs class-attribute instance-attribute

description = 'Scroll through all points that match the filter criteria (without a vector search). (Consider checking how many points match the filter criteria first.)' class-attribute instance-attribute

github_search_uow instance-attribute

name = ToolNames.GITHUB_SEARCH_SCROLL_POINTS class-attribute instance-attribute

response_format = 'content_and_artifact' class-attribute instance-attribute

tags = Field(default=['github_search_scroll_points']) class-attribute instance-attribute

GithubSearchSpecificTool

Bases: BaseTool

Tool wrapper around the github_search.search service.

args_schema = GithubSearchArgs class-attribute instance-attribute

description = 'Search for specific code/text snippets within a repository.' class-attribute instance-attribute

github_search_uow instance-attribute

name = ToolNames.GITHUB_SEARCH_SPECIFIC class-attribute instance-attribute

response_format = 'content_and_artifact' class-attribute instance-attribute

tags = Field(default=['github_search_specific']) class-attribute instance-attribute

GithubUpdateVectorsTool

Bases: BaseTool

args_schema = UpdateVectorsArgs class-attribute instance-attribute

description = 'Update the vectors for a repository. Only use if there is good reason to believe there are changes (E.g., New commits have been added to repository, or work on a new branch is requested). This is an expensive operation in both time and resources.' class-attribute instance-attribute

github_parsing_uow instance-attribute

github_search_uow instance-attribute

name = ToolNames.GITHUB_SEARCH_UPDATE_VECTORS class-attribute instance-attribute

response_format = 'content_and_artifact' class-attribute instance-attribute

tags = Field(default=['github_search_update_vectors']) class-attribute instance-attribute

RepoArgs

Bases: BaseModel

Args common to all GitHub search tools.

repo_branch = Field(default='main', description='The branch of the repository to search in. (e.g. `master`, `feature-x`)') class-attribute instance-attribute

repo_name = Field(description='The name of the repository to search in. (e.g. `reflex`)') class-attribute instance-attribute

repo_owner = Field(description='The owner (or organization) of the repository to search in. (e.g. `reflex-dev`)') class-attribute instance-attribute

user_id instance-attribute

UpdateVectorsArgs

Bases: RepoArgs

Extend RepoArgs for updating the vectors for a repository.

from_repo_id = Field(default=None, description='(default None). The repository to use as a starting point for updates. E.g., the `main` branch if generating vectors for a new branch. (None will use the current branch.)') class-attribute instance-attribute

max_content_size = Field(default=10000, description='The maximum size of content to include in vectorization. (default 10000 bytes, generally enough.)', gt=100, lt=100000) class-attribute instance-attribute