語言

DistributedCachingEmbeddingGenerator<TInput,TEmbedding> 類別

定義

代表一個委派嵌入產生器,快取嵌入產生呼叫的結果,並以 JSON 格式儲存在 IDistributedCache.

generic <typename TInput, typename TEmbedding>
 where TEmbedding : Embeddingpublic ref class DistributedCachingEmbeddingGenerator : Microsoft::Extensions::AI::CachingEmbeddingGenerator<TInput, TEmbedding>
public class DistributedCachingEmbeddingGenerator<TInput,TEmbedding> : Microsoft.Extensions.AI.CachingEmbeddingGenerator<TInput,TEmbedding> where TEmbedding : Embedding
type DistributedCachingEmbeddingGenerator<'Input, 'Embedding (requires 'Embedding :> Embedding)> = class
    inherit CachingEmbeddingGenerator<'Input, 'Embedding (requires 'Embedding :> Embedding)>
Public Class DistributedCachingEmbeddingGenerator(Of TInput, TEmbedding)
Inherits CachingEmbeddingGenerator(Of TInput, TEmbedding)

類型參數

TInput

嵌入將從中產生的類型。

TEmbedding

要產生的嵌入類型。

繼承

備註

所提供的實 IEmbeddingGenerator<TInput,TEmbedding> 作對並行使用是執行緒安全的,只要所用 IDistributedCache 的執行緒同樣適用於並行使用。

建構函式

名稱 Description
DistributedCachingEmbeddingGenerator<TInput,TEmbedding>(IEmbeddingGenerator<TInput,TEmbedding>, IDistributedCache)

初始化 DistributedCachingEmbeddingGenerator<TInput,TEmbedding> 類別的新執行個體。

屬性

名稱 Description
CacheKeyAdditionalValues

取得或設定額外值,用以通知用於儲存狀態的快取金鑰。

InnerGenerator

得到內層 IEmbeddingGenerator<TInput,TEmbedding>。

(繼承來源 DelegatingEmbeddingGenerator<TInput,TEmbedding>)
JsonSerializerOptions

取得或設定 JSON 序列化選項,用於序列化快取資料。

方法

名稱 Description
Dispose()

執行與釋放、釋放或重設非受控資源相關聯的應用程式定義工作。

(繼承來源 DelegatingEmbeddingGenerator<TInput,TEmbedding>)
Dispose(Boolean)

提供釋放 Unmanaged 資源的機制。

(繼承來源 DelegatingEmbeddingGenerator<TInput,TEmbedding>)
GenerateAsync(IEnumerable<TInput>, EmbeddingGenerationOptions, CancellationToken)

代表一個委派嵌入產生器,快取嵌入產生呼叫的結果,並以 JSON 格式儲存在 IDistributedCache.

(繼承來源 CachingEmbeddingGenerator<TInput,TEmbedding>)
GetCacheKey(ReadOnlySpan<Object>)

計算指定值的快取鍵。

GetService(Type, Object)

請求 給 IEmbeddingGenerator<TInput,TEmbedding> 指定類型的 serviceType物件。

(繼承來源 DelegatingEmbeddingGenerator<TInput,TEmbedding>)
ReadCacheAsync(String, CancellationToken)

若有,則回傳先前快取的 Embedding<T>。

WriteCacheAsync(String, TEmbedding, CancellationToken)

將 a TEmbedding 儲存在底層快取中。

擴充方法

名稱 Description
AsBuilder<TInput,TEmbedding>(IEmbeddingGenerator<TInput,TEmbedding>)

創造一個新的 EmbeddingGeneratorBuilder<TInput,TEmbedding> 用途 innerGenerator 作為其內部產生者。

GenerateAndZipAsync<TInput,TEmbedding>(IEmbeddingGenerator<TInput,TEmbedding>, IEnumerable<TInput>, EmbeddingGenerationOptions, CancellationToken)

為每個提供的 values 輸入產生嵌入,並產生一個將每個輸入值與其嵌入配對的清單。

GenerateAsync<TInput,TEmbedding>(IEmbeddingGenerator<TInput,TEmbedding>, TInput, EmbeddingGenerationOptions, CancellationToken)

從指定的 value生成嵌入。

GetRequiredService(IEmbeddingGenerator, Type, Object)

會要求 需要 IEmbeddingGenerator<TInput,TEmbedding> 指定類型的 serviceType 物件,若無法使用則拋出例外。

GetRequiredService<TService>(IEmbeddingGenerator, Object)

會請求 一個 IEmbeddingGenerator<TInput,TEmbedding> 類型的 TService 物件,若無法使用則拋出例外。

GetService<TService>(IEmbeddingGenerator, Object)

請求 一個 IEmbeddingGenerator<TInput,TEmbedding> 類型的 TService物件。

適用於