GenerativeModel


class GenerativeModel : AutoCloseable


特定系統模型的促進者。

摘要

公用建構函式

GenerativeModel(
    generationConfig: GenerationConfig,
    downloadConfig: DownloadConfig
)

公開函式

open Unit

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

suspend GenerateContentResponse
generateContent(vararg prompt: Content)

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

suspend GenerateContentResponse

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

Flow<GenerateContentResponse>
generateContentStream(vararg prompt: Content)

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

Flow<GenerateContentResponse>

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

suspend <Error class: unknown class>

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

公開屬性

DownloadConfig

系統模型下載設定

GenerationConfig

用於產生內容的設定參數

公用建構函式

GenerativeModel

GenerativeModel(
    generationConfig: GenerationConfig,
    downloadConfig: DownloadConfig = DownloadConfig()
)

公開函式

關閉

open fun close(): Unit

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

generateContent

suspend fun generateContent(vararg prompt: Content): GenerateContentResponse

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

參數
vararg prompt: Content

要傳送至模型的一組 Content

傳回
GenerateContentResponse

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

generateContent

suspend fun generateContent(prompt: String): GenerateContentResponse

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

參數
prompt: String

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

傳回
GenerateContentResponse

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

generateContentStream

fun generateContentStream(vararg prompt: Content): Flow<GenerateContentResponse>

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

參數
vararg prompt: Content

要傳送至模型的一組 Content

傳回
Flow<GenerateContentResponse>

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

generateContentStream

fun generateContentStream(prompt: String): Flow<GenerateContentResponse>

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

參數
prompt: String

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

傳回
Flow<GenerateContentResponse>

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

prepareInferenceEngine

suspend fun prepareInferenceEngine(): <Error class: unknown class>

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

公開屬性

downloadConfig

val downloadConfigDownloadConfig

系統模型下載設定

generationConfig

val generationConfigGenerationConfig

用於產生內容的設定參數