接口
DownloadCallback |
用于模型下载的回调函数。 |
Part |
表示向请求发送和从请求接收的数据的接口。 |
类
Candidate |
模型的回答片段。 |
Content |
表示发送给模型和从模型接收的内容。 |
Content.Builder |
|
DownloadConfig |
用于系统模型下载的配置参数。 |
GenerateContentResponse |
表示模型的响应。 |
GenerationConfig |
用于内容生成的配置参数。 |
GenerationConfig.Builder |
|
GenerativeModel |
给定系统模型的协助者。 |
TextPart |
表示发送到请求和从请求接收的基于文本或字符串的数据。 |
异常
ConnectionException |
连接时出错。 |
DownloadException |
下载时出错。 |
GenerativeAIException |
|
InferenceException |
推理期间出错。 |
PreparationException |
准备过程中出错。 |
TokenizationException |
令牌化期间出错。 |
UnknownException |
未知错误。 |
注释
Candidate.FinishReason |
与 |
Content.Role |
与 |
GenerativeAIException.ErrorCode |
一组 |
顶级函数摘要
Content |
content(@Content.Role role: Int, init: Content.Builder.() -> Unit) 用于以 DSL 方式构建发送和接收的内容的函数。 |
GenerationConfig |
generationConfig(init: GenerationConfig.Builder.() -> Unit) 用于以 DSL 方式构建 |
扩展函数摘要
顶级函数
内容
fun content(@Content.Role role: Int = Role.USER, init: Content.Builder.() -> Unit): Content
用于以 DSL 方式构建发送和接收的内容的函数。
包含一组文本、图片和二进制部分。
用法示例:
content(Role.MODEL) {
text("Example string")
)
generationConfig
fun generationConfig(init: GenerationConfig.Builder.() -> Unit): GenerationConfig
用于以 DSL 方式构建 GenerationConfig
的辅助方法。
用法示例:
generationConfig {
context = context // required
workerExecutor = workerThread // Set the [ExecutorService] on which background tasks should be run. If no value is specified, a background thread pool will be used.
callbackExecutor = callbackExecutor // Set the [Executor] on which callbacks should be invoked. If no value is specified, callbacks will be invoked on the UI thread.
temperature = 0.75f
topK = 30
candidateCount = 4
maxOutputTokens = 300
stopSequences = listOf("in conclusion", "-----", "do you need")
}