com.google.ai.edge.aicore


接口

DownloadCallback

用于模型下载的回调函数。

Part

表示向请求发送和从请求接收的数据的接口。

Candidate

模型的回答片段。

Content

表示发送给模型和从模型接收的内容。

Content.Builder
DownloadConfig

用于系统模型下载的配置参数。

GenerateContentResponse

表示模型的响应。

GenerationConfig

用于内容生成的配置参数。

GenerationConfig.Builder
GenerativeModel

给定系统模型的协助者。

TextPart

表示发送到请求和从请求接收的基于文本或字符串的数据。

异常

ConnectionException

连接时出错。

DownloadException

下载时出错。

GenerativeAIException

GenerativeModel 中发生的所有错误的父类。

InferenceException

推理期间出错。

PreparationException

准备过程中出错。

TokenizationException

令牌化期间出错。

UnknownException

未知错误。

注释

Candidate.FinishReason

Candidate 关联的结束原因

Content.Role

Content 相关联的角色

GenerativeAIException.ErrorCode

一组 GenerativeAIException 错误代码。

顶级函数摘要

Content
content(@Content.Role role: Int, init: Content.Builder.() -> Unit)

用于以 DSL 方式构建发送和接收的内容的函数。

GenerationConfig

用于以 DSL 方式构建 GenerationConfig 的辅助方法。

扩展函数摘要

顶级函数

内容

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")
}

扩展函数

asTextOrNull

fun Part.asTextOrNull(): String?
返回
String?

如果相应部分表示文本,则为 String;否则为 null