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

用于生成内容的配置参数