|
132 | 132 | (fn [content]
|
133 | 133 | (if prompts-file
|
134 | 134 | (stache/render-string
|
135 |
| - content |
136 |
| - m |
137 |
| - {:partials (partials/file-partials |
138 |
| - [(if (fs/directory? prompts-file) prompts-file (fs/parent prompts-file))] |
139 |
| - ".md")}) |
| 135 | + content |
| 136 | + m |
| 137 | + {:partials (partials/file-partials |
| 138 | + [(if (fs/directory? prompts-file) prompts-file (fs/parent prompts-file))] |
| 139 | + ".md")}) |
140 | 140 | (stache/render-string content m)))))
|
141 | 141 |
|
142 | 142 | (defn selmer-render [m message]
|
|
145 | 145 | (fn [content]
|
146 | 146 | (selmer/render content m))))
|
147 | 147 |
|
148 |
| -(selmer/add-tag! :tip (fn [args context-map] |
149 |
| - (format |
150 |
| - "At the very end of the response, add this sentence: \"ℹ️ You can also ask: '%s'\", in the language used by the user, with the question in italic." (first args)))) |
| 148 | +(selmer/add-tag! :tip (fn [args context-map] |
| 149 | + (format |
| 150 | + "At the very end of the response, add this sentence: \"ℹ️ You can also ask: '%s'\", in the language used by the user, with the question in italic." (first args)))) |
151 | 151 |
|
152 | 152 | (comment
|
153 | 153 | (stache/render-string "yo {{a.0.content}}" {:a [{:content "blah"}]}))
|
|
159 | 159 | returns map of messages, functions, metadata and optionally error"
|
160 | 160 | [{:keys [parameters prompts user platform host-dir prompt-content] :as opts}]
|
161 | 161 | (let [{:keys [metadata] :as prompt-data}
|
162 |
| - (cond |
| 162 | + (cond |
163 | 163 | ;; prompt content is already in opts
|
164 | 164 | prompt-content
|
165 | 165 | (markdown-parser/parse-prompts prompt-content)
|
|
179 | 179 | :else
|
180 | 180 | (markdown-parser/parse-prompts (slurp prompts)))
|
181 | 181 |
|
182 |
| - m (merge (run-extractors (:extractors metadata) opts) parameters) |
183 |
| - renderer (if (= "django" (:prompt-format metadata)) |
| 182 | + m (merge |
| 183 | + (run-extractors (:extractors metadata) opts) |
| 184 | + parameters |
| 185 | + (-> metadata :parameter-values)) |
| 186 | + renderer (if (= "django" (:prompt-format metadata)) |
184 | 187 | (partial selmer-render (facts m user platform host-dir))
|
185 | 188 | (partial moustache-render prompts (facts m user platform host-dir)))]
|
186 | 189 | ((schema/validate :schema/prompts-file)
|
|
0 commit comments