에이전트 SDK 스토리지 개요

스토리지는 Microsoft 에이전트 SDK의 중요한 구성 요소로, 에이전트가 세션 간에 대화 상태, 사용자 데이터 및 기타 정보를 유지할 수 있도록 합니다. 메모리 내 스토리지, Azure Cosmos DB, Azure Blobs Storage를 비롯한 다양한 스토리지 옵션을 지원하며 사용자 지정 스토리지 공급자를 허용합니다.

키 스토리지 옵션

  1. 메모리 스토리지

    • 테스트 및 개발 목적에 적합합니다.
    • 에이전트가 다시 시작될 때 데이터가 지워지므로 프로덕션에 적합하지 않습니다.
    • 데이터는 웹앱 인스턴스에서만 사용할 수 있으므로 클러스터에서 실행할 때 적합하지 않습니다.
  2. Azure Cosmos DB (애저 코스모스 DB)

    • 프로덕션 에이전트에 적합한 전역적으로 분산된 다중 모델 데이터베이스입니다.
    • 확장성 및 성능을 위해 분할된 스토리지를 지원합니다.
  3. Azure Blob Storage (애저 블롭 스토리지)

    • 텍스트 또는 이진 파일과 같은 구조화되지 않은 데이터를 저장하기 위해 최적화되었습니다.
    • 에이전트 상태 및 대화록 스토리지에 일반적으로 사용됩니다.
  4. 사용자 지정 스토리지 옵션은 IStorage를 구현하여 제공할 수 있습니다.

다른 스토리지 공급자 사용

메모리 스토리지

모든 샘플 사용 MemoryStorage

.NET의 경우 Program.cs에서 MemoryStorage을 등록합니다.

builder.Services.AddSingleton<IStorage, MemoryStorage>();

Azure CosmosDb 스토리지

.NET의 경우:

  1. Microsoft.Agents.Storage.CosmosDb에 대한 패키지 종속성 추가

  2. Program.cs에서 IStorage 등록을 다음으로 추가(또는 바꾸기) 합니다.

    builder.Services.AddSingleton<IStorage>(sp =>
    {
          var options = new CosmosDbPartitionedStorageOptions()
          {
             CosmosDbEndpoint = "your-cosmosdb-endpoint",
             DatabaseId = "your-database-id",
             ContainerId = "your-container-id",
    
             // Get a TokenCredential from your defined Connections
             TokenCredential = sp.GetService<IConnections>().GetConnection("ServiceConnection").GetTokenCredential()
          };
    
          return new CosmosDbPartitionedStorage(options);
    });
    
  3. 자세한 내용은 CosmosDbPartitionedStorageOptions를 참조하세요.

Azure Blob Storage

.NET의 경우:

  1. Microsoft.Agents.Storage.Blobs에 대한 패키지 종속성 추가

  2. Program.cs에서 IStorage 등록을 다음으로 추가(또는 바꾸기) 합니다.

    builder.Services.AddSingleton<IStorage>(sp =>
    {
       // Get a TokenCredential from your defined Connections
       var tokenCredential = sp.GetService<IConnections>().GetConnection("ServiceConnection").GetTokenCredential();
    
       return new BlobsStorage(
          new Uri("{{your-blobs-storage-endpoint}}/agent-state"),
          tokenCredential);
    });