โดย Gemini API จะแสดงผลการตอบกลับเป็นข้อความที่ไม่มีโครงสร้างโดยค่าเริ่มต้น อย่างไรก็ตาม กรณีการใช้งานบางอย่างต้องใช้ข้อความที่มีโครงสร้าง เช่น JSON เช่น คุณอาจ ใช้การตอบกลับสำหรับงานอื่นๆ ที่ต้องใช้สคีมาข้อมูลที่สร้างขึ้น
หากต้องการให้เอาต์พุตที่โมเดลสร้างขึ้นเป็นไปตามสคีมาที่เฉพาะเจาะจงเสมอ คุณสามารถกำหนดสคีมาการตอบกลับ ซึ่งทำงานเหมือนพิมพ์เขียวสำหรับการตอบกลับของโมเดล จากนั้นคุณจะดึงข้อมูลจากเอาต์พุตของโมเดลได้โดยตรงโดยไม่ต้องประมวลผลภายหลังมากนัก
โดยตัวอย่างมีดังนี้
ตรวจสอบว่าการตอบกลับของโมเดลสร้าง JSON ที่ถูกต้องและเป็นไปตามสคีมาที่คุณ ระบุ
เช่น โมเดลสามารถสร้างรายการที่มีโครงสร้างสำหรับสูตรอาหารซึ่งมี ชื่อสูตร รายการส่วนผสม และขั้นตอนเสมอ จากนั้นคุณจะแยกวิเคราะห์และแสดงข้อมูลนี้ใน UI ของแอปได้ง่ายขึ้นจำกัดวิธีที่โมเดลตอบกลับระหว่างงานการจัดประเภท
เช่น คุณสามารถให้โมเดลใส่คำอธิบายประกอบข้อความด้วยชุดป้ายกำกับที่เฉพาะเจาะจง (เช่น ชุดป้ายกำกับที่เฉพาะเจาะจง เช่นpositive
และnegative
) แทนป้ายกำกับที่โมเดลสร้างขึ้น (ซึ่งอาจมีความแปรปรวนในระดับหนึ่ง เช่นgood
,positive
,negative
หรือbad
)
คู่มือนี้แสดงวิธีสร้างเอาต์พุต JSON โดยการระบุ responseSchema
ในการเรียกใช้ generateContent
โดยจะเน้นที่อินพุตที่เป็นข้อความเท่านั้น แต่ Gemini ยังสร้างคำตอบที่มีโครงสร้างสำหรับคำขอแบบมัลติโมดัลซึ่งมีรูปภาพ วิดีโอ และเสียงเป็นอินพุตได้ด้วย
ที่ด้านล่างของหน้านี้มีตัวอย่างเพิ่มเติม เช่น วิธี สร้างค่า Enum เป็นเอาต์พุต
ก่อนเริ่มต้น
คลิกผู้ให้บริการ Gemini API เพื่อดูเนื้อหาและโค้ดของผู้ให้บริการนั้นๆ ในหน้านี้ |
หากยังไม่ได้ดำเนินการ ให้ทำตามคู่มือเริ่มต้นใช้งาน ซึ่งอธิบายวิธี
ตั้งค่าโปรเจ็กต์ Firebase, เชื่อมต่อแอปกับ Firebase, เพิ่ม SDK,
เริ่มต้นบริการแบ็กเอนด์สำหรับผู้ให้บริการ Gemini API ที่เลือก และ
สร้างอินสแตนซ์ GenerativeModel
สําหรับการทดสอบและทําซ้ำพรอมต์ รวมถึง การรับข้อมูลโค้ดที่สร้างขึ้น เราขอแนะนําให้ใช้ Google AI Studio
ขั้นตอนที่ 1: กำหนดสคีมาการตอบกลับ
กำหนดสคีมาการตอบกลับเพื่อระบุโครงสร้างของเอาต์พุตของโมเดล ชื่อฟิลด์ และประเภทข้อมูลที่คาดไว้สำหรับแต่ละฟิลด์
เมื่อโมเดลสร้างคำตอบ โมเดลจะใช้ชื่อฟิลด์และบริบทจากพรอมต์ ของคุณ เราขอแนะนำให้ใช้ โครงสร้างที่ชัดเจน ชื่อฟิลด์ที่ไม่กำกวม และแม้แต่คำอธิบายตามความจำเป็น เพื่อให้มั่นใจว่าเจตนาของคุณชัดเจน
ข้อควรพิจารณาสำหรับสคีมาการตอบกลับ
โปรดคำนึงถึงสิ่งต่อไปนี้เมื่อเขียนสคีมาการตอบกลับ
ขนาดของสคีมาการตอบกลับจะนับรวมในขีดจํากัดโทเค็นอินพุต
ฟีเจอร์สคีมาการตอบกลับรองรับประเภท MIME ของการตอบกลับต่อไปนี้
application/json
: แสดงผล JSON ตามที่กำหนดไว้ในสคีมาการตอบกลับ (มีประโยชน์สำหรับข้อกำหนดเอาต์พุตที่มีโครงสร้าง)text/x.enum
: แสดงค่า enum ตามที่กำหนดไว้ในสคีมาการตอบกลับ (มีประโยชน์สำหรับงานการจัดประเภท)
ฟีเจอร์สคีมาการตอบกลับรองรับฟิลด์สคีมาต่อไปนี้
enum
items
maxItems
nullable
properties
required
หากใช้ฟิลด์ที่ไม่รองรับ โมเดลจะยังคงจัดการคำขอได้ แต่จะ ไม่สนใจฟิลด์นั้น โปรดทราบว่ารายการด้านบนเป็นส่วนหนึ่งของออบเจ็กต์สคีมา OpenAPI 3.0
โดยค่าเริ่มต้น สำหรับ Firebase AI Logic SDK ระบบจะถือว่าทุกช่องเป็นต้องระบุ เว้นแต่คุณจะระบุว่าไม่บังคับในอาร์เรย์
optionalProperties
สำหรับฟิลด์ที่ไม่บังคับเหล่านี้ โมเดลสามารถป้อนข้อมูลในฟิลด์หรือข้าม ฟิลด์ได้ โปรดทราบว่าลักษณะการทำงานนี้จะตรงกันข้ามกับลักษณะการทำงานเริ่มต้นของ Gemini APIผู้ให้บริการทั้ง 2 รายหากคุณใช้ SDK ของเซิร์ฟเวอร์หรือ API ของผู้ให้บริการโดยตรง
ขั้นตอนที่ 2: สร้างเอาต์พุต JSON โดยใช้สคีมาการตอบกลับ
ก่อนที่จะลองใช้ตัวอย่างนี้ ให้ทำตามส่วน
ก่อนที่จะเริ่มของคู่มือนี้
เพื่อตั้งค่าโปรเจ็กต์และแอป ในส่วนนั้น คุณจะคลิกปุ่มสำหรับ ผู้ให้บริการ Gemini API ที่เลือกเพื่อให้เห็นเนื้อหาเฉพาะของผู้ให้บริการ ในหน้านี้ด้วย |
ตัวอย่างต่อไปนี้แสดงวิธีสร้างเอาต์พุต JSON ที่มีโครงสร้าง
เมื่อสร้างGenerativeModel
อินสแตนซ์ ให้ระบุ
responseMimeType
ที่เหมาะสม (ในตัวอย่างนี้คือ application/json
) รวมถึง
responseSchema
ที่คุณต้องการให้โมเดลใช้
import FirebaseAI
// Provide a JSON schema object using a standard format.
// Later, pass this schema object into `responseSchema` in the generation config.
let jsonSchema = Schema.object(
properties: [
"characters": Schema.array(
items: .object(
properties: [
"name": .string(),
"age": .integer(),
"species": .string(),
"accessory": .enumeration(values: ["hat", "belt", "shoes"]),
],
optionalProperties: ["accessory"]
)
),
]
)
// Initialize the Gemini Developer API backend service
let ai = FirebaseAI.firebaseAI(backend: .googleAI())
// Create a `GenerativeModel` instance with a model that supports your use case
let model = ai.generativeModel(
modelName: "gemini-2.5-flash",
// In the generation config, set the `responseMimeType` to `application/json`
// and pass the JSON schema object into `responseSchema`.
generationConfig: GenerationConfig(
responseMIMEType: "application/json",
responseSchema: jsonSchema
)
)
let prompt = "For use in a children's card game, generate 10 animal-based characters."
let response = try await model.generateContent(prompt)
print(response.text ?? "No text in response.")
// Provide a JSON schema object using a standard format.
// Later, pass this schema object into `responseSchema` in the generation config.
val jsonSchema = Schema.obj(
mapOf("characters" to Schema.array(
Schema.obj(
mapOf(
"name" to Schema.string(),
"age" to Schema.integer(),
"species" to Schema.string(),
"accessory" to Schema.enumeration(listOf("hat", "belt", "shoes")),
),
optionalProperties = listOf("accessory")
)
))
)
// Initialize the Gemini Developer API backend service
// Create a `GenerativeModel` instance with a model that supports your use case
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
modelName = "gemini-2.5-flash",
// In the generation config, set the `responseMimeType` to `application/json`
// and pass the JSON schema object into `responseSchema`.
generationConfig = generationConfig {
responseMimeType = "application/json"
responseSchema = jsonSchema
})
val prompt = "For use in a children's card game, generate 10 animal-based characters."
val response = generativeModel.generateContent(prompt)
print(response.text)
Publisher
จากไลบรารี Reactive Streams
// Provide a JSON schema object using a standard format.
// Later, pass this schema object into `responseSchema` in the generation config.
Schema jsonSchema = Schema.obj(
/* properties */
Map.of(
"characters", Schema.array(
/* items */ Schema.obj(
/* properties */
Map.of("name", Schema.str(),
"age", Schema.numInt(),
"species", Schema.str(),
"accessory",
Schema.enumeration(
List.of("hat", "belt", "shoes")))
))),
List.of("accessory"));
// In the generation config, set the `responseMimeType` to `application/json`
// and pass the JSON schema object into `responseSchema`.
GenerationConfig.Builder configBuilder = new GenerationConfig.Builder();
configBuilder.responseMimeType = "application/json";
configBuilder.responseSchema = jsonSchema;
GenerationConfig generationConfig = configBuilder.build();
// Initialize the Gemini Developer API backend service
// Create a `GenerativeModel` instance with a model that supports your use case
GenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.googleAI())
.generativeModel(
/* modelName */ "gemini-2.5-flash",
/* generationConfig */ generationConfig);
GenerativeModelFutures model = GenerativeModelFutures.from(ai);
Content content = new Content.Builder()
.addText("For use in a children's card game, generate 10 animal-based characters.")
.build();
// For illustrative purposes only. You should use an executor that fits your needs.
Executor executor = Executors.newSingleThreadExecutor();
ListenableFuture<GenerateContentResponse> response = model.generateContent(content);
Futures.addCallback(
response,
new FutureCallback<GenerateContentResponse>() {
@Override
public void onSuccess(GenerateContentResponse result) {
String resultText = result.getText();
System.out.println(resultText);
}
@Override
public void onFailure(Throwable t) {
t.printStackTrace();
}
},
executor);
import { initializeApp } from "firebase/app";
import { getAI, getGenerativeModel, GoogleAIBackend, Schema } from "firebase/ai";
// TODO(developer) Replace the following with your app's Firebase configuration
// See: https://firebase.google.com/docs/web/learn-more#config-object
const firebaseConfig = {
// ...
};
// Initialize FirebaseApp
const firebaseApp = initializeApp(firebaseConfig);
// Initialize the Gemini Developer API backend service
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
// Provide a JSON schema object using a standard format.
// Later, pass this schema object into `responseSchema` in the generation config.
const jsonSchema = Schema.object({
properties: {
characters: Schema.array({
items: Schema.object({
properties: {
name: Schema.string(),
accessory: Schema.string(),
age: Schema.number(),
species: Schema.string(),
},
optionalProperties: ["accessory"],
}),
}),
}
});
// Create a `GenerativeModel` instance with a model that supports your use case
const model = getGenerativeModel(ai, {
model: "gemini-2.5-flash",
// In the generation config, set the `responseMimeType` to `application/json`
// and pass the JSON schema object into `responseSchema`.
generationConfig: {
responseMimeType: "application/json",
responseSchema: jsonSchema
},
});
let prompt = "For use in a children's card game, generate 10 animal-based characters.";
let result = await model.generateContent(prompt)
console.log(result.response.text());
import 'package:firebase_ai/firebase_ai.dart';
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';
// Provide a JSON schema object using a standard format.
// Later, pass this schema object into `responseSchema` in the generation config.
final jsonSchema = Schema.object(
properties: {
'characters': Schema.array(
items: Schema.object(
properties: {
'name': Schema.string(),
'age': Schema.integer(),
'species': Schema.string(),
'accessory':
Schema.enumString(enumValues: ['hat', 'belt', 'shoes']),
},
),
),
},
optionalProperties: ['accessory'],
);
// Initialize FirebaseApp
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
// Initialize the Gemini Developer API backend service
// Create a `GenerativeModel` instance with a model that supports your use case
final model =
FirebaseAI.googleAI().generativeModel(
model: 'gemini-2.5-flash',
// In the generation config, set the `responseMimeType` to `application/json`
// and pass the JSON schema object into `responseSchema`.
generationConfig: GenerationConfig(
responseMimeType: 'application/json', responseSchema: jsonSchema));
final prompt = "For use in a children's card game, generate 10 animal-based characters.";
final response = await model.generateContent([Content.text(prompt)]);
print(response.text);
using Firebase;
using Firebase.AI;
// Provide a JSON schema object using a standard format.
// Later, pass this schema object into `responseSchema` in the generation config.
var jsonSchema = Schema.Object(
properties: new System.Collections.Generic.Dictionary<string, Schema> {
{ "characters", Schema.Array(
items: Schema.Object(
properties: new System.Collections.Generic.Dictionary<string, Schema> {
{ "name", Schema.String() },
{ "age", Schema.Int() },
{ "species", Schema.String() },
{ "accessory", Schema.Enum(new string[] { "hat", "belt", "shoes" }) },
},
optionalProperties: new string[] { "accessory" }
)
) },
}
);
// Initialize the Gemini Developer API backend service
// Create a `GenerativeModel` instance with a model that supports your use case
var model = FirebaseAI.DefaultInstance.GetGenerativeModel(
modelName: "gemini-2.5-flash",
// In the generation config, set the `responseMimeType` to `application/json`
// and pass the JSON schema object into `responseSchema`.
generationConfig: new GenerationConfig(
responseMimeType: "application/json",
responseSchema: jsonSchema
)
);
var prompt = "For use in a children's card game, generate 10 animal-based characters.";
var response = await model.GenerateContentAsync(prompt);
UnityEngine.Debug.Log(response.Text ?? "No text in response.");
ดูวิธีเลือกโมเดล ที่เหมาะสมกับกรณีการใช้งานและแอปของคุณ
ตัวอย่างเพิ่มเติม
ตัวอย่างเพิ่มเติมเกี่ยวกับวิธีใช้และสร้างเอาต์พุตที่มีโครงสร้างมีดังนี้สร้างค่า enum เป็นเอาต์พุต
ก่อนที่จะลองใช้ตัวอย่างนี้ ให้ทำตามส่วน
ก่อนที่จะเริ่มของคู่มือนี้
เพื่อตั้งค่าโปรเจ็กต์และแอป ในส่วนนั้น คุณจะคลิกปุ่มสำหรับ ผู้ให้บริการ Gemini API ที่เลือกเพื่อให้เห็นเนื้อหาเฉพาะของผู้ให้บริการ ในหน้านี้ด้วย |
ตัวอย่างต่อไปนี้แสดงวิธีใช้สคีมาการตอบกลับสำหรับงานการจัดประเภท ระบบขอให้โมเดลระบุประเภทของภาพยนตร์ตามคำอธิบาย เอาต์พุตคือค่า Enum ที่เป็นข้อความธรรมดา 1 ค่าที่โมเดลเลือกจาก รายการค่าที่กำหนดไว้ในสคีมาการตอบกลับที่ระบุ
หากต้องการทํางานการแยกประเภทที่มีโครงสร้างนี้ คุณต้องระบุในระหว่างการเริ่มต้นโมเดล responseMimeType
ที่เหมาะสม (ในตัวอย่างนี้คือ text/x.enum
) รวมถึง responseSchema
ที่คุณต้องการให้โมเดลใช้
import FirebaseAI
// Provide an enum schema object using a standard format.
// Later, pass this schema object into `responseSchema` in the generation config.
let enumSchema = Schema.enumeration(values: ["drama", "comedy", "documentary"])
// Initialize the Gemini Developer API backend service
let ai = FirebaseAI.firebaseAI(backend: .googleAI())
// Create a `GenerativeModel` instance with a model that supports your use case
let model = ai.generativeModel(
modelName: "gemini-2.5-flash",
// In the generation config, set the `responseMimeType` to `text/x.enum`
// and pass the enum schema object into `responseSchema`.
generationConfig: GenerationConfig(
responseMIMEType: "text/x.enum",
responseSchema: enumSchema
)
)
let prompt = """
The film aims to educate and inform viewers about real-life subjects, events, or people.
It offers a factual record of a particular topic by combining interviews, historical footage,
and narration. The primary purpose of a film is to present information and provide insights
into various aspects of reality.
"""
let response = try await model.generateContent(prompt)
print(response.text ?? "No text in response.")
// Provide an enum schema object using a standard format.
// Later, pass this schema object into `responseSchema` in the generation config.
val enumSchema = Schema.enumeration(listOf("drama", "comedy", "documentary"))
// Initialize the Gemini Developer API backend service
// Create a `GenerativeModel` instance with a model that supports your use case
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
modelName = "gemini-2.5-flash",
// In the generation config, set the `responseMimeType` to `text/x.enum`
// and pass the enum schema object into `responseSchema`.
generationConfig = generationConfig {
responseMimeType = "text/x.enum"
responseSchema = enumSchema
})
val prompt = """
The film aims to educate and inform viewers about real-life subjects, events, or people.
It offers a factual record of a particular topic by combining interviews, historical footage,
and narration. The primary purpose of a film is to present information and provide insights
into various aspects of reality.
"""
val response = generativeModel.generateContent(prompt)
print(response.text)
Publisher
จากไลบรารี Reactive Streams
// Provide an enum schema object using a standard format.
// Later, pass this schema object into `responseSchema` in the generation config.
Schema enumSchema = Schema.enumeration(List.of("drama", "comedy", "documentary"));
// In the generation config, set the `responseMimeType` to `text/x.enum`
// and pass the enum schema object into `responseSchema`.
GenerationConfig.Builder configBuilder = new GenerationConfig.Builder();
configBuilder.responseMimeType = "text/x.enum";
configBuilder.responseSchema = enumSchema;
GenerationConfig generationConfig = configBuilder.build();
// Initialize the Gemini Developer API backend service
// Create a `GenerativeModel` instance with a model that supports your use case
GenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.googleAI())
.generativeModel(
/* modelName */ "gemini-2.5-flash",
/* generationConfig */ generationConfig);
GenerativeModelFutures model = GenerativeModelFutures.from(ai);
String prompt = "The film aims to educate and inform viewers about real-life subjects," +
" events, or people. It offers a factual record of a particular topic by" +
" combining interviews, historical footage, and narration. The primary purpose" +
" of a film is to present information and provide insights into various aspects" +
" of reality.";
Content content = new Content.Builder().addText(prompt).build();
// For illustrative purposes only. You should use an executor that fits your needs.
Executor executor = Executors.newSingleThreadExecutor();
ListenableFuture<GenerateContentResponse> response = model.generateContent(content);
Futures.addCallback(
response,
new FutureCallback<GenerateContentResponse>() {
@Override
public void onSuccess(GenerateContentResponse result) {
String resultText = result.getText();
System.out.println(resultText);
}
@Override
public void onFailure(Throwable t) {
t.printStackTrace();
}
},
executor);
import { initializeApp } from "firebase/app";
import { getAI, getGenerativeModel, GoogleAIBackend, Schema } from "firebase/ai";
// TODO(developer) Replace the following with your app's Firebase configuration
// See: https://firebase.google.com/docs/web/learn-more#config-object
const firebaseConfig = {
// ...
};
// Initialize FirebaseApp
const firebaseApp = initializeApp(firebaseConfig);
// Initialize the Gemini Developer API backend service
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
// Provide an enum schema object using a standard format.
// Later, pass this schema object into `responseSchema` in the generation config.
const enumSchema = Schema.enumString({
enum: ["drama", "comedy", "documentary"],
});
// Create a `GenerativeModel` instance with a model that supports your use case
const model = getGenerativeModel(ai, {
model: "gemini-2.5-flash",
// In the generation config, set the `responseMimeType` to `text/x.enum`
// and pass the JSON schema object into `responseSchema`.
generationConfig: {
responseMimeType: "text/x.enum",
responseSchema: enumSchema,
},
});
let prompt = `The film aims to educate and inform viewers about real-life
subjects, events, or people. It offers a factual record of a particular topic
by combining interviews, historical footage, and narration. The primary purpose
of a film is to present information and provide insights into various aspects
of reality.`;
let result = await model.generateContent(prompt);
console.log(result.response.text());
import 'package:firebase_ai/firebase_ai.dart';
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';
// Provide an enum schema object using a standard format.
// Later, pass this schema object into `responseSchema` in the generation config.
final enumSchema = Schema.enumString(enumValues: ['drama', 'comedy', 'documentary']);
// Initialize FirebaseApp
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
// Initialize the Gemini Developer API backend service
// Create a `GenerativeModel` instance with a model that supports your use case
final model =
FirebaseAI.googleAI().generativeModel(
model: 'gemini-2.5-flash',
// In the generation config, set the `responseMimeType` to `text/x.enum`
// and pass the enum schema object into `responseSchema`.
generationConfig: GenerationConfig(
responseMimeType: 'text/x.enum', responseSchema: enumSchema));
final prompt = """
The film aims to educate and inform viewers about real-life subjects, events, or people.
It offers a factual record of a particular topic by combining interviews, historical footage,
and narration. The primary purpose of a film is to present information and provide insights
into various aspects of reality.
""";
final response = await model.generateContent([Content.text(prompt)]);
print(response.text);
using Firebase;
using Firebase.AI;
// Provide an enum schema object using a standard format.
// Later, pass this schema object into `responseSchema` in the generation config.
var enumSchema = Schema.Enum(new string[] { "drama", "comedy", "documentary" });
// Initialize the Gemini Developer API backend service
// Create a `GenerativeModel` instance with a model that supports your use case
var model = FirebaseAI.DefaultInstance.GetGenerativeModel(
modelName: "gemini-2.5-flash",
// In the generation config, set the `responseMimeType` to `text/x.enum`
// and pass the enum schema object into `responseSchema`.
generationConfig: new GenerationConfig(
responseMimeType: "text/x.enum",
responseSchema: enumSchema
)
);
var prompt = @"
The film aims to educate and inform viewers about real-life subjects, events, or people.
It offers a factual record of a particular topic by combining interviews, historical footage,
and narration. The primary purpose of a film is to present information and provide insights
into various aspects of reality.
";
var response = await model.GenerateContentAsync(prompt);
UnityEngine.Debug.Log(response.Text ?? "No text in response.");
ดูวิธีเลือกโมเดล ที่เหมาะสมกับกรณีการใช้งานและแอปของคุณ
ตัวเลือกอื่นๆ ในการควบคุมการสร้างเนื้อหา
- ดูข้อมูลเพิ่มเติมเกี่ยวกับการออกแบบพรอมต์ เพื่อให้คุณมีอิทธิพลต่อโมเดลในการสร้างเอาต์พุตที่เฉพาะเจาะจงตามความต้องการของคุณ
- กำหนดค่าพารามิเตอร์โมเดล เพื่อควบคุมวิธีที่โมเดลสร้างคำตอบ สำหรับGemini โมเดล พารามิเตอร์เหล่านี้ประกอบด้วยโทเค็นเอาต์พุตสูงสุด อุณหภูมิ topK และ topP สำหรับImagen โมเดล ฟีเจอร์เหล่านี้รวมถึงสัดส่วนภาพ การสร้างบุคคล ลายน้ำ ฯลฯ
- ใช้การตั้งค่าความปลอดภัย เพื่อปรับความน่าจะเป็นที่จะได้รับคำตอบที่อาจถือว่า เป็นอันตราย ซึ่งรวมถึงวาจาสร้างความเกลียดชังและเนื้อหาเกี่ยวกับเรื่องเพศอย่างโจ่งแจ้ง
- ตั้งคำสั่งของระบบ เพื่อกำหนดลักษณะการทำงานของโมเดล ฟีเจอร์นี้เป็นเหมือนคำนำที่คุณ เพิ่มก่อนที่โมเดลจะได้รับคำสั่งเพิ่มเติมจากผู้ใช้ปลายทาง
แสดงความคิดเห็น เกี่ยวกับประสบการณ์การใช้งาน Firebase AI Logic