59 lines
1.5 KiB
Go
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),
|
|
)
|
|
}
|