mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-26 08:56:21 +02:00
Maint/neater prompt jsonnet (#127)
* Changed the JSONNET for prompt-template so that prompt templates are simpler. This tidies default-prompts.jsonnet so it's easier to see where the prompts are. * Updated prompt override templates to match new structure
This commit is contained in:
parent
b07d539802
commit
2942c4dcf0
7 changed files with 303 additions and 99 deletions
|
|
@ -6,6 +6,8 @@ local default_prompts = import "prompts/default-prompts.jsonnet";
|
|||
|
||||
{
|
||||
|
||||
prompts:: default_prompts,
|
||||
|
||||
"prompt" +: {
|
||||
|
||||
create:: function(engine)
|
||||
|
|
@ -24,36 +26,28 @@ local default_prompts = import "prompts/default-prompts.jsonnet";
|
|||
"non-persistent://tg/response/text-completion-response",
|
||||
|
||||
"--system-prompt",
|
||||
$["system-template"],
|
||||
$["prompts"]["system-template"],
|
||||
|
||||
"--prompt",
|
||||
"question={{question}}",
|
||||
"extract-definitions=" +
|
||||
$["prompt-definition-template"],
|
||||
"extract-relationships=" +
|
||||
$["prompt-relationship-template"],
|
||||
"extract-topics=" +
|
||||
$["prompt-topic-template"],
|
||||
"kg-prompt=" +
|
||||
$["prompt-knowledge-query-template"],
|
||||
"document-prompt=" +
|
||||
$["prompt-document-query-template"],
|
||||
"extract-rows=" +
|
||||
$["prompt-rows-template"],
|
||||
|
||||
"--prompt-response-type",
|
||||
"extract-definitions=json",
|
||||
"extract-relationships=json",
|
||||
"extract-topics=json",
|
||||
"kg-prompt=text",
|
||||
"document-prompt=text",
|
||||
"extract-rows=json",
|
||||
|
||||
"--prompt-schema",
|
||||
'extract-definitions={ "type": "array", "items": { "type": "object", "properties": { "entity": { "type": "string" }, "definition": { "type": "string" } }, "required": [ "entity", "definition" ] } }',
|
||||
'extract-relationships={ "type": "array", "items": { "type": "object", "properties": { "subject": { "type": "string" }, "predicate": { "type": "string" }, "object": { "type": "string" }, "object-entity": { "type": "boolean" } }, "required": [ "subject", "predicate", "object", "object-entity" ] } }',
|
||||
'extract-topics={ "type": "array", "items": { "type": "object", "properties": { "topic": { "type": "string" }, "definition": { "type": "string" } }, "required": [ "topic", "definition" ] } }',
|
||||
|
||||
] + [
|
||||
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")
|
||||
])
|
||||
.with_limits("0.5", "128M")
|
||||
.with_reservations("0.1", "128M");
|
||||
|
|
@ -94,36 +88,28 @@ local default_prompts = import "prompts/default-prompts.jsonnet";
|
|||
"non-persistent://tg/response/text-completion-rag-response",
|
||||
|
||||
"--system-prompt",
|
||||
$["system-template"],
|
||||
$["prompts"]["system-template"],
|
||||
|
||||
"--prompt",
|
||||
"question={{question}}",
|
||||
"extract-definitions=" +
|
||||
$["prompt-definition-template"],
|
||||
"extract-relationships=" +
|
||||
$["prompt-relationship-template"],
|
||||
"extract-topics=" +
|
||||
$["prompt-topic-template"],
|
||||
"kg-prompt=" +
|
||||
$["prompt-knowledge-query-template"],
|
||||
"document-prompt=" +
|
||||
$["prompt-document-query-template"],
|
||||
"extract-rows=" +
|
||||
$["prompt-rows-template"],
|
||||
|
||||
"--prompt-response-type",
|
||||
"extract-definitions=json",
|
||||
"extract-relationships=json",
|
||||
"extract-topics=json",
|
||||
"kg-prompt=text",
|
||||
"document-prompt=text",
|
||||
"extract-rows=json",
|
||||
|
||||
"--prompt-schema",
|
||||
'extract-definitions={ "type": "array", "items": { "type": "object", "properties": { "entity": { "type": "string" }, "definition": { "type": "string" } }, "required": [ "entity", "definition" ] } }',
|
||||
'extract-relationships={ "type": "array", "items": { "type": "object", "properties": { "subject": { "type": "string" }, "predicate": { "type": "string" }, "object": { "type": "string" }, "object-entity": { "type": "boolean" } }, "required": [ "subject", "predicate", "object", "object-entity" ] } }',
|
||||
'extract-topics={ "type": "array", "items": { "type": "object", "properties": { "topic": { "type": "string" }, "definition": { "type": "string" } }, "required": [ "topic", "definition" ] } }',
|
||||
|
||||
] + [
|
||||
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")
|
||||
])
|
||||
.with_limits("0.5", "128M")
|
||||
.with_reservations("0.1", "128M");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue