Refactor templates (#52)

* Switching from docker compose to abstract form - should be easier to k8s later
* Text loader util
* Recreate templates
This commit is contained in:
cybermaggedon 2024-09-05 16:40:47 +01:00 committed by GitHub
parent af5508ff68
commit 65d7f6d261
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
47 changed files with 1659 additions and 1277 deletions

View file

@ -49,6 +49,7 @@ VECTORDB=qdrant
JSONNET_FLAGS=-J templates -J .
update-templates: set-version
for graph in ${GRAPHS}; do \
cm=$${graph},pulsar,${VECTORDB},grafana; \

128
scripts/load-text Executable file
View file

@ -0,0 +1,128 @@
#!/usr/bin/env python3
"""
Loads a text document into TrustGraph processing.
"""
import pulsar
from pulsar.schema import JsonSchema
from trustgraph.schema import TextDocument, Source, text_ingest_queue
import base64
import hashlib
import argparse
import os
import time
from trustgraph.log_level import LogLevel
class Loader:
def __init__(
self,
pulsar_host,
output_queue,
log_level,
file,
):
self.client = pulsar.Client(
pulsar_host,
logger=pulsar.ConsoleLogger(log_level.to_pulsar())
)
self.producer = self.client.create_producer(
topic=output_queue,
schema=JsonSchema(TextDocument),
chunking_enabled=True,
)
self.file = file
def run(self):
try:
path = self.file
data = open(path, "rb").read()
id = hashlib.sha256(path.encode("utf-8")).hexdigest()[0:8]
r = TextDocument(
source=Source(
source=path,
title=path,
id=id,
),
text=data,
)
self.producer.send(r)
except Exception as e:
print(e, flush=True)
def __del__(self):
self.client.close()
def main():
parser = argparse.ArgumentParser(
prog='loader',
description=__doc__,
)
default_pulsar_host = os.getenv("PULSAR_HOST", 'pulsar://localhost:6650')
default_output_queue = text_ingest_queue
parser.add_argument(
'-p', '--pulsar-host',
default=default_pulsar_host,
help=f'Pulsar host (default: {default_pulsar_host})',
)
parser.add_argument(
'-o', '--output-queue',
default=default_output_queue,
help=f'Output queue (default: {default_output_queue})'
)
parser.add_argument(
'-l', '--log-level',
type=LogLevel,
default=LogLevel.ERROR,
choices=list(LogLevel),
help=f'Output queue (default: info)'
)
parser.add_argument(
'-f', '--file',
required=True,
help=f'File to load'
)
args = parser.parse_args()
while True:
try:
p = Loader(
pulsar_host=args.pulsar_host,
output_queue=args.output_queue,
log_level=args.log_level,
file=args.file,
)
p.run()
print("File loaded.")
break
except Exception as e:
print("Exception:", e, flush=True)
print("Will retry...", flush=True)
time.sleep(10)
main()

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""
Loads a PDF documented into TrustGraph processing.
Loads a PDF document into TrustGraph processing.
"""
import pulsar

View file

@ -1,4 +1,4 @@
local components = {
{
"azure": import "components/azure.jsonnet",
"bedrock": import "components/bedrock.jsonnet",
"claude": import "components/claude.jsonnet",
@ -24,32 +24,12 @@ local components = {
"vector-store-milvus": import "components/milvus.jsonnet",
"vector-store-qdrant": import "components/qdrant.jsonnet",
"vertexai": import "components/vertexai.jsonnet",
"null": {}
};
"null": {},
local config = function(p)
(components[p.name] + {
with:: function(k, v) self + {
[k]:: v
},
with_params:: function(pars)
self + std.foldl(
function(obj, par) obj.with(par.key, par.value),
std.objectKeysValues(pars),
self
),
}).with_params(p.parameters);
local options = import "config.json";
local add = function(state, p) state + config(p);
local output = std.foldl(add, options, {});
//std.manifestYamlDoc(config)
output
// FIXME: Dupes
"cassandra": import "components/cassandra.jsonnet",
"neo4j": import "components/neo4j.jsonnet",
"qdrant": import "components/qdrant.jsonnet",
"trustgraph": import "components/trustgraph.jsonnet",
}

View file

@ -2,6 +2,7 @@ local base = import "base/base.jsonnet";
local images = import "values/images.jsonnet";
local url = import "values/url.jsonnet";
local prompts = import "prompts/mixtral.jsonnet";
{
"azure-token":: "${AZURE_TOKEN}",
@ -9,70 +10,76 @@ local prompts = import "prompts/mixtral.jsonnet";
"azure-max-output-tokens":: 4096,
"azure-temperature":: 0.0,
services +: {
"text-completion" +: {
create:: function(engine)
"text-completion": base + {
image: images.trustgraph,
command: [
"text-completion-azure",
"-p",
url.pulsar,
"-k",
$["azure-token"],
"-e",
$["azure-endpoint"],
"-x",
std.toString($["azure-max-output-tokens"]),
"-t",
std.toString($["azure-temperature"]),
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local container =
engine.container("text-completion")
.with_image(images.trustgraph)
.with_command([
"text-completion-azure",
"-p",
url.pulsar,
"-k",
$["azure-token"],
"-e",
$["azure-endpoint"],
"-x",
std.toString($["azure-max-output-tokens"]),
"-t",
std.toString($["azure-temperature"]),
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"text-completion", [ container ]
);
engine.resources([
containerSet,
])
"text-completion-rag": base + {
image: images.trustgraph,
command: [
"text-completion-azure",
"-p",
url.pulsar,
"-k",
$["azure-token"],
"-e",
$["azure-endpoint"],
"-i",
"-x",
std.toString($["azure-max-output-tokens"]),
"-t",
std.toString($["azure-temperature"]),
"non-persistent://tg/request/text-completion-rag",
"-o",
"non-persistent://tg/response/text-completion-rag-response",
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
},
"text-completion-rag" +: {
create:: function(engine)
local container =
engine.container("text-completion-rag")
.with_image(images.trustgraph)
.with_command([
"text-completion-azure",
"-p",
url.pulsar,
"-k",
$["azure-token"],
"-e",
$["azure-endpoint"],
"-x",
std.toString($["azure-max-output-tokens"]),
"-t",
std.toString($["azure-temperature"]),
"-i",
"non-persistent://tg/request/text-completion-rag",
"-o",
"non-persistent://tg/response/text-completion-rag-response",
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"text-completion-rag", [ container ]
);
engine.resources([
containerSet,
])
}
} + prompts

View file

@ -3,7 +3,9 @@ local images = import "values/images.jsonnet";
local url = import "values/url.jsonnet";
local prompts = import "prompts/mixtral.jsonnet";
local chunker = import "chunker-recursive.jsonnet";
{
"aws-id-key":: "${AWS_ID_KEY}",
"aws-secret-key":: "${AWS_SECRET_KEY}",
"aws-region":: "us-west-2",
@ -11,78 +13,84 @@ local chunker = import "chunker-recursive.jsonnet";
"bedrock-temperature":: 0.0,
"bedrock-model":: "mistral.mixtral-8x7b-instruct-v0:1",
services +: {
"text-completion" +: {
create:: function(engine)
"text-completion": base + {
image: images.trustgraph,
command: [
"text-completion-bedrock",
"-p",
url.pulsar,
"-z",
$["aws-id-key"],
"-k",
$["aws-secret-key"],
"-r",
$["aws-region"],
"-x",
std.toString($["bedrock-max-output-tokens"]),
"-t",
std.toString($["bedrock-temperature"]),
"-m",
$["bedrock-model"],
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local container =
engine.container("text-completion")
.with_image(images.trustgraph)
.with_command([
"text-completion-bedrock",
"-p",
url.pulsar,
"-z",
$["aws-id-key"],
"-k",
$["aws-secret-key"],
"-r",
$["aws-region"],
"-x",
std.toString($["bedrock-max-output-tokens"]),
"-t",
std.toString($["bedrock-temperature"]),
"-m",
$["bedrock-model"],
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"text-completion", [ container ]
);
engine.resources([
containerSet,
])
"text-completion-rag": base + {
image: images.trustgraph,
command: [
"text-completion-bedrock",
"-p",
url.pulsar,
"-z",
$["aws-id-key"],
"-k",
$["aws-secret-key"],
"-r",
$["aws-region"],
"-x",
std.toString($["bedrock-max-output-tokens"]),
"-t",
std.toString($["bedrock-temperature"]),
"-m",
$["bedrock-model"],
"-i",
"non-persistent://tg/request/text-completion-rag",
"-o",
"non-persistent://tg/response/text-completion-rag-response",
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
},
"text-completion-rag" +: {
create:: function(engine)
local container =
engine.container("text-completion-rag")
.with_image(images.trustgraph)
.with_command([
"text-completion-bedrock",
"-p",
url.pulsar,
"-z",
$["aws-id-key"],
"-k",
$["aws-secret-key"],
"-r",
$["aws-region"],
"-x",
std.toString($["bedrock-max-output-tokens"]),
"-t",
std.toString($["bedrock-temperature"]),
"-m",
$["bedrock-model"],
"-i",
"non-persistent://tg/request/text-completion-rag",
"-o",
"non-persistent://tg/response/text-completion-rag-response",
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"text-completion-rag", [ container ]
);
engine.resources([
containerSet,
])
}
} + prompts + chunker

View file

@ -6,53 +6,59 @@ local cassandra = import "stores/cassandra.jsonnet";
cassandra + {
services +: {
"store-triples" +: {
create:: function(engine)
"store-triples": base + {
image: images.trustgraph,
command: [
"triples-write-cassandra",
"-p",
url.pulsar,
"-g",
cassandra_hosts,
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local container =
engine.container("store-triples")
.with_image(images.trustgraph)
.with_command([
"triples-write-cassandra",
"-p",
url.pulsar,
"-g",
cassandra_hosts,
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
"query-triples": base + {
image: images.trustgraph,
command: [
"triples-query-cassandra",
"-p",
url.pulsar,
"-g",
cassandra_hosts,
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '512M'
},
reservations: {
cpus: '0.1',
memory: '512M'
}
}
},
},
local containerSet = engine.containers(
"stop-triples", [ container ]
);
engine.resources([
containerSet,
])
},
"query-triples" +: {
create:: function(engine)
local container =
engine.container("query-triples")
.with_image(images.trustgraph)
.with_command([
"triples-query-cassandra",
"-p",
url.pulsar,
"-g",
cassandra_hosts,
])
.with_limits("0.5", "512M")
.with_reservations("0.1", "512M");
local containerSet = engine.containers(
"query-triples", [ container ]
);
engine.resources([
containerSet,
])
}
}

View file

@ -2,38 +2,40 @@ local base = import "base/base.jsonnet";
local images = import "values/images.jsonnet";
local url = import "values/url.jsonnet";
local prompts = import "prompts/mixtral.jsonnet";
{
"chunk-size":: 2000,
"chunk-overlap":: 100,
services +: {
"chunker" +: {
create:: function(engine)
local container =
engine.container("chunker")
.with_image(images.trustgraph)
.with_command([
"chunker-recursive",
"-p",
url.pulsar,
"--chunk-size",
std.toString($["chunk-size"]),
"--chunk-overlap",
std.toString($["chunk-overlap"]),
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"chunker", [ container ]
);
engine.resources([
containerSet,
])
chunker: base + {
image: images.trustgraph,
command: [
"chunker-recursive",
"-p",
url.pulsar,
"--chunk-size",
std.toString($["chunk-size"]),
"--chunk-overlap",
std.toString($["chunk-overlap"]),
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
},
} + prompts
}

View file

@ -2,71 +2,79 @@ local base = import "base/base.jsonnet";
local images = import "values/images.jsonnet";
local url = import "values/url.jsonnet";
local prompts = import "prompts/mixtral.jsonnet";
{
"claude-key":: "${CLAUDE_KEY}",
"claude-max-output-tokens":: 4096,
"claude-temperature":: 0.0,
services +: {
"text-completion" +: {
create:: function(engine)
"text-completion": base + {
image: images.trustgraph,
command: [
"text-completion-claude",
"-p",
url.pulsar,
"-k",
$["claude-key"],
"-x",
std.toString($["claude-max-output-tokens"]),
"-t",
std.toString($["claude-temperature"]),
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local container =
engine.container("text-completion")
.with_image(images.trustgraph)
.with_command([
"text-completion-claude",
"-p",
url.pulsar,
"-k",
$["claude-key"],
"-x",
std.toString($["claude-max-output-tokens"]),
"-t",
std.toString($["claude-temperature"]),
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"text-completion", [ container ]
);
engine.resources([
containerSet,
])
"text-completion-rag": base + {
image: images.trustgraph,
command: [
"text-completion-claude",
"-p",
url.pulsar,
"-k",
$["claude-key"],
"-x",
std.toString($["claude-max-output-tokens"]),
"-t",
std.toString($["claude-temperature"]),
"-i",
"non-persistent://tg/request/text-completion-rag",
"-o",
"non-persistent://tg/response/text-completion-rag-response",
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
},
"text-completion-rag" +: {
create:: function(engine)
local container =
engine.container("text-completion-rag")
.with_image(images.trustgraph)
.with_command([
"text-completion-claude",
"-p",
url.pulsar,
"-k",
$["claude-key"],
"-x",
std.toString($["claude-max-output-tokens"]),
"-t",
std.toString($["claude-temperature"]),
"-i",
"non-persistent://tg/request/text-completion-rag",
"-o",
"non-persistent://tg/response/text-completion-rag-response",
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"text-completion-rag", [ container ]
);
engine.resources([
containerSet,
])
}
} + prompts

View file

@ -1,7 +1,8 @@
local base = import "base/base.jsonnet";
local images = import "values/images.jsonnet";
local url = import "values/url.jsonnet";
local prompts = import "prompts/cohere.jsonnet";
local prompts = import "prompts/mixtral.jsonnet";
{
// Override chunking
@ -11,61 +12,68 @@ local prompts = import "prompts/cohere.jsonnet";
"cohere-key":: "${COHERE_KEY}",
"cohere-temperature":: 0.0,
services +: {
"text-completion" +: {
create:: function(engine)
"text-completion": base + {
image: images.trustgraph,
command: [
"text-completion-cohere",
"-p",
url.pulsar,
"-k",
$["cohere-key"],
"-t",
$["cohere-temperature"],
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local container =
engine.container("text-completion")
.with_image(images.trustgraph)
.with_command([
"text-completion-cohere",
"-p",
url.pulsar,
"-k",
$["cohere-key"],
"-t",
$["cohere-temperature"],
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
"text-completion-rag": base + {
image: images.trustgraph,
command: [
"text-completion-cohere",
"-p",
url.pulsar,
"-k",
$["cohere-key"],
"-t",
$["cohere-temperature"],
"-i",
"non-persistent://tg/request/text-completion-rag",
"-o",
"non-persistent://tg/response/text-completion-rag-response",
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local containerSet = engine.containers(
"text-completion", [ container ]
);
engine.resources([
containerSet,
])
},
"text-completion-rag" +: {
create:: function(engine)
local container =
engine.container("text-completion-rag")
.with_image(images.trustgraph)
.with_command([
"text-completion-cohere",
"-p",
url.pulsar,
"-k",
$["cohere-key"],
"-t",
$["cohere-temperature"],
"-i",
"non-persistent://tg/request/text-completion-rag",
"-o",
"non-persistent://tg/response/text-completion-rag-response",
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"text-completion-rag", [ container ]
);
engine.resources([
containerSet,
])
}
} + prompts

View file

@ -1,38 +1,38 @@
local base = import "base/base.jsonnet";
local images = import "values/images.jsonnet";
local url = import "values/url.jsonnet";
local prompts = import "prompt-template.jsonnet";
local prompts = import "prompts/mixtral.jsonnet";
{
services +: {
"document-rag" +: {
create:: function(engine)
"document-rag": base + {
image: images.trustgraph,
command: [
"document-rag",
"-p",
url.pulsar,
"--prompt-request-queue",
"non-persistent://tg/request/prompt-rag",
"--prompt-response-queue",
"non-persistent://tg/response/prompt-rag-response",
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local container =
engine.container("document-rag"")
.with_image(images.trustgraph)
.with_command([
"document-rag",
"-p",
url.pulsar,
"--prompt-request-queue",
"non-persistent://tg/request/prompt-rag",
"--prompt-response-queue",
"non-persistent://tg/response/prompt-rag-response",
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
}
local containerSet = engine.containers(
"document-rag"", [ container ]
);
} + prompts
engine.resources([
containerSet,
])
},
}

View file

@ -1,40 +1,38 @@
local base = import "base/base.jsonnet";
local images = import "values/images.jsonnet";
local url = import "values/url.jsonnet";
local prompts = import "prompt-template.jsonnet";
local prompts = import "prompts/mixtral.jsonnet";
{
"embeddings-model":: "all-MiniLM-L6-v2",
services +: {
embeddings +: {
create:: function(engine)
embeddings: base + {
image: images.trustgraph,
command: [
"embeddings-hf",
"-p",
url.pulsar,
"-m",
$["embeddings-model"],
],
deploy: {
resources: {
limits: {
cpus: '1.0',
memory: '256M'
},
reservations: {
cpus: '0.5',
memory: '256M'
}
}
},
},
local container =
engine.container("embeddings")
.with_image(images.trustgraph)
.with_command([
"embeddings-hf",
"-p",
url.pulsar,
"-m",
$["embeddings-model"],
])
.with_limits("1.0", "256M")
.with_reservations("0.5", "256M");
}
local containerSet = engine.containers(
"embeddings", [ container ]
);
} + prompts
engine.resources([
containerSet,
])
},
}

View file

@ -1,65 +1,80 @@
local base = import "base/base.jsonnet";
local images = import "values/images.jsonnet";
{
volumes +: {
"prometheus-data": {},
"grafana-storage": {},
"prometheus" +: {
create:: function(engine)
local vol = engine.volume("prometheus-data").with_size("20G");
local cfgVol = engine.configVolume("./prometheus")
.with_size("20G");
local container =
engine.container("prometheus")
.with_image(images.prometheus)
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M")
.with_port(9090, 9090, "http")
.with_volume_mount(cfgVol, "/etc/prometheus")
.with_volume_mount(vol, "/prometheus");
local containerSet = engine.containers(
"prometheus", [ container ]
);
engine.resources([
cfgVol,
vol,
containerSet,
])
},
services +: {
prometheus: base + {
image: images.prometheus,
ports: [
"9090:9090",
],
volumes: [
"./prometheus:/etc/prometheus",
"prometheus-data:/prometheus",
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
grafana: base + {
image: images.grafana,
ports: [
"3000:3000",
],
volumes: [
"grafana-storage:/var/lib/grafana",
"./grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/dashboard.yml",
"./grafana/datasource.yml:/etc/grafana/provisioning/datasources/datasource.yml",
"./grafana/dashboard.json:/var/lib/grafana/dashboards/dashboard.json",
],
environment: {
// GF_AUTH_ANONYMOUS_ORG_ROLE: "Admin",
// GF_AUTH_ANONYMOUS_ENABLED: "true",
// GF_ORG_ROLE: "Admin",
GF_ORG_NAME: "trustgraph.ai",
// GF_SERVER_ROOT_URL: "https://example.com",
},
deploy: {
resources: {
limits: {
cpus: '1.0',
memory: '256M'
},
reservations: {
cpus: '0.5',
memory: '256M'
}
}
},
},
"grafana" +: {
create:: function(engine)
local vol = engine.volume("grafana-storage").with_size("20G");
local cv1 = engine.configVolume("./grafana/dashboard.yml")
.with_size("20G");
local cv2 = engine.configVolume("./grafana/datasource.yml")
.with_size("20G");
local cv3 = engine.configVolume("./grafana/dashboard.json")
.with_size("20G");
local container =
engine.container("grafana")
.with_image(images.grafana)
.with_environment({
// GF_AUTH_ANONYMOUS_ORG_ROLE: "Admin",
// GF_AUTH_ANONYMOUS_ENABLED: "true",
// GF_ORG_ROLE: "Admin",
GF_ORG_NAME: "trustgraph.ai",
// GF_SERVER_ROOT_URL: "https://example.com",
})
.with_limits("1.0", "256M")
.with_reservations("0.5", "256M")
.with_port(3000, 3000, "cassandra")
.with_volume_mount(vol, "/var/lib/grafana")
.with_volume_mount(cv1, "/etc/grafana/provisioning/dashboards/dashboard.yml")
.with_volume_mount(cv2, "/etc/grafana/provisioning/datasources/datasource.yml")
.with_volume_mount(cv3, "/var/lib/grafana/dashboards/dashboard.json");
local containerSet = engine.containers(
"grafana", [ container ]
);
engine.resources([
vol,
cv1,
cv2,
cv3,
containerSet,
])
},
}

View file

@ -1,7 +1,6 @@
local base = import "base/base.jsonnet";
local images = import "values/images.jsonnet";
local url = import "values/url.jsonnet";
local prompts = import "prompt-template.jsonnet";
{
@ -9,84 +8,90 @@ local prompts = import "prompt-template.jsonnet";
"graph-rag-triple-limit":: 30,
"graph-rag-max-subgraph-size":: 3000,
services +: {
"kg-extract-definitions" +: {
create:: function(engine)
"kg-extract-definitions": base + {
image: images.trustgraph,
command: [
"kg-extract-definitions",
"-p",
url.pulsar,
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local container =
engine.container("kg-extract-definitions")
.with_image(images.trustgraph)
.with_command([
"kg-extract-definitions",
"-p",
url.pulsar,
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
"kg-extract-relationships": base + {
image: images.trustgraph,
command: [
"kg-extract-relationships",
"-p",
url.pulsar,
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local containerSet = engine.containers(
"kg-extract-definitions", [ container ]
);
"graph-rag": base + {
image: images.trustgraph,
command: [
"graph-rag",
"-p",
url.pulsar,
"--prompt-request-queue",
"non-persistent://tg/request/prompt-rag",
"--prompt-response-queue",
"non-persistent://tg/response/prompt-rag-response",
"--entity-limit",
std.toString($["graph-rag-entity-limit"]),
"--triple-limit",
std.toString($["graph-rag-triple-limit"]),
"--max-subgraph-size",
std.toString($["graph-rag-max-subgraph-size"]),
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
engine.resources([
containerSet,
])
}
},
} + prompts
"kg-extract-relationships" +: {
create:: function(engine)
local container =
engine.container("kg-extract-relationships")
.with_image(images.trustgraph)
.with_command([
"kg-extract-relationships",
"-p",
url.pulsar,
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"kg-extract-relationships", [ container ]
);
engine.resources([
containerSet,
])
},
"graph-rag" +: {
create:: function(engine)
local container =
engine.container("graph-rag")
.with_image(images.trustgraph)
.with_command([
"graph-rag",
"-p",
url.pulsar,
"--prompt-request-queue",
"non-persistent://tg/request/prompt-rag",
"--prompt-response-queue",
"non-persistent://tg/response/prompt-rag-response",
"--entity-limit",
std.toString($["graph-rag-entity-limit"]),
"--triple-limit",
std.toString($["graph-rag-triple-limit"]),
"--max-subgraph-size",
std.toString($["graph-rag-max-subgraph-size"]),
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"graph-rag", [ container ]
);
engine.resources([
containerSet,
])
},
}

View file

@ -5,54 +5,62 @@ local neo4j = import "stores/neo4j.jsonnet";
neo4j + {
services +: {
"neo4j-url":: "bolt://neo4j:7687",
"query-triples": base + {
image: images.trustgraph,
command: [
"triples-query-neo4j",
"-p",
url.pulsar,
"-g",
"bolt://neo4j:7687",
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
"store-triples" +: {
create:: function(engine)
"store-triples": base + {
image: images.trustgraph,
command: [
"triples-write-neo4j",
"-p",
url.pulsar,
"-g",
"bolt://neo4j:7687",
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
}
local container =
engine.container("store-triples")
.with_image(images.trustgraph)
.with_command([
"triples-write-neo4j",
"-p",
url.pulsar,
"-g",
$["neo4j-url"],
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"store-triples", [ container ]
);
engine.resources([
containerSet,
])
},
"query-triples" +: {
create:: function(engine)
local container =
engine.container("query-triples")
.with_image(images.trustgraph)
.with_command([
"triples-query-neo4j",
"-p",
url.pulsar,
"-g",
$["neo4j-url"],
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"query-triples", [ container ]
);
engine.resources([
containerSet,
])
}
}

View file

@ -2,66 +2,74 @@ local base = import "base/base.jsonnet";
local images = import "values/images.jsonnet";
local url = import "values/url.jsonnet";
local prompts = import "prompts/slm.jsonnet";
{
"ollama-model":: "gemma2:9b",
"ollama-url":: "${OLLAMA_HOST}",
services +: {
"text-completion" +: {
create:: function(engine)
"text-completion": base + {
image: images.trustgraph,
command: [
"text-completion-ollama",
"-p",
url.pulsar,
"-m",
$["ollama-model"],
"-r",
$["ollama-url"],
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local container =
engine.container("text-completion")
.with_image(images.trustgraph)
.with_command([
"text-completion-ollama",
"-p",
url.pulsar,
"-m",
$["ollama-model"],
"-r",
$["ollama-url"],
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"text-completion", [ container ]
);
engine.resources([
containerSet,
])
"text-completion-rag": base + {
image: images.trustgraph,
command: [
"text-completion-ollama",
"-p",
url.pulsar,
"-m",
$["ollama-model"],
"-r",
$["ollama-url"],
"-i",
"non-persistent://tg/request/text-completion-rag",
"-o",
"non-persistent://tg/response/text-completion-rag-response",
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
},
"text-completion-rag" +: {
create:: function(engine)
local container =
engine.container("text-completion-rag")
.with_image(images.trustgraph)
.with_command([
"text-completion-ollama",
"-p",
url.pulsar,
"-m",
$["ollama-model"],
"-r",
$["ollama-url"],
"-i",
"non-persistent://tg/request/text-completion-rag",
"-o",
"non-persistent://tg/response/text-completion-rag-response",
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"text-completion-rag", [ container ]
);
engine.resources([
containerSet,
])
}
} + prompts

View file

@ -1,7 +1,8 @@
local base = import "base/base.jsonnet";
local images = import "values/images.jsonnet";
local url = import "values/url.jsonnet";
local prompts = import "prompts/openai.jsonnet";
local prompts = import "prompts/mixtral.jsonnet";
{
"openai-key":: "${OPENAI_KEY}",
@ -9,69 +10,76 @@ local prompts = import "prompts/openai.jsonnet";
"openai-temperature":: 0.0,
"openai-model":: "GPT-3.5-Turbo",
services +: {
"text-completion" +: {
create:: function(engine)
"text-completion": base + {
image: images.trustgraph,
command: [
"text-completion-openai",
"-p",
url.pulsar,
"-k",
$["openai-key"],
"-x",
std.toString($["openai-max-output-tokens"]),
"-t",
std.toString($["openai-temperature"]),
"-m",
$["openai-model"],
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local container =
engine.container("text-completion")
.with_image(images.trustgraph)
.with_command([
"text-completion-openai",
"-p",
url.pulsar,
"-k",
$["openai-key"],
"-x",
std.toString($["openai-max-output-tokens"]),
"-t",
std.toString($["openai-temperature"]),
"-m",
$["openai-model"],
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"text-completion", [ container ]
);
engine.resources([
containerSet,
])
"text-completion-rag": base + {
image: images.trustgraph,
command: [
"text-completion-openai",
"-p",
url.pulsar,
"-k",
$["openai-key"],
"-x",
std.toString($["openai-max-output-tokens"]),
"-t",
std.toString($["openai-temperature"]),
"-m",
$["openai-model"],
"-i",
"non-persistent://tg/request/text-completion-rag",
"-o",
"non-persistent://tg/response/text-completion-rag-response",
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
},
"text-completion-rag" +: {
create:: function(engine)
local container =
engine.container("text-completion-rag")
.with_image(images.trustgraph)
.with_command([
"text-completion-openai",
"-p",
url.pulsar,
"-k",
$["openai-key"],
"-x",
std.toString($["openai-max-output-tokens"]),
"-t",
std.toString($["openai-temperature"]),
"-m",
$["openai-model"],
"-i",
"non-persistent://tg/request/text-completion-rag",
"-o",
"non-persistent://tg/response/text-completion-rag-response",
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"text-completion-rag", [ container ]
);
engine.resources([
containerSet,
])
}
} + prompts

View file

@ -1,67 +1,71 @@
local base = import "base/base.jsonnet";
local images = import "values/images.jsonnet";
local url = import "values/url.jsonnet";
local prompts = import "prompts/mixtral.jsonnet";
{
services +: {
"prompt" +: {
create:: function(engine)
"prompt": base + {
image: images.trustgraph,
command: [
"prompt-generic",
"-p",
url.pulsar,
"--text-completion-request-queue",
"non-persistent://tg/request/text-completion",
"--text-completion-response-queue",
"non-persistent://tg/response/text-completion-response",
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local container =
engine.container("prompt")
.with_image(images.trustgraph)
.with_command([
"prompt-generic",
"-p",
url.pulsar,
"--text-completion-request-queue",
"non-persistent://tg/request/text-completion",
"--text-completion-response-queue",
"non-persistent://tg/response/text-completion-response",
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
"prompt-rag": base + {
image: images.trustgraph,
command: [
"prompt-generic",
"-p",
url.pulsar,
"-i",
"non-persistent://tg/request/prompt-rag",
"-o",
"non-persistent://tg/response/prompt-rag-response",
"--text-completion-request-queue",
"non-persistent://tg/request/text-completion-rag",
"--text-completion-response-queue",
"non-persistent://tg/response/text-completion-rag-response",
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local containerSet = engine.containers(
"prompt", [ container ]
);
}
engine.resources([
containerSet,
])
},
"prompt-rag" +: {
create:: function(engine)
local container =
engine.container("prompt-rag")
.with_image(images.trustgraph)
.with_command([
"prompt-generic",
"-p",
url.pulsar,
"-i",
"non-persistent://tg/request/prompt-rag",
"-o",
"non-persistent://tg/response/prompt-rag-response",
"--text-completion-request-queue",
"non-persistent://tg/request/text-completion-rag",
"--text-completion-response-queue",
"non-persistent://tg/response/text-completion-rag-response",
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"prompt-rag", [ container ]
);
engine.resources([
containerSet,
])
},
}

View file

@ -1,89 +1,92 @@
// For VertexAI Gemini
local base = import "base/base.jsonnet";
local images = import "values/images.jsonnet";
local url = import "values/url.jsonnet";
local prompts = import "prompts/mixtral.jsonnet";
local default_prompts = import "prompts/default-prompts.jsonnet";
default_prompts + {
{
services +: {
"prompt" +: {
create:: function(engine)
"prompt": base + {
image: images.trustgraph,
command: [
"prompt-template",
"-p",
url.pulsar,
"--text-completion-request-queue",
"non-persistent://tg/request/text-completion",
"--text-completion-response-queue",
"non-persistent://tg/response/text-completion-response",
"--definition-template",
$["prompt-definition-template"],
"--relationship-template",
$["prompt-relationship-template"],
"--knowledge-query-template",
$["prompt-knowledge-query-template"],
"--document-query-template",
$["prompt-document-query-template"],
"--rows-template",
$["prompt-rows-template"],
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local container =
engine.container("prompt")
.with_image(images.trustgraph)
.with_command([
"prompt-template",
"-p",
url.pulsar,
"--text-completion-request-queue",
"non-persistent://tg/request/text-completion",
"--text-completion-response-queue",
"non-persistent://tg/response/text-completion-response",
"--definition-template",
$["prompt-definition-template"],
"--relationship-template",
$["prompt-relationship-template"],
"--knowledge-query-template",
$["prompt-knowledge-query-template"],
"--document-query-template",
$["prompt-document-query-template"],
"--rows-template",
$["prompt-rows-template"],
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
"prompt-rag": base + {
image: images.trustgraph,
command: [
"prompt-template",
"-p",
url.pulsar,
"-i",
"non-persistent://tg/request/prompt-rag",
"-o",
"non-persistent://tg/response/prompt-rag-response",
"--text-completion-request-queue",
"non-persistent://tg/request/text-completion-rag",
"--text-completion-response-queue",
"non-persistent://tg/response/text-completion-rag-response",
"--definition-template",
$["prompt-definition-template"],
"--relationship-template",
$["prompt-relationship-template"],
"--knowledge-query-template",
$["prompt-knowledge-query-template"],
"--document-query-template",
$["prompt-document-query-template"],
"--rows-template",
$["prompt-rows-template"],
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local containerSet = engine.containers(
"prompt", [ container ]
);
engine.resources([
containerSet,
])
},
}
"prompt-rag" +: {
create:: function(engine)
local container =
engine.container("prompt-rag")
.with_image(images.trustgraph)
.with_command([
"prompt-template",
"-p",
url.pulsar,
"-i",
"non-persistent://tg/request/prompt-rag",
"-o",
"non-persistent://tg/response/prompt-rag-response",
"--text-completion-request-queue",
"non-persistent://tg/request/text-completion-rag",
"--text-completion-response-queue",
"non-persistent://tg/response/text-completion-rag-response",
"--definition-template",
$["prompt-definition-template"],
"--relationship-template",
$["prompt-relationship-template"],
"--knowledge-query-template",
$["prompt-knowledge-query-template"],
"--document-query-template",
$["prompt-document-query-template"],
"--rows-template",
$["prompt-rows-template"],
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"prompt-rag", [ container ]
);
engine.resources([
containerSet,
])
},
} + default_prompts

View file

@ -1,62 +1,62 @@
local base = import "base/base.jsonnet";
local images = import "values/images.jsonnet";
{
volumes +: {
"pulsar-conf": {},
"pulsar-data": {},
},
services +: {
pulsar: base + {
image: images.pulsar,
command: "bin/pulsar standalone",
ports: [
"6650:6650",
"8080:8080",
],
environment: {
"PULSAR_MEM": "-Xms700M -Xmx700M"
},
volumes: [
"pulsar-conf:/pulsar/conf",
"pulsar-data:/pulsar/data",
],
deploy: {
resources: {
limits: {
cpus: '1.0',
memory: '900M'
},
reservations: {
cpus: '0.5',
memory: '900M'
}
}
},
},
"init-pulsar": base + {
image: images.pulsar,
command: [
"sh",
"-c",
"pulsar-admin --admin-url http://pulsar:8080 tenants create tg && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/flow && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/request && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/response && pulsar-admin --admin-url http://pulsar:8080 namespaces set-retention --size -1 --time 3m tg/response",
],
depends_on: {
pulsar: {
condition: "service_started",
}
},
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
"pulsar" +: {
create:: function(engine)
local confVolume = engine.volume("pulsar-conf").with_size("2G");
local dataVolume = engine.volume("pulsar-data").with_size("20G");
local container =
engine.container("pulsar")
.with_image(images.pulsar)
.with_command("bin/pulsar standalone")
.with_environment({
"PULSAR_MEM": "-Xms700M -Xmx700M"
})
.with_limits("1.0", "900M")
.with_reservations("0.5", "900M")
.with_volume_mount(confVolume, "/pulsar/conf")
.with_volume_mount(dataVolume, "/pulsar/data")
.with_port(6650, 6650, "bookie")
.with_port(8080, 8080, "http");
local adminContainer =
engine.container("init-pulsar")
.with_image(images.pulsar)
.with_command([
"sh",
"-c",
"pulsar-admin --admin-url http://pulsar:8080 tenants create tg && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/flow && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/request && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/response && pulsar-admin --admin-url http://pulsar:8080 namespaces set-retention --size -1 --time 3m tg/response",
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"pulsar",
[
container, adminContainer
]
);
local service =
engine.service(containerSet)
.with_port(6650, 6650)
.with_port(8080, 8080);
engine.resources([
confVolume,
dataVolume,
containerSet,
service,
])
}
}

View file

@ -1,105 +1,117 @@
local base = import "base/base.jsonnet";
local images = import "values/images.jsonnet";
local url = import "values/url.jsonnet";
local cassandra_hosts = "cassandra";
local qdrant = import "stores/qdrant.jsonnet";
qdrant + {
services +: {
"store-graph-embeddings" +: {
create:: function(engine)
"store-graph-embeddings": base + {
image: images.trustgraph,
command: [
"ge-write-qdrant",
"-p",
url.pulsar,
"-t",
url.qdrant,
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local container =
engine.container("store-graph-embeddings")
.with_image(images.trustgraph)
.with_command([
"ge-write-qdrant",
"-p",
url.pulsar,
"-t",
url.qdrant,
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
"query-graph-embeddings": base + {
image: images.trustgraph,
command: [
"ge-query-qdrant",
"-p",
url.pulsar,
"-t",
url.qdrant,
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local containerSet = engine.containers(
"store-graph-embeddings", [ container ]
);
// Document embeddings writer & query service.
engine.resources([
containerSet,
])
"store-doc-embeddings": base + {
image: images.trustgraph,
command: [
"de-write-qdrant",
"-p",
url.pulsar,
"-t",
url.qdrant,
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
},
"query-graph-embeddings" +: {
create:: function(engine)
local container =
engine.container("query-graph-embeddings")
.with_image(images.trustgraph)
.with_command([
"ge-query-qdrant",
"-p",
url.pulsar,
"-t",
url.qdrant,
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"query-graph-embeddings", [ container ]
);
engine.resources([
containerSet,
])
},
"store-doc-embeddings" +: {
create:: function(engine)
local container =
engine.container("store-doc-embeddings")
.with_image(images.trustgraph)
.with_command([
"de-write-qdrant",
"-p",
url.pulsar,
"-t",
url.qdrant,
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"store-doc-embeddings", [ container ]
);
engine.resources([
containerSet,
])
},
"query-doc-embeddings" +: {
create:: function(engine)
local container =
engine.container("query-doc-embeddings")
.with_image(images.trustgraph)
.with_command([
"de-query-qdrant",
"-p",
url.pulsar,
"-t",
url.qdrant,
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"query-doc-embeddings", [ container ]
);
engine.resources([
containerSet,
])
"query-doc-embeddings": base + {
image: images.trustgraph,
command: [
"de-query-qdrant",
"-p",
url.pulsar,
"-t",
url.qdrant,
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
}

View file

@ -1,85 +1,91 @@
local base = import "base/base.jsonnet";
local images = import "values/images.jsonnet";
local url = import "values/url.jsonnet";
local prompts = import "prompt-template.jsonnet";
local prompt = import "prompt-template.jsonnet";
{
"chunk-size":: 250,
"chunk-overlap":: 15,
services +: {
"chunker" +: {
create:: function(engine)
"pdf-decoder": base + {
image: images.trustgraph,
command: [
"pdf-decoder",
"-p",
url.pulsar,
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local container =
engine.container("chunker")
.with_image(images.trustgraph)
.with_command([
"chunker-token",
"-p",
url.pulsar,
"--chunk-size",
std.toString($["chunk-size"]),
"--chunk-overlap",
std.toString($["chunk-overlap"]),
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
chunker: base + {
image: images.trustgraph,
command: [
"chunker-token",
"-p",
url.pulsar,
"--chunk-size",
std.toString($["chunk-size"]),
"--chunk-overlap",
std.toString($["chunk-overlap"]),
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local containerSet = engine.containers(
"chunker", [ container ]
);
vectorize: base + {
image: images.trustgraph,
command: [
"embeddings-vectorize",
"-p",
url.pulsar,
],
deploy: {
resources: {
limits: {
cpus: '1.0',
memory: '512M'
},
reservations: {
cpus: '0.5',
memory: '512M'
}
}
},
},
engine.resources([
containerSet,
])
}
},
} + prompts
"pdf-decoder" +: {
create:: function(engine)
local container =
engine.container("pdf-decoder")
.with_image(images.trustgraph)
.with_command([
"pdf-decoder",
"-p",
url.pulsar,
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
local containerSet = engine.containers(
"pdf-decoder", [ container ]
);
engine.resources([
containerSet,
])
},
"vectorize" +: {
create:: function(engine)
local container =
engine.container("vectorize")
.with_image(images.trustgraph)
.with_command([
"embeddings-vectorize",
"-p",
url.pulsar,
])
.with_limits("1.0", "512M")
.with_reservations("0.5", "512M");
local containerSet = engine.containers(
"vectorize", [ container ]
);
engine.resources([
containerSet,
])
},
} + prompt

View file

@ -1,7 +1,8 @@
local base = import "base/base.jsonnet";
local images = import "values/images.jsonnet";
local url = import "values/url.jsonnet";
local prompts = import "prompts/gemini.jsonnet";
local prompts = import "prompts/mixtral.jsonnet";
{
"vertexai-model":: "gemini-1.0-pro-001",
@ -10,80 +11,88 @@ local prompts = import "prompts/gemini.jsonnet";
"vertexai-max-output-tokens":: 4096,
"vertexai-temperature":: 0.0,
services +: {
"text-completion" +: {
create:: function(engine)
"text-completion": base + {
image: images.trustgraph,
command: [
"text-completion-vertexai",
"-p",
url.pulsar,
"-k",
$["vertexai-private-key"],
"-r",
$["vertexai-region"],
"-x",
std.toString($["vertexai-max-output-tokens"]),
"-t",
std.toString($["vertexai-temperature"]),
"-m",
$["vertexai-model"],
],
volumes: [
"./vertexai:/vertexai"
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local cfgVol = engine.configVolume("./vertexai");
"text-completion-rag": base + {
image: images.trustgraph,
command: [
"text-completion-vertexai",
"-p",
url.pulsar,
"-k",
$["vertexai-private-key"],
"-r",
$["vertexai-region"],
"-x",
std.toString($["vertexai-max-output-tokens"]),
"-t",
std.toString($["vertexai-temperature"]),
"-m",
$["vertexai-model"],
"-i",
"non-persistent://tg/request/text-completion-rag",
"-o",
"non-persistent://tg/response/text-completion-rag-response",
],
volumes: [
"./vertexai:/vertexai"
],
deploy: {
resources: {
limits: {
cpus: '0.5',
memory: '128M'
},
reservations: {
cpus: '0.1',
memory: '128M'
}
}
},
},
local container =
engine.container("text-completion")
.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",
std.toString($["vertexai-temperature"]),
"-m",
$["vertexai-model"],
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M")
.with_volume_mount(cfgVol, "/vertexai");
local containerSet = engine.containers(
"text-completion", [ container ]
);
engine.resources([
cfgVol,
containerSet,
])
},
"text-completion-rag" +: {
create:: function(engine)
local cfgVol = engine.configVolume("./vertexai");
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",
std.toString($["vertexai-temperature"]),
"-m",
$["vertexai-model"],
"-i",
"non-persistent://tg/request/text-completion-rag",
"-o",
"non-persistent://tg/response/text-completion-rag-response",
])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M")
.with_volume_mount(cfgVol, "/vertexai");
local containerSet = engine.containers(
"text-completion-rag", [ container ]
);
engine.resources([
cfgVol,
containerSet,
])
}
} + prompts

View file

@ -0,0 +1,20 @@
local engine = import "docker-compose.jsonnet";
local decode = import "decode-config.jsonnet";
local components = import "components.jsonnet";
// Import config
local config = import "config.json";
// Produce patterns from config
local patterns = decode(config);
// Extract resources usnig the engine
local resources = std.foldl(
function(state, p) state + p.create(engine),
std.objectValues(patterns),
{}
);
resources

View file

@ -0,0 +1,29 @@
local components = import "components.jsonnet";
local apply = function(p, components)
local component = components[p.name];
(component + {
with:: function(k, v) self + {
[k]:: v
},
with_params:: function(pars)
self + std.foldl(
function(obj, par) obj.with(par.key, par.value),
std.objectKeysValues(pars),
self
),
}).with_params(p.parameters);
local decode = function(config)
local add = function(state, c) state + apply(c, components);
local patterns = std.foldl(add, config, {});
patterns;
decode

View file

@ -0,0 +1,154 @@
{
container:: function(name)
{
local container = self,
name: name,
limits: {},
reservations: {},
ports: [],
volumes: [],
with_image:: function(x) self + { image: x },
with_command:: function(x) self + { command: x },
with_environment:: function(x) self + { environment: x },
with_limits:: function(c, m) self + { limits: { cpus: c, memory: m } },
with_reservations::
function(c, m) self + { reservations: { cpus: c, memory: m } },
with_volume_mount::
function(vol, mnt)
self + {
volumes: super.volumes + [{
volume: vol.name, mount: mnt
}]
},
with_port::
function(src, dest, name) self + {
ports: super.ports + [
{ src: src, dest: dest, name : name }
]
},
add:: function() {
services +: {
[container.name]: {
image: container.image,
deploy: {
resources: {
limits: container.limits,
reservations: container.reservations,
}
},
restart: "on-failure:100",
} +
(if std.objectHas(container, "command") then
{ command: container.command }
else {}) +
(if std.objectHas(container, "environment") then
{ environment: container.environment }
else {}) +
(if std.length(container.ports) > 0 then
{
ports: [
"%d:%d" % [port.src, port.dest]
for port in container.ports
]
}
else {}) +
(if std.length(container.volumes) > 0 then
{
volumes: [
"%s:%s" % [vol.volume, vol.mount]
for vol in container.volumes
]
}
else {})
}
}
},
service:: function(containers)
{
local service = self,
name: containers.name,
with_port:: function(src, dest) self + { port: [src, dest] },
add:: function() {
}
},
volume:: function(name)
{
local volume = self,
name: name,
with_size:: function(size) self + { size: size },
add:: function() {
volumes +: {
[volume.name]: {}
}
}
},
// FIXME: For K8s
configVolume:: function(name)
{
local volume = self,
name: name,
with_size:: function(size) self + { size: size },
add:: function() {
}
},
containers:: function(name, containers)
{
local cont = self,
name: name,
containers: containers,
add:: function() std.foldl(
function(state, c) state + c.add(),
cont.containers,
{}
),
},
resources:: function(res)
std.foldl(
function(state, c) state + c.add(),
res,
{}
),
}

View file

@ -1,30 +1,24 @@
local components = {
neo4j: import "components/neo4j.jsonnet",
cassandra: import "components/cassandra.jsonnet",
pulsar: import "components/pulsar.jsonnet",
milvus: import "components/milvus.jsonnet",
qdrant: import "components/qdrant.jsonnet",
grafana: import "components/grafana.jsonnet",
trustgraph: import "components/trustgraph.jsonnet",
azure: import "components/azure.jsonnet",
bedrock: import "components/bedrock.jsonnet",
cohere: import "components/cohere.jsonnet",
claude: import "components/claude.jsonnet",
ollama: import "components/ollama.jsonnet",
openai: import "components/openai.jsonnet",
mix: import "components/mix.jsonnet",
vertexai: import "components/vertexai.jsonnet",
"embeddings-hf": import "components/embeddings-hf.jsonnet",
"embeddings-ollama": import "components/embeddings-ollama.jsonnet",
"graph-rag": import "components/graph-rag.jsonnet",
"document-rag": import "components/document-rag.jsonnet",
};
local engine = import "docker-compose.jsonnet";
local decode = import "decode-config.jsonnet";
local components = import "components.jsonnet";
// Options
local options = std.split(std.extVar("options"), ",");
local add = function(state, name) state + components[name];
// Produce patterns from config
local patterns = std.foldl(
function(state, p) state + components[p],
options,
{}
);
local config = std.foldl(add, options, {});
// Extract resources usnig the engine
local resources = std.foldl(
function(state, p) state + p.create(engine),
std.objectValues(patterns),
{}
);
std.manifestYamlDoc(config)
std.manifestYamlDoc(resources)

View file

@ -1,35 +1,35 @@
local base = import "base/base.jsonnet";
local images = import "values/images.jsonnet";
{
volumes +: {
cassandra: {},
},
services +: {
cassandra: base + {
image: images.cassandra,
ports: [
"9042:9042"
],
environment: {
JVM_OPTS: "-Xms256M -Xmx256M",
},
volumes: [
"cassandra:/var/lib/cassandra"
],
deploy: {
resources: {
limits: {
cpus: '1.0',
memory: '800M'
},
reservations: {
cpus: '0.5',
memory: '800M'
}
}
},
},
"cassandra" +: {
create:: function(engine)
local vol = engine.volume("cassandra").with_size("20G");
local container =
engine.container("cassandra")
.with_image(images.cassandra)
.with_environment({
JVM_OPTS: "-Xms256M -Xmx256M",
})
.with_limits("1.0", "800M")
.with_reservations("0.5", "800M")
.with_port(9042, 9042, "cassandra")
.with_volume_mount(vol, "/var/lib/cassandra");
local containerSet = engine.containers(
"cassandra", [ container ]
);
engine.resources([
vol,
containerSet,
])
},
}

View file

@ -28,7 +28,11 @@ local images = import "values/images.jsonnet";
ETCD_SNAPSHOT_COUNT: "50000"
},
ports: [
"2379:2379",
{
src: 2379,
dest: 2379,
name: "api",
}
],
volumes: [
"etcd:/etcd"
@ -61,7 +65,11 @@ local images = import "values/images.jsonnet";
MINIO_ROOT_PASSWORD: "minioadmin",
},
ports: [
"9001:9001",
{
src: 9001,
dest: 9001,
name: "api",
}
],
volumes: [
"minio-data:/minio_data",
@ -90,8 +98,16 @@ local images = import "values/images.jsonnet";
MINIO_ADDRESS: "minio:9000",
},
ports: [
"9091:9091",
"19530:19530",
{
src: 9091,
dest: 9091,
name: "api",
},
{
src: 19530,
dest: 19530,
name: "api2",
}
],
volumes: [
"milvus:/var/lib/milvus"

View file

@ -1,42 +1,39 @@
local base = import "base/base.jsonnet";
local images = import "values/images.jsonnet";
{
volumes +: {
neo4j: {},
},
"neo4j" +: {
create:: function(engine)
services +: {
local vol = engine.volume("neo4j").with_size("20G");
neo4j: base + {
image: images.neo4j,
ports: [
"7474:7474",
"7687:7687",
],
environment: {
NEO4J_AUTH: "neo4j/password",
// NEO4J_server_bolt_listen__address: "0.0.0.0:7687",
// NEO4J_server_default__listen__address: "0.0.0.0",
// NEO4J_server_http_listen__address: "0.0.0.0:7474",
},
volumes: [
"neo4j:/data"
],
deploy: {
resources: {
limits: {
cpus: '1.0',
memory: '768M'
},
reservations: {
cpus: '0.5',
memory: '768M'
}
}
},
},
local container =
engine.container("neo4j")
.with_image(images.neo4j)
.with_environment({
NEO4J_AUTH: "neo4j/password",
// NEO4J_server_bolt_listen__address: "0.0.0.0:7687",
// NEO4J_server_default__listen__address: "0.0.0.0",
// NEO4J_server_http_listen__address: "0.0.0.0:7474",
})
.with_limits("1.0", "768M")
.with_reservations("0.5", "768M")
.with_port(7474, 7474, "api")
.with_port(7687, 7687, "api2")
.with_volume_mount(vol, "/data");
local containerSet = engine.containers(
"neo4j", [ container ]
);
engine.resources([
vol,
containerSet,
])
},
}

View file

@ -3,35 +3,31 @@ local images = import "values/images.jsonnet";
{
volumes +: {
qdrant: {},
},
"qdrant" +: {
create:: function(engine)
services +: {
local vol = engine.volume("qdrant").with_size("20G");
qdrant: base + {
image: images.qdrant,
ports: [
"6333:6333",
"6334:6334",
],
volumes: [
"qdrant:/qdrant/storage"
],
deploy: {
resources: {
limits: {
cpus: '1.0',
memory: '256M'
},
reservations: {
cpus: '0.5',
memory: '256M'
}
}
},
},
local container =
engine.container("qdrant")
.with_image(images.qdrant)
.with_limits("1.0", "256M")
.with_reservations("0.5", "256M")
.with_port(6333, 6333, "api")
.with_port(6334, 6334, "api2")
.with_volume_mount(vol, "/qdrant/storage");
local containerSet = engine.containers(
"qdrant", [ container ]
);
engine.resources([
vol,
containerSet,
])
},
}

View file

@ -102,9 +102,6 @@
- "sh"
- "-c"
- "pulsar-admin --admin-url http://pulsar:8080 tenants create tg && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/flow && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/request && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/response && pulsar-admin --admin-url http://pulsar:8080 namespaces set-retention --size -1 --time 3m tg/response"
"depends_on":
"pulsar":
"condition": "service_started"
"deploy":
"resources":
"limits":
@ -436,11 +433,11 @@
- "${AZURE_TOKEN}"
- "-e"
- "${AZURE_ENDPOINT}"
- "-i"
- "-x"
- "4096"
- "-t"
- "0"
- "-i"
- "non-persistent://tg/request/text-completion-rag"
- "-o"
- "non-persistent://tg/response/text-completion-rag-response"

View file

@ -85,9 +85,6 @@
- "sh"
- "-c"
- "pulsar-admin --admin-url http://pulsar:8080 tenants create tg && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/flow && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/request && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/response && pulsar-admin --admin-url http://pulsar:8080 namespaces set-retention --size -1 --time 3m tg/response"
"depends_on":
"pulsar":
"condition": "service_started"
"deploy":
"resources":
"limits":
@ -437,11 +434,11 @@
- "${AZURE_TOKEN}"
- "-e"
- "${AZURE_ENDPOINT}"
- "-i"
- "-x"
- "4096"
- "-t"
- "0"
- "-i"
- "non-persistent://tg/request/text-completion-rag"
- "-o"
- "non-persistent://tg/response/text-completion-rag-response"

View file

@ -102,9 +102,6 @@
- "sh"
- "-c"
- "pulsar-admin --admin-url http://pulsar:8080 tenants create tg && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/flow && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/request && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/response && pulsar-admin --admin-url http://pulsar:8080 namespaces set-retention --size -1 --time 3m tg/response"
"depends_on":
"pulsar":
"condition": "service_started"
"deploy":
"resources":
"limits":

View file

@ -85,9 +85,6 @@
- "sh"
- "-c"
- "pulsar-admin --admin-url http://pulsar:8080 tenants create tg && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/flow && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/request && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/response && pulsar-admin --admin-url http://pulsar:8080 namespaces set-retention --size -1 --time 3m tg/response"
"depends_on":
"pulsar":
"condition": "service_started"
"deploy":
"resources":
"limits":

View file

@ -102,9 +102,6 @@
- "sh"
- "-c"
- "pulsar-admin --admin-url http://pulsar:8080 tenants create tg && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/flow && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/request && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/response && pulsar-admin --admin-url http://pulsar:8080 namespaces set-retention --size -1 --time 3m tg/response"
"depends_on":
"pulsar":
"condition": "service_started"
"deploy":
"resources":
"limits":

View file

@ -85,9 +85,6 @@
- "sh"
- "-c"
- "pulsar-admin --admin-url http://pulsar:8080 tenants create tg && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/flow && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/request && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/response && pulsar-admin --admin-url http://pulsar:8080 namespaces set-retention --size -1 --time 3m tg/response"
"depends_on":
"pulsar":
"condition": "service_started"
"deploy":
"resources":
"limits":

View file

@ -102,9 +102,6 @@
- "sh"
- "-c"
- "pulsar-admin --admin-url http://pulsar:8080 tenants create tg && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/flow && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/request && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/response && pulsar-admin --admin-url http://pulsar:8080 namespaces set-retention --size -1 --time 3m tg/response"
"depends_on":
"pulsar":
"condition": "service_started"
"deploy":
"resources":
"limits":

View file

@ -85,9 +85,6 @@
- "sh"
- "-c"
- "pulsar-admin --admin-url http://pulsar:8080 tenants create tg && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/flow && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/request && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/response && pulsar-admin --admin-url http://pulsar:8080 namespaces set-retention --size -1 --time 3m tg/response"
"depends_on":
"pulsar":
"condition": "service_started"
"deploy":
"resources":
"limits":

View file

@ -102,9 +102,6 @@
- "sh"
- "-c"
- "pulsar-admin --admin-url http://pulsar:8080 tenants create tg && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/flow && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/request && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/response && pulsar-admin --admin-url http://pulsar:8080 namespaces set-retention --size -1 --time 3m tg/response"
"depends_on":
"pulsar":
"condition": "service_started"
"deploy":
"resources":
"limits":

View file

@ -85,9 +85,6 @@
- "sh"
- "-c"
- "pulsar-admin --admin-url http://pulsar:8080 tenants create tg && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/flow && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/request && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/response && pulsar-admin --admin-url http://pulsar:8080 namespaces set-retention --size -1 --time 3m tg/response"
"depends_on":
"pulsar":
"condition": "service_started"
"deploy":
"resources":
"limits":

View file

@ -102,9 +102,6 @@
- "sh"
- "-c"
- "pulsar-admin --admin-url http://pulsar:8080 tenants create tg && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/flow && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/request && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/response && pulsar-admin --admin-url http://pulsar:8080 namespaces set-retention --size -1 --time 3m tg/response"
"depends_on":
"pulsar":
"condition": "service_started"
"deploy":
"resources":
"limits":

View file

@ -85,9 +85,6 @@
- "sh"
- "-c"
- "pulsar-admin --admin-url http://pulsar:8080 tenants create tg && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/flow && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/request && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/response && pulsar-admin --admin-url http://pulsar:8080 namespaces set-retention --size -1 --time 3m tg/response"
"depends_on":
"pulsar":
"condition": "service_started"
"deploy":
"resources":
"limits":

View file

@ -102,9 +102,6 @@
- "sh"
- "-c"
- "pulsar-admin --admin-url http://pulsar:8080 tenants create tg && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/flow && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/request && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/response && pulsar-admin --admin-url http://pulsar:8080 namespaces set-retention --size -1 --time 3m tg/response"
"depends_on":
"pulsar":
"condition": "service_started"
"deploy":
"resources":
"limits":

View file

@ -85,9 +85,6 @@
- "sh"
- "-c"
- "pulsar-admin --admin-url http://pulsar:8080 tenants create tg && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/flow && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/request && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/response && pulsar-admin --admin-url http://pulsar:8080 namespaces set-retention --size -1 --time 3m tg/response"
"depends_on":
"pulsar":
"condition": "service_started"
"deploy":
"resources":
"limits":

View file

@ -41,9 +41,6 @@
- "sh"
- "-c"
- "pulsar-admin --admin-url http://pulsar:8080 tenants create tg && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/flow && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/request && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/response && pulsar-admin --admin-url http://pulsar:8080 namespaces set-retention --size -1 --time 3m tg/response"
"depends_on":
"pulsar":
"condition": "service_started"
"deploy":
"resources":
"limits":

View file

@ -24,9 +24,6 @@
- "sh"
- "-c"
- "pulsar-admin --admin-url http://pulsar:8080 tenants create tg && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/flow && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/request && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/response && pulsar-admin --admin-url http://pulsar:8080 namespaces set-retention --size -1 --time 3m tg/response"
"depends_on":
"pulsar":
"condition": "service_started"
"deploy":
"resources":
"limits":