类 ResponseFormat
java.lang.Object
io.agentscope.core.formatter.ResponseFormat
Response format configuration for OpenAI API.
This class supports three response format types:
- text: Plain text response (default)
- json_object: Valid JSON object response
- json_schema: Response conforming to a specific JSON Schema
Example usage:
// Plain text
ResponseFormat format = ResponseFormat.text();
// JSON object
ResponseFormat format = ResponseFormat.jsonObject();
// JSON Schema with strict validation
JsonSchema schema = JsonSchema.builder()
.name("MathResponse")
.schema(Map.of("type", "object", ...))
.strict(true)
.build();
ResponseFormat format = ResponseFormat.jsonSchema(schema);
-
嵌套类概要
嵌套类 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static ResponseFormat.Builderbuilder()getType()static ResponseFormatCreate a JSON object response format.static ResponseFormatjsonSchema(JsonSchema schema) Create a JSON Schema response format with structured output validation.voidsetJsonSchema(JsonSchema jsonSchema) voidstatic ResponseFormattext()Create a plain text response format.
-
构造器详细资料
-
ResponseFormat
public ResponseFormat()
-
-
方法详细资料
-
text
Create a plain text response format.- 返回:
- ResponseFormat configured for plain text
-
jsonObject
Create a JSON object response format.The model will return a valid JSON object, but without a specific schema validation.
- 返回:
- ResponseFormat configured for JSON object
-
jsonSchema
Create a JSON Schema response format with structured output validation.The model will return a response that conforms to the provided JSON Schema. When strict mode is enabled, the response will be validated against the schema.
- 参数:
schema- The JSON Schema defining the expected structure- 返回:
- ResponseFormat configured for JSON Schema validation
-
getType
-
setType
-
getJsonSchema
-
setJsonSchema
-
builder
-