AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.

MongoDB 와 CrewAI 통합

MongoDB와 CrewAI 를 통합하여 특수한 역할, 도구 및 작업을 통해 자율적인 AI 에이전트와 멀티 에이전트 애플리케이션을 빌드 할 수 있습니다. 구체적으로, CrewAI를 위한 MongoDB 벡터 검색 도구를 활용하여 팀원 의 AI 에이전트가 데이터에서 관련 정보를 조회하여 작업을 완료하도록 활성화할 수 있습니다.

CrewAI 및 MongoDB 사용하여 튜토리얼을 완료하려면 CrewAI 및 MongoDB 사용하여 에이전트적 RAG 애플리케이션 빌드하기를 참조하세요.

CrewAI용 MongoDB 벡터 검색 도구를 설치하려면 Python 패키지 관리자에 따라 다음 명령 중 하나를 실행 .

pip install 'crewai-tools[mongodb]'

참고

Python 버전 호환성은 CrewAI의 공식 문서와 다를 수 있습니다. 작성 시점에서 crewai-tools 패키지 embedchain에 종속되며, 이를 위해서는 3.9 에서 3.13.2 사이의 Python 버전이 필요합니다. (포함).

MongoDB 벡터 검색 도구를 사용하려면 초기화한 다음 에이전트에 전달합니다.

도구를 초기화하려면 다음을 지정해야 합니다.

from crewai_tools import MongoDBVectorSearchTool tool = MongoDBVectorSearchTool( connection_string="<connection-string>", database_name="<database-name>", collection_name="<collection-name>", # Other optional parameters...) # To test the toolprint(tool.run(query="<test-query>")) # To use the tool in an agentrag_agent = Agent( name="rag_agent", role="You are a helpful assistant that can answer questions with the help of the MongoDBVectorSearchTool.", goal="...", backstory="...", tools=[tool],)

MongoDBVectorSearchTool 클래스는 다음 메서드를 제공합니다.

  • add_texts(): 지정된 MongoDB 컬렉션 에 텍스트 문서를 추가합니다.

  • create_vector_search_index(): 컬렉션 에 벡터 검색 인덱스 만듭니다.

  • run(): 데이터에 대해 벡터 검색 쿼리 실행합니다.

import osfrom crewai_tools import MongoDBVectorSearchTool tool = MongoDBVectorSearchTool( connection_string="<connection-string>", database_name="<database-name>", collection_name="<collection-name>") # Example of loading text content from a local foldertexts = []for fname in os.listdir("knowledge"): path = os.path.join("knowledge", fname) if os.path.isfile(path): with open(path, "r", encoding="utf-8") as f: texts.append(f.read()) # Method to add documents to the vector storetool.add_texts(texts) # Method to create the vector search indextool.create_vector_search_index(dimensions=<number-of-dimensions>) # Method to test the tool by running a vector search querytool.run(query="<search-query>")

이 페이지 평가하기

이 페이지의 내용