AuthoringPrompt creates a prompt template from a CEL environment for the purpose of AI-assisted authoring.
(env *Env)
| 62 | |
| 63 | // AuthoringPrompt creates a prompt template from a CEL environment for the purpose of AI-assisted authoring. |
| 64 | func AuthoringPrompt(env *Env) (*Prompt, error) { |
| 65 | funcMap := template.FuncMap{ |
| 66 | "split": splitImpl, |
| 67 | "newlineToSpace": func(str string) string { return strings.ReplaceAll(str, "\n", " ") }, |
| 68 | } |
| 69 | tmpl := template.New("cel").Funcs(funcMap) |
| 70 | tmpl, err := tmpl.Parse(authoringPrompt) |
| 71 | if err != nil { |
| 72 | return nil, err |
| 73 | } |
| 74 | return &Prompt{ |
| 75 | Persona: defaultPersona, |
| 76 | FormatRules: defaultFormatRules, |
| 77 | GeneralUsage: defaultGeneralUsage, |
| 78 | tmpl: tmpl, |
| 79 | env: env, |
| 80 | }, nil |
| 81 | } |
| 82 | |
| 83 | // AuthoringPromptWithFieldPaths creates a prompt template from a CEL environment for the purpose of AI-assisted authoring. |
| 84 | // Includes documentation for all of the reachable field paths in the environment. |