mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-08 02:03:42 +08:00
meta prompt function is ready
This commit is contained in:
@@ -94,3 +94,30 @@ func (h *PromptHandler) Video(c *gin.Context) {
|
||||
|
||||
resp.SUCCESS(c, strings.Trim(content, `"`))
|
||||
}
|
||||
|
||||
// MetaPrompt 生成元提示词
|
||||
func (h *PromptHandler) MetaPrompt(c *gin.Context) {
|
||||
var data struct {
|
||||
Prompt string `json:"prompt"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&data); err != nil {
|
||||
resp.ERROR(c, types.InvalidArgs)
|
||||
return
|
||||
}
|
||||
messages := make([]interface{}, 0)
|
||||
messages = append(messages, types.Message{
|
||||
Role: "system",
|
||||
Content: service.MetaPromptTemplate,
|
||||
})
|
||||
messages = append(messages, types.Message{
|
||||
Role: "user",
|
||||
Content: "Task, Goal, or the Role to actor is:\n" + data.Prompt,
|
||||
})
|
||||
content, err := utils.SendOpenAIMessage(h.DB, messages, 0)
|
||||
if err != nil {
|
||||
resp.ERROR(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp.SUCCESS(c, strings.Trim(content, `"`))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user