Files
geo/server/internal/tenant/app/question_combination_fill_prompt.go
T
root 34ef5873ca
Deployment Config CI / Deployment Config (push) Successful in 27s
Backend CI / Backend (push) Successful in 16m5s
feat: load question expansion prompts from yaml
2026-05-13 20:24:51 +08:00

59 lines
1.5 KiB
Go

package app
import (
"encoding/json"
"strings"
"github.com/geo-platform/tenant-api/internal/tenant/prompts"
)
var questionCombinationFillSchema = []byte(`{
"type": "object",
"additionalProperties": false,
"properties": {
"region": {
"type": "array",
"maxItems": 4,
"items": { "type": "string", "minLength": 1, "maxLength": 16 }
},
"prefix": {
"type": "array",
"maxItems": 4,
"items": { "type": "string", "minLength": 1, "maxLength": 16 }
},
"core": {
"type": "array",
"maxItems": 4,
"items": { "type": "string", "minLength": 1, "maxLength": 18 }
},
"industry": {
"type": "array",
"maxItems": 4,
"items": { "type": "string", "minLength": 1, "maxLength": 18 }
},
"suffix": {
"type": "array",
"maxItems": 4,
"items": { "type": "string", "minLength": 1, "maxLength": 16 }
}
},
"required": ["region", "prefix", "core", "industry", "suffix"]
}`)
func buildQuestionCombinationFillPrompt(brandCtx *questionBrandContext, regionTerms []string, req QuestionCombinationFillRequest) string {
competitors := "无"
if len(brandCtx.CompetitorNames) > 0 {
encoded, _ := json.Marshal(brandCtx.CompetitorNames)
competitors = string(encoded)
}
hints, _ := json.Marshal(req)
return prompts.QuestionCombinationFillPrompt(
strings.TrimSpace(brandCtx.BrandName),
strings.TrimSpace(nilToString(brandCtx.Website)),
strings.TrimSpace(nilToString(brandCtx.Description)),
competitors,
strings.Join(regionTerms, "、"),
string(hints),
)
}