From 4c58c751e99f3f22401b2ff29b8121f9edf5c15e Mon Sep 17 00:00:00 2001 From: Cyber MacGeddon Date: Fri, 10 Jan 2025 16:22:19 +0000 Subject: [PATCH] Finalised templates --- templates/components/vertexai-rag.jsonnet | 74 +++++++++++++++++++++++ templates/components/vertexai.jsonnet | 54 ----------------- 2 files changed, 74 insertions(+), 54 deletions(-) create mode 100644 templates/components/vertexai-rag.jsonnet diff --git a/templates/components/vertexai-rag.jsonnet b/templates/components/vertexai-rag.jsonnet new file mode 100644 index 00000000..9c7eaa00 --- /dev/null +++ b/templates/components/vertexai-rag.jsonnet @@ -0,0 +1,74 @@ +local base = import "base/base.jsonnet"; +local images = import "values/images.jsonnet"; +local url = import "values/url.jsonnet"; +local prompts = import "prompts/mixtral.jsonnet"; + +{ + + with:: function(key, value) + self + { + ["vertexai-rag-" + key]:: value, + }, + + "vertexai-rag-model":: "gemini-1.0-pro-001", + "vertexai-rag-private-key":: "/vertexai/private.json", + "vertexai-rag-region":: "us-central1", + "vertexai-rag-max-output-tokens":: 4096, + "vertexai-rag-temperature":: 0.0, + + "text-completion-rag" +: { + + create:: function(engine) + + local cfgVol = engine.secretVolume( + "vertexai-creds", + "./vertexai", + { + "private.json": importstr "vertexai/private.json", + } + ); + + local container = + engine.container("text-completion-rag") + .with_image(images.trustgraph) + .with_command([ + "text-completion-vertexai", + "-p", + url.pulsar, + "-k", + $["vertexai-rag-private-key"], + "-r", + $["vertexai-rag-region"], + "-x", + std.toString($["vertexai-rag-max-output-tokens"]), + "-t", + "%0.3f" % $["vertexai-rag-temperature"], + "-m", + $["vertexai-rag-model"], + "-i", + "non-persistent://tg/request/text-completion-rag", + "-o", + "non-persistent://tg/response/text-completion-rag", + ]) + .with_limits("0.5", "256M") + .with_reservations("0.1", "256M") + .with_volume_mount(cfgVol, "/vertexai"); + + local containerSet = engine.containers( + "text-completion-rag", [ container ] + ); + + local service = + engine.internalService(containerSet) + .with_port(8000, 8000, "metrics"); + + engine.resources([ + cfgVol, + containerSet, + service, + ]) + + } + +} + prompts + diff --git a/templates/components/vertexai.jsonnet b/templates/components/vertexai.jsonnet index ef193156..fc3192a4 100644 --- a/templates/components/vertexai.jsonnet +++ b/templates/components/vertexai.jsonnet @@ -61,59 +61,5 @@ local prompts = import "prompts/mixtral.jsonnet"; }, - "text-completion-rag" +: { - - create:: function(engine) - - local cfgVol = engine.secretVolume( - "vertexai-creds", - "./vertexai", - { - "private.json": importstr "vertexai/private.json", - } - ); - - local container = - engine.container("text-completion-rag") - .with_image(images.trustgraph) - .with_command([ - "text-completion-vertexai", - "-p", - url.pulsar, - "-k", - $["vertexai-private-key"], - "-r", - $["vertexai-region"], - "-x", - std.toString($["vertexai-max-output-tokens"]), - "-t", - "%0.3f" % $["vertexai-temperature"], - "-m", - $["vertexai-model"], - "-i", - "non-persistent://tg/request/text-completion-rag", - "-o", - "non-persistent://tg/response/text-completion-rag", - ]) - .with_limits("0.5", "256M") - .with_reservations("0.1", "256M") - .with_volume_mount(cfgVol, "/vertexai"); - - local containerSet = engine.containers( - "text-completion-rag", [ container ] - ); - - local service = - engine.internalService(containerSet) - .with_port(8000, 8000, "metrics"); - - engine.resources([ - cfgVol, - containerSet, - service, - ]) - - } - } + prompts