อินเทอร์เฟซ
DownloadCallback |
ฟังก์ชัน Callback ที่ใช้ในการดาวน์โหลดโมเดล |
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) เมธอดตัวช่วยในการสร้าง |
สรุปฟังก์ชันส่วนขยาย
ฟังก์ชันระดับบนสุด
เนื้อหา
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
เมธอดตัวช่วยในการสร้าง GenerationConfig
ในลักษณะ DSL
ตัวอย่างการใช้งาน
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")
}