Github Search 도구
Github Search 도구 (GithubSearchTool)
CrewAI의 GithubSearchTool은 GitHub 저장소 안에서 시맨틱 검색(의미 기반 검색)을 수행하도록 특별히 설계된 RAG(Retrieval-Augmented Generation) 도구예요. 고급 시맨틱 검색 기능으로 코드, pull request, 이슈, 저장소를 훑어볼 수 있어서, GitHub에서 정확한 정보가 필요한 개발자·리서처·모든 사람에게 필수적인 도구랍니다.
출처: 문서
본문
GithubSearchTool은 GitHub 저장소 내에서 시맨틱 검색을 수행하도록 특별히 설계된 RAG(Retrieval-Augmented Generation) 도구입니다. 고급 시맨틱 검색 기능을 활용해 코드, pull request, 이슈, 저장소를 훑어보므로, GitHub에서 정확한 정보가 필요한 개발자·리서처·모든 사람에게 필수적인 도구예요.
참고: 아직 도구 개선 작업이 진행 중이라, 예상치 못한 동작이나 향후 변경이 있을 수 있어요.
설치 (Installation)
GithubSearchTool을 사용하려면 먼저 Python 환경에 crewai_tools 패키지가 설치되어 있는지 확인하세요.
pip install 'crewai[tools]'
이 명령은 crewai_tools 패키지에 포함된 다른 도구와 함께 GithubSearchTool을 실행하는 데 필요한 패키지를 설치합니다.
GitHub Personal Access Token은 https://github.com/settings/tokens (Developer settings → Fine-grained tokens 또는 classic tokens)에서 받으세요.
예시 (Example)
GithubSearchTool을 사용해 GitHub 저장소 안에서 시맨틱 검색을 수행하는 방법은 다음과 같습니다.
from crewai_tools import GithubSearchTool
# 특정 GitHub 저장소 안에서 시맨틱 검색하도록 도구 초기화
tool = GithubSearchTool(
github_repo='https://github.com/example/repo',
gh_token='your_github_personal_access_token',
content_types=['code', 'issue'] # Options: code, repo, pr, issue
)
# OR
# 특정 GitHub 저장소로 초기화 (에이전트가 실행 중 학습하면 어떤 저장소든 검색 가능)
tool = GithubSearchTool(
gh_token='your_github_personal_access_token',
content_types=['code', 'issue'] # Options: code, repo, pr, issue
)
인자 (Arguments)
github_repo: 검색을 수행할 GitHub 저장소의 URL이에요. 필수 필드이며 검색 대상 저장소를 지정합니다.gh_token: 인증에 필요한 GitHub Personal Access Token(PAT)이에요. GitHub 계정 설정의 Developer Settings > Personal Access Tokens에서 만들 수 있습니다.content_types: 검색에 포함할 콘텐츠 유형을 지정해요. 다음 옵션 중에서 리스트로 제공해야 합니다:code(코드 안에서 검색),repo(저장소 일반 정보 안에서 검색),pr(pull request 안에서 검색),issue(이슈 안에서 검색). 필수 필드이며, GitHub 저장소 안에서 특정 콘텐츠 유형으로 검색을 맞춤화할 수 있게 해줍니다.
커스텀 모델과 임베딩 (Custom model and embeddings)
기본적으로 이 도구는 임베딩과 요약 모두에 OpenAI를 사용해요. 모델을 커스터마이즈하려면 다음과 같이 config 딕셔너리를 사용하면 됩니다.
tool = GithubSearchTool(
config=dict(
llm=dict(
provider="ollama", # or google, openai, anthropic, llama2, ...
config=dict(
model="llama2",
# temperature=0.5,
# top_p=1,
# stream=true,
),
),
embedder=dict(
provider="google-generativeai", # or openai, ollama, ...
config=dict(
model_name="gemini-embedding-001",
task_type="RETRIEVAL_DOCUMENT",
# title="Embeddings",
),
),
)
)