feat: Enhance article generation and outline handling

- Added support for external markdown synchronization in ArticleEditorCanvas.vue.
- Implemented a new function to sync markdown from props, ensuring the editor reflects external changes.
- Introduced a removeOutlineSection function in TemplateWizardView.vue to manage outline sections dynamically.
- Updated UI components to improve user experience, including replacing a-input with a-textarea for better text handling.
- Refactored CSS styles for a cleaner layout and improved responsiveness in TemplateWizardView.vue.
- Enhanced LLM generation requests to include response format options in ark.go and client.go.
- Updated template assist logic to enforce structured outline outputs in template_assist.go.
- Added tests for outline result decoding and prompt generation to ensure robustness.
- Created migration scripts to update prompt templates with new writing requirements for top X articles.
This commit is contained in:
2026-04-02 10:58:39 +08:00
parent b31d8d0096
commit 7fa1809682
12 changed files with 605 additions and 106 deletions
+27
View File
@@ -132,6 +132,32 @@ 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}
}
var tools []*responses.ResponsesTool
if req.WebSearch != nil && req.WebSearch.Enabled {
webSearchLimit := c.webSearchLimit
@@ -159,6 +185,7 @@ func (c *arkClient) Generate(ctx context.Context, req GenerateRequest, onDelta f
Temperature: &c.temperature,
TopP: c.topP,
Tools: tools,
Text: textFormat,
Reasoning: c.reasoning,
Input: &responses.ResponsesInput{
Union: &responses.ResponsesInput_ListValue{
+17
View File
@@ -17,6 +17,7 @@ type GenerateRequest struct {
Timeout time.Duration
MaxOutputTokens int64
WebSearch *WebSearchOptions
ResponseFormat *ResponseFormat
}
type GenerateResult struct {
@@ -24,6 +25,22 @@ type GenerateResult struct {
Model string
}
type ResponseFormat struct {
Type ResponseFormatType
Name string
Description string
SchemaJSON []byte
Strict bool
}
type ResponseFormatType string
const (
ResponseFormatTypeText ResponseFormatType = "text"
ResponseFormatTypeJSONObject ResponseFormatType = "json_object"
ResponseFormatTypeJSONSchema ResponseFormatType = "json_schema"
)
type WebSearchOptions struct {
Enabled bool
Limit int32