Feature/prompt terms (#128)

* Add prompt terms
* Remove dupe template code
This commit is contained in:
cybermaggedon 2024-10-27 15:04:53 +00:00 committed by GitHub
parent 2942c4dcf0
commit 7c0c471e55
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,6 +8,36 @@ local default_prompts = import "prompts/default-prompts.jsonnet";
prompts:: default_prompts,
local prompt_template_args = [ "--prompt" ] + [
p.key + "=" + p.value.prompt,
for p in std.objectKeysValuesAll($.prompts.templates)
],
local prompt_response_type_args = [ "--prompt-response-type" ] + [
p.key + "=" + p.value["response-type"],
for p in std.objectKeysValuesAll($.prompts.templates)
if std.objectHas(p.value, "response-type")
],
local prompt_schema_args = [ "--prompt-schema" ] + [
(
p.key + "=" +
std.manifestJsonMinified(p.value["schema"])
)
for p in std.objectKeysValuesAll($.prompts.templates)
if std.objectHas(p.value, "schema")
],
local prompt_term_args = [ "--prompt-term" ] + [
p.key + "=" + t.key + ":" + t.value
for p in std.objectKeysValuesAll($.prompts.templates)
if std.objectHas(p.value, "terms")
for t in std.objectKeysValuesAll(p.value.terms)
],
local prompt_args = prompt_template_args + prompt_response_type_args +
prompt_schema_args + prompt_term_args,
"prompt" +: {
create:: function(engine)
@ -28,27 +58,8 @@ local default_prompts = import "prompts/default-prompts.jsonnet";
"--system-prompt",
$["prompts"]["system-template"],
"--prompt",
] + [
p.key + "=" + p.value.prompt,
for p in std.objectKeysValuesAll($.prompts.templates)
] + [
"--prompt-response-type"
] + [
p.key + "=" + p.value["response-type"],
for p in std.objectKeysValuesAll($.prompts.templates)
if std.objectHas(p.value, "response-type")
] + [
"--prompt-schema"
] + [
(
p.key + "=" +
std.manifestJsonMinified(p.value["schema"])
)
for p in std.objectKeysValuesAll($.prompts.templates)
if std.objectHas(p.value, "schema")
])
] + prompt_args
)
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
@ -90,27 +101,8 @@ local default_prompts = import "prompts/default-prompts.jsonnet";
"--system-prompt",
$["prompts"]["system-template"],
"--prompt",
] + [
p.key + "=" + p.value.prompt,
for p in std.objectKeysValuesAll($.prompts.templates)
] + [
"--prompt-response-type"
] + [
p.key + "=" + p.value["response-type"],
for p in std.objectKeysValuesAll($.prompts.templates)
if std.objectHas(p.value, "response-type")
] + [
"--prompt-schema"
] + [
(
p.key + "=" +
std.manifestJsonMinified(p.value["schema"])
)
for p in std.objectKeysValuesAll($.prompts.templates)
if std.objectHas(p.value, "schema")
])
] + prompt_args
)
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");