summaryrefslogtreecommitdiff
path: root/scripts/toy.groovy
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/toy.groovy')
-rw-r--r--scripts/toy.groovy20
1 files changed, 20 insertions, 0 deletions
diff --git a/scripts/toy.groovy b/scripts/toy.groovy
index a19b024..b89f6b0 100644
--- a/scripts/toy.groovy
+++ b/scripts/toy.groovy
@@ -402,6 +402,26 @@ ${jspec.collect{ k, v -> "\"${k}\": ${v}" }.join(",\n ")}
}
}
+ final textMatcher = { text, dommePrompt, assetDetail, assetType, requestPrompt, assets ->
+ final assetList = assets.collect{ id, value -> "* ${id} : ${value}" }.join("\n");
+ final idList = assets.keySet().collect{ id -> "\"${id}\"" }.join(" | ");
+ final request = [
+ model: loadString("toy.chatModel"),
+ grammar: "root ::= ( ${idList} )",
+ messages: [
+ [role: "system", content: """
+You are ${DOMME.title} ${DOMME.fullName}.
+${dommePrompt}
+Given a list of ${assetDetail}, you select the ${assetType} which best ${requestPrompt}.
+The available ${assetType}s are:
+${assetList}"""
+ ],
+ [role: "user", content: "Write only an ${assetType} Id from the list as an unformatted string, select an ${assetType} for the text: ${text}"]
+ ]
+ ];
+ return callAPI("chat/completions", request)?.choices?[0]?.message?.content;
+ }
+
final chatInitialMessages = { String ... extra ->
def messages = [
[role: "system", content: """