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