GenerativeModel


public final class GenerativeModel implements AutoCloseable


特定系統模型的促進者。

摘要

公用建構函式

GenerativeModel(
    @NonNull GenerationConfig generationConfig,
    @NonNull DownloadConfig downloadConfig
)

公用方法

void

關閉用戶端並釋出其資源。

final @NonNull GenerateContentResponse

使用提供的 Content 從系統模型產生回應。

final @NonNull GenerateContentResponse

使用 Content 表示的文字,從系統模型產生回應。

final @NonNull Flow<@NonNull GenerateContentResponse>

使用提供的 Content 從系統模型產生串流回應。

final @NonNull Flow<@NonNull GenerateContentResponse>

使用 Content 所代表的文字,從系統模型產生串流回應。

final @NonNull DownloadConfig

系統模型下載設定

final @NonNull GenerationConfig

用於產生內容的設定參數

final @NonNull <Error class: unknown class>

提前準備引擎,將時間耗損移出推論。

公用建構函式

GenerativeModel

public GenerativeModel(
    @NonNull GenerationConfig generationConfig,
    @NonNull DownloadConfig downloadConfig
)

公用方法

關閉

public void close()

關閉用戶端並釋出其資源。

generateContent

public final @NonNull GenerateContentResponse generateContent(@NonNull Content prompt)

使用提供的 Content 從系統模型產生回應。

參數
@NonNull Content prompt

要傳送至模型的一組 Content

傳回
@NonNull GenerateContentResponse

經過一段延遲時間後的 GenerateContentResponse。函式應在暫停內容中呼叫,才能妥善管理並行性。

generateContent

public final @NonNull GenerateContentResponse generateContent(@NonNull String prompt)

使用 Content 表示的文字,從系統模型產生回應。

參數
@NonNull String prompt

要轉換為單一 Content 並傳送至模型的文字。

傳回
@NonNull GenerateContentResponse

經過一段延遲時間後的 GenerateContentResponse。函式應在暫停內容中呼叫,才能妥善管理並行性。

generateContentStream

public final @NonNull Flow<@NonNull GenerateContentResponsegenerateContentStream(@NonNull Content prompt)

使用提供的 Content 從系統模型產生串流回應。

參數
@NonNull Content prompt

要傳送至模型的一組 Content

傳回
@NonNull Flow<@NonNull GenerateContentResponse>

Flow 會在模型傳回回應時發出回應。

generateContentStream

public final @NonNull Flow<@NonNull GenerateContentResponsegenerateContentStream(@NonNull String prompt)

使用 Content 所代表的文字,從系統模型產生串流回應。

參數
@NonNull String prompt

要轉換為單一 Content 並傳送至模型的文字。

傳回
@NonNull Flow<@NonNull GenerateContentResponse>

Flow 會在模型傳回回應時發出回應。

getDownloadConfig

public final @NonNull DownloadConfig getDownloadConfig()

系統模型下載設定

getGenerationConfig

public final @NonNull GenerationConfig getGenerationConfig()

用於產生內容的設定參數

prepareInferenceEngine

public final @NonNull <Error class: unknown class> prepareInferenceEngine()

提前準備引擎,將時間耗損移出推論。呼叫這個方法並非必要,但我們建議您在第一次推論呼叫之前先呼叫這個方法,以便盡可能縮短第一次推論的延遲時間。