feat: Refactor template handling and brand management
- Removed schema_json from article templates and related queries. - Updated brand service to include website field in requests and responses. - Simplified template wizard view by eliminating unused schema fields and related logic. - Added tests for ark text format handling. - Created migrations for dropping schema_json and adding website to brands.
This commit is contained in:
@@ -132,31 +132,7 @@ func (c *arkClient) Generate(ctx context.Context, req GenerateRequest, onDelta f
|
||||
},
|
||||
}
|
||||
|
||||
var textFormat *responses.ResponsesText
|
||||
if req.ResponseFormat != nil {
|
||||
format := &responses.TextFormat{
|
||||
Name: strings.TrimSpace(req.ResponseFormat.Name),
|
||||
}
|
||||
switch req.ResponseFormat.Type {
|
||||
case ResponseFormatTypeJSONSchema:
|
||||
format.Type = responses.TextType_json_schema
|
||||
case ResponseFormatTypeJSONObject:
|
||||
format.Type = responses.TextType_json_object
|
||||
default:
|
||||
format.Type = responses.TextType_text
|
||||
}
|
||||
if description := strings.TrimSpace(req.ResponseFormat.Description); description != "" {
|
||||
format.Description = &description
|
||||
}
|
||||
if len(req.ResponseFormat.SchemaJSON) > 0 {
|
||||
format.Schema = &responses.Bytes{Value: req.ResponseFormat.SchemaJSON}
|
||||
}
|
||||
if req.ResponseFormat.Strict {
|
||||
strict := true
|
||||
format.Strict = &strict
|
||||
}
|
||||
textFormat = &responses.ResponsesText{Format: format}
|
||||
}
|
||||
textFormat := buildArkTextFormat(req.ResponseFormat)
|
||||
|
||||
var tools []*responses.ResponsesTool
|
||||
if req.WebSearch != nil && req.WebSearch.Enabled {
|
||||
@@ -260,6 +236,38 @@ func (c *arkClient) Generate(ctx context.Context, req GenerateRequest, onDelta f
|
||||
}, nil
|
||||
}
|
||||
|
||||
func buildArkTextFormat(format *ResponseFormat) *responses.ResponsesText {
|
||||
if format == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
textFormat := &responses.TextFormat{}
|
||||
switch format.Type {
|
||||
case ResponseFormatTypeJSONSchema:
|
||||
textFormat.Type = responses.TextType_json_schema
|
||||
if name := strings.TrimSpace(format.Name); name != "" {
|
||||
textFormat.Name = name
|
||||
}
|
||||
if description := strings.TrimSpace(format.Description); description != "" {
|
||||
textFormat.Description = &description
|
||||
}
|
||||
if len(format.SchemaJSON) > 0 {
|
||||
textFormat.Schema = &responses.Bytes{Value: format.SchemaJSON}
|
||||
}
|
||||
if format.Strict {
|
||||
strict := true
|
||||
textFormat.Strict = &strict
|
||||
}
|
||||
case ResponseFormatTypeJSONObject:
|
||||
// Ark only accepts the type discriminator for json_object.
|
||||
textFormat.Type = responses.TextType_json_object
|
||||
default:
|
||||
textFormat.Type = responses.TextType_text
|
||||
}
|
||||
|
||||
return &responses.ResponsesText{Format: textFormat}
|
||||
}
|
||||
|
||||
func resolveArkReasoning(value string) *responses.ResponsesReasoning {
|
||||
switch strings.ToLower(strings.TrimSpace(value)) {
|
||||
case "":
|
||||
|
||||
Reference in New Issue
Block a user