From 966f47b46f150d62e2f0683d6dfd2ac0b4f90c43 Mon Sep 17 00:00:00 2001 From: Cyber MacGeddon Date: Sat, 22 Mar 2025 00:26:00 +0000 Subject: [PATCH] - Template updates for pdf-ocr - Template updates for pdf-ocr-mistral --- .gitignore | 1 + templates/components.jsonnet | 4 ++ templates/components/mistral-ocr.jsonnet | 47 ++++++++++++++++++++++++ templates/components/ocr.jsonnet | 38 +++++++++++++++++++ templates/values/images.jsonnet | 1 + 5 files changed, 91 insertions(+) create mode 100644 templates/components/mistral-ocr.jsonnet create mode 100644 templates/components/ocr.jsonnet diff --git a/.gitignore b/.gitignore index 357ecf1e..4d089211 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ trustgraph-base/trustgraph/base_version.py trustgraph-bedrock/trustgraph/bedrock_version.py trustgraph-embeddings-hf/trustgraph/embeddings_hf_version.py trustgraph-flow/trustgraph/flow_version.py +trustgraph-ocr/trustgraph/ocr_version.py trustgraph-parquet/trustgraph/parquet_version.py trustgraph-vertexai/trustgraph/vertexai_version.py trustgraph-cli/trustgraph/ diff --git a/templates/components.jsonnet b/templates/components.jsonnet index 121bd6a5..d0df569f 100644 --- a/templates/components.jsonnet +++ b/templates/components.jsonnet @@ -37,6 +37,10 @@ "graph-rag": import "components/graph-rag.jsonnet", "document-rag": import "components/document-rag.jsonnet", + // OCR options + "ocr": import "components/ocr.jsonnet", + "mistral-ocr": import "components/mistral-ocr.jsonnet", + // Librarian - document management "librarian": import "components/librarian.jsonnet", diff --git a/templates/components/mistral-ocr.jsonnet b/templates/components/mistral-ocr.jsonnet new file mode 100644 index 00000000..8049c514 --- /dev/null +++ b/templates/components/mistral-ocr.jsonnet @@ -0,0 +1,47 @@ +local images = import "values/images.jsonnet"; +local url = import "values/url.jsonnet"; + +{ + + with:: function(key, value) + self + { + ["mistral-" + key]:: value, + }, + + "pdf-decoder" +: { + + create:: function(engine) + + local envSecrets = engine.envSecrets("mistral-credentials") + .with_env_var("MISTRAL_TOKEN", "mistral-token"); + + local container = + engine.container("mistral-ocr") + .with_image(images.trustgraph_flow) + .with_command([ + "pdf-ocr-mistral", + "-p", + url.pulsar, + ]) + .with_env_var_secrets(envSecrets) + .with_limits("0.5", "128M") + .with_reservations("0.1", "128M"); + + local containerSet = engine.containers( + "mistral-ocr", [ container ] + ); + + local service = + engine.internalService(containerSet) + .with_port(8080, 8080, "metrics"); + + engine.resources([ + envSecrets, + containerSet, + service, + ]) + + }, + +} + prompts + diff --git a/templates/components/ocr.jsonnet b/templates/components/ocr.jsonnet new file mode 100644 index 00000000..4353b7f9 --- /dev/null +++ b/templates/components/ocr.jsonnet @@ -0,0 +1,38 @@ +local images = import "values/images.jsonnet"; +local url = import "values/url.jsonnet"; + +{ + + "pdf-decoder" +: { + + create:: function(engine) + + local container = + engine.container("pdf-ocr") + .with_image(images.trustgraph_ocr) + .with_command([ + "pdf-ocr", + "-p", + url.pulsar, + ]) + .with_limits("1.0", "512M") + .with_reservations("0.1", "512M"); + + local containerSet = engine.containers( + "pdf-ocr", [ container ] + ); + + local service = + engine.internalService(containerSet) + .with_port(8080, 8080, "metrics"); + + engine.resources([ + envSecrets, + containerSet, + service, + ]) + + }, + +} + prompts + diff --git a/templates/values/images.jsonnet b/templates/values/images.jsonnet index dde235ce..54dbd016 100644 --- a/templates/values/images.jsonnet +++ b/templates/values/images.jsonnet @@ -11,6 +11,7 @@ local version = import "version.jsonnet"; grafana: "docker.io/grafana/grafana:11.1.4", trustgraph_base: "docker.io/trustgraph/trustgraph-base:" + version, trustgraph_flow: "docker.io/trustgraph/trustgraph-flow:" + version, + trustgraph_ocr: "docker.io/trustgraph/trustgraph-ocr:" + version, trustgraph_bedrock: "docker.io/trustgraph/trustgraph-bedrock:" + version, trustgraph_vertexai: "docker.io/trustgraph/trustgraph-vertexai:" + version, trustgraph_hf: "docker.io/trustgraph/trustgraph-hf:" + version,