Bedrock Knowledge Base Retriever

Bedrock Knowledge Base Retriever

자연어 쿼리로 Amazon Bedrock 지식 베이스에서 정보를 검색하는 도구예요.

출처: 문서

본문

BedrockKBRetrieverTool

BedrockKBRetrieverTool은 CrewAI 에이전트가 자연어 쿼리를 사용해 Amazon Bedrock 지식 베이스에서 정보를 검색할 수 있게 해줍니다.

설치 (Installation)

uv pip install 'crewai[tools]'

요구 사항 (Requirements)

  • AWS 자격 증명 설정 (환경 변수 또는 AWS CLI를 통해)
  • boto3와 python-dotenv 패키지
  • Amazon Bedrock 지식 베이스에 대한 접근 권한

사용법 (Usage)

CrewAI 에이전트와 함께 도구를 사용하는 방법은 다음과 같습니다:

from crewai import Agent, Task, Crew
from crewai_tools.aws.bedrock.knowledge_base.retriever_tool import BedrockKBRetrieverTool

# Initialize the tool
kb_tool = BedrockKBRetrieverTool(
    knowledge_base_id="your-kb-id",
    number_of_results=5
)

# Create a CrewAI agent that uses the tool
researcher = Agent(
    role='Knowledge Base Researcher',
    goal='Find information about company policies',
    backstory='I am a researcher specialized in retrieving and analyzing company documentation.',
    tools=[kb_tool],
    verbose=True
)

# Create a task for the agent
research_task = Task(
    description="Find our company's remote work policy and summarize the key points.",
    agent=researcher
)

# Create a crew with the agent
crew = Crew(
    agents=[researcher],
    tasks=[research_task],
    verbose=2
)

# Run the crew
result = crew.kickoff()
print(result)

도구 인자 (Tool Arguments)

인자 타입 필수 기본값 설명
knowledge_base_id str Yes None 지식 베이스의 고유 식별자 (0-10 영숫자 문자)
number_of_results int No 5 반환할 최대 결과 수
retrieval_configuration dict No None 지식 베이스 쿼리용 커스텀 설정
guardrail_configuration dict No None 콘텐츠 필터링 설정
next_token str No None 페이지네이션용 토큰

환경 변수 (Environment Variables)

BEDROCK_KB_ID=your-knowledge-base-id  # Alternative to passing knowledge_base_id
AWS_REGION=your-aws-region            # Defaults to us-east-1
AWS_ACCESS_KEY_ID=your-access-key     # Required for AWS authentication
AWS_SECRET_ACCESS_KEY=your-secret-key # Required for AWS authentication

응답 형식 (Response Format)

도구는 JSON 형식으로 결과를 반환합니다:

{
  "results": [
    {
      "content": "Retrieved text content",
      "content_type": "text",
      "source_type": "S3",
      "source_uri": "s3://bucket/document.pdf",
      "score": 0.95,
      "metadata": {
        "additional": "metadata"
      }
    }
  ],
  "nextToken": "pagination-token",
  "guardrailAction": "NONE"
}

고급 사용법 (Advanced Usage)

커스텀 검색 설정 (Custom Retrieval Configuration)
kb_tool = BedrockKBRetrieverTool(
    knowledge_base_id="your-kb-id",
    retrieval_configuration={
        "vectorSearchConfiguration": {
            "numberOfResults": 10,
            "overrideSearchType": "HYBRID"
        }
    }
)

policy_expert = Agent(
    role='Policy Expert',
    goal='Analyze company policies in detail',
    backstory='I am an expert in corporate policy analysis with deep knowledge of regulatory requirements.',
    tools=[kb_tool]
)

지원 데이터 소스 (Supported Data Sources)

  • Amazon S3
  • Confluence
  • Salesforce
  • SharePoint
  • 웹 페이지
  • 커스텀 문서 위치
  • Amazon Kendra
  • SQL 데이터베이스

사용 사례 (Use Cases)

엔터프라이즈 지식 통합 (Enterprise Knowledge Integration)
  • 민감한 데이터를 노출하지 않고 CrewAI 에이전트가 조직의 독점 지식에 접근할 수 있게 함
  • 에이전트가 회사의 특정 정책, 절차, 문서에 기반해 결정을 내릴 수 있게 함
  • 데이터 보안을 유지하면서 내부 문서를 바탕으로 질문에 답하는 에이전트 생성
전문 도메인 지식 (Specialized Domain Knowledge)
  • 모델을 재학습하지 않고 CrewAI 에이전트를 도메인별 지식 베이스(법률, 의료, 기술)에 연결
  • AWS 환경에 이미 유지 관리되고 있는 기존 지식 저장소 활용
  • CrewAI의 추론과 지식 베이스의 도메인별 정보 결합
데이터 기반 의사 결정 (Data-Driven Decision Making)
  • 일반적인 지식이 아니라 실제 회사 데이터에 CrewAI 에이전트 응답을 근거로 함
  • 에이전트가 특정 비즈니스 컨텍스트와 문서를 바탕으로 권장 사항을 제공하도록 보장
  • 지식 베이스에서 사실 정보를 검색해 환각(hallucination) 감소
확장 가능한 정보 접근 (Scalable Information Access)
  • 모든 것을 모델에 임베딩하지 않고 테라바이트급 조직 지식에 접근
  • 특정 태스크에 필요한 관련 정보만 동적으로 질의
  • AWS의 확장 가능한 인프라를 활용해 대규모 지식 베이스를 효율적으로 처리
규정 준수와 거버넌스 (Compliance and Governance)
  • CrewAI 에이전트가 회사의 승인된 문서와 일치하는 응답을 제공하도록 보장
  • 에이전트가 사용한 정보 소스의 감사 가능한 추적 기록 생성
  • 에이전트가 접근할 수 있는 정보 소스에 대한 제어 유지

더 알아보기 (Learn more)