Mem0은 에이전트 대화에서 지속성 기억을 추출하고 이후 실행에서 관련 기억을 검색합니다. 세션 간에 메모리를 사용할 수 있어야 하는 경우 스토리지 및 검색 범위를 구성합니다.
이 통합은 메모리 패턴을 사용합니다. 전체 대화 대본을 재생하지 않고 선택한 지속성 정보를 추출하고 회수합니다.
중요합니다
Mem0은 타사 시스템입니다. 애플리케이션 데이터를 보내기 전에 데이터 처리, 보존, 지역 경계 및 서비스 약관을 검토합니다.
비고
현재 에이전트 프레임워크 .NET Mem0 통합을 사용할 수 없습니다.
패키지 설치
pip install agent-framework-mem0 --pre
MEM0_API_KEY을 설정하거나 API 키를 직접 전달합니다. 스토리지 및 검색을 별도로 구성합니다.
-
user_id,agent_id및application_id스토리지 범위입니다. Mem0은 저장된 각 메모리에 스탬프를 찍습니다. -
search_user_id,search_agent_id및search_application_id검색 범위입니다. Mem0에서는 이를 사용하여 검색할 추억을 선택합니다.
애플리케이션 범위에는 Mem0 Platform 클라이언트()가AsyncMemoryClient 필요합니다. OSS AsyncMemory 클라이언트는 사용자 및 에이전트 범위만 지원합니다.
검색 범위는 스토리지 범위에서 상속되지 않습니다. 범위를 설정 search_* 하지 않으면 공급자는 추억을 저장하지만 기억하지 않습니다.
사용자별 메모리의 경우 동일한 안정적인 식별자를 설정하고 user_idsearch_user_id 설정합니다.
async def main() -> None:
"""Example of memory usage with Mem0 context provider."""
print("=== Mem0 Context Provider Example ===")
# Each record in Mem0 should be associated with agent_id or user_id or application_id.
# In this example, we associate Mem0 records with user_id.
user_id = str(uuid.uuid4())
# For Azure authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
# authentication option.
# For Mem0 authentication, set Mem0 API key via "api_key" parameter or MEM0_API_KEY environment variable.
async with (
AzureCliCredential() as credential,
Agent(
client=FoundryChatClient(credential=credential),
name="FriendlyAssistant",
instructions="You are a friendly assistant.",
tools=retrieve_company_report,
context_providers=[Mem0ContextProvider(source_id="mem0", user_id=user_id, search_user_id=user_id)],
) as agent,
):
Mem0은 기억을 비동기적으로 처리합니다. 프로덕션 환경에서는 고정된 지연에 의존하는 대신 재시도 또는 서비스 인식 일관성 처리를 사용합니다.
비고
Mem0 통합은 현재 Agent Framework Go에서 사용할 수 없습니다. 최신 상태는 에이전트 프레임워크 Go 리포지토리 를 참조하세요.
다음 단계
더 자세히 살펴보기: