diff --git a/Containerfile b/Containerfile index 1c22ebf5..0c5562e4 100644 --- a/Containerfile +++ b/Containerfile @@ -13,7 +13,7 @@ RUN dnf install -y python3 python3-pip python3-wheel python3-aiohttp \ RUN pip3 install torch --index-url https://download.pytorch.org/whl/cpu -RUN pip3 install anthropic boto3 cohere google-cloud-aiplatform langchain langchain-core \ +RUN pip3 install anthropic boto3 cohere openai google-cloud-aiplatform langchain langchain-core \ langchain-huggingface langchain-text-splitters langchain-community \ pymilvus sentence-transformers transformers huggingface-hub \ pulsar-client && \ diff --git a/Makefile b/Makefile index 89d1bd9a..821ce4df 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # VERSION=$(shell git describe | sed 's/^v//') -VERSION=0.5.8 +VERSION=0.5.9 all: container diff --git a/docker-compose-azure.yaml b/docker-compose-azure.yaml index bf41fd16..203f4b26 100644 --- a/docker-compose-azure.yaml +++ b/docker-compose-azure.yaml @@ -130,7 +130,7 @@ services: restart: on-failure:100 pdf-decoder: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "pdf-decoder" - "-p" @@ -138,7 +138,7 @@ services: restart: on-failure:100 chunker: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "chunker-recursive" - "-p" @@ -146,7 +146,7 @@ services: restart: on-failure:100 vectorize: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "embeddings-vectorize" - "-p" @@ -154,7 +154,7 @@ services: restart: on-failure:100 embeddings: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "embeddings-hf" - "-p" @@ -164,7 +164,7 @@ services: restart: on-failure:100 kg-extract-definitions: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "kg-extract-definitions" - "-p" @@ -172,7 +172,7 @@ services: restart: on-failure:100 kg-extract-relationships: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "kg-extract-relationships" - "-p" @@ -180,7 +180,7 @@ services: restart: on-failure:100 store-graph-embeddings: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "ge-write-milvus" - "-p" @@ -190,7 +190,7 @@ services: restart: on-failure:100 store-triples: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "triples-write-cassandra" - "-p" @@ -200,7 +200,7 @@ services: restart: on-failure:100 text-completion: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "text-completion-azure" - "-p" @@ -212,7 +212,7 @@ services: restart: on-failure:100 text-completion-rag: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "text-completion-azure" - "-p" @@ -228,7 +228,7 @@ services: restart: on-failure:100 graph-rag: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "graph-rag" - "-p" diff --git a/docker-compose-bedrock.yaml b/docker-compose-bedrock.yaml index 8ffbf047..0eedfd22 100644 --- a/docker-compose-bedrock.yaml +++ b/docker-compose-bedrock.yaml @@ -130,7 +130,7 @@ services: restart: on-failure:100 pdf-decoder: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "pdf-decoder" - "-p" @@ -138,7 +138,7 @@ services: restart: on-failure:100 chunker: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "chunker-recursive" - "-p" @@ -150,7 +150,7 @@ services: restart: on-failure:100 vectorize: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "embeddings-vectorize" - "-p" @@ -158,7 +158,7 @@ services: restart: on-failure:100 embeddings: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "embeddings-hf" - "-p" @@ -168,7 +168,7 @@ services: restart: on-failure:100 kg-extract-definitions: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "kg-extract-definitions" - "-p" @@ -176,7 +176,7 @@ services: restart: on-failure:100 kg-extract-relationships: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "kg-extract-relationships" - "-p" @@ -184,7 +184,7 @@ services: restart: on-failure:100 store-graph-embeddings: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "ge-write-milvus" - "-p" @@ -194,7 +194,7 @@ services: restart: on-failure:100 store-triples: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "triples-write-cassandra" - "-p" @@ -204,7 +204,7 @@ services: restart: on-failure:100 text-completion: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "text-completion-bedrock" - "-p" @@ -218,7 +218,7 @@ services: restart: on-failure:100 text-completion-rag: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "text-completion-bedrock" - "-p" @@ -238,7 +238,7 @@ services: restart: on-failure:100 #text-completion-rag: - # image: docker.io/trustgraph/trustgraph-flow:0.5.8 + # image: docker.io/trustgraph/trustgraph-flow:0.5.9 # command: # - "text-completion-ollama" # - "-p" @@ -254,7 +254,7 @@ services: # restart: on-failure:100 graph-rag: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "graph-rag" - "-p" diff --git a/docker-compose-claude.yaml b/docker-compose-claude.yaml index 98603a3f..1eaaae12 100644 --- a/docker-compose-claude.yaml +++ b/docker-compose-claude.yaml @@ -130,7 +130,7 @@ services: restart: on-failure:100 pdf-decoder: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "pdf-decoder" - "-p" @@ -138,7 +138,7 @@ services: restart: on-failure:100 chunker: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "chunker-recursive" - "-p" @@ -146,7 +146,7 @@ services: restart: on-failure:100 vectorize: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "embeddings-vectorize" - "-p" @@ -154,7 +154,7 @@ services: restart: on-failure:100 embeddings: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "embeddings-hf" - "-p" @@ -164,7 +164,7 @@ services: restart: on-failure:100 kg-extract-definitions: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "kg-extract-definitions" - "-p" @@ -172,7 +172,7 @@ services: restart: on-failure:100 kg-extract-relationships: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "kg-extract-relationships" - "-p" @@ -180,7 +180,7 @@ services: restart: on-failure:100 store-graph-embeddings: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "ge-write-milvus" - "-p" @@ -190,7 +190,7 @@ services: restart: on-failure:100 store-triples: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "triples-write-cassandra" - "-p" @@ -200,7 +200,7 @@ services: restart: on-failure:100 text-completion: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "text-completion-claude" - "-p" @@ -210,7 +210,7 @@ services: restart: on-failure:100 text-completion-rag: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "text-completion-ollama" - "-p" @@ -224,7 +224,7 @@ services: restart: on-failure:100 graph-rag: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "graph-rag" - "-p" diff --git a/docker-compose-cohere.yaml b/docker-compose-cohere.yaml index 24dfd10f..b52f67d7 100644 --- a/docker-compose-cohere.yaml +++ b/docker-compose-cohere.yaml @@ -130,7 +130,7 @@ services: restart: on-failure:100 pdf-decoder: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "pdf-decoder" - "-p" @@ -138,7 +138,7 @@ services: restart: on-failure:100 chunker: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "chunker-recursive" - "-p" @@ -150,7 +150,7 @@ services: restart: on-failure:100 vectorize: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "embeddings-vectorize" - "-p" @@ -158,7 +158,7 @@ services: restart: on-failure:100 embeddings: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "embeddings-hf" - "-p" @@ -168,7 +168,7 @@ services: restart: on-failure:100 kg-extract-definitions: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "kg-extract-definitions" - "-p" @@ -176,7 +176,7 @@ services: restart: on-failure:100 kg-extract-relationships: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "kg-extract-relationships" - "-p" @@ -184,7 +184,7 @@ services: restart: on-failure:100 store-graph-embeddings: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "ge-write-milvus" - "-p" @@ -194,7 +194,7 @@ services: restart: on-failure:100 store-triples: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "triples-write-cassandra" - "-p" @@ -204,7 +204,7 @@ services: restart: on-failure:100 text-completion: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "text-completion-cohere" - "-p" @@ -214,7 +214,7 @@ services: restart: on-failure:100 graph-rag: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "graph-rag" - "-p" diff --git a/docker-compose-mix.yaml b/docker-compose-mix.yaml index 4e4090f8..34e94d8c 100644 --- a/docker-compose-mix.yaml +++ b/docker-compose-mix.yaml @@ -130,7 +130,7 @@ services: restart: on-failure:100 pdf-decoder: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "pdf-decoder" - "-p" @@ -138,7 +138,7 @@ services: restart: on-failure:100 chunker: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "chunker-recursive" - "-p" @@ -150,7 +150,7 @@ services: restart: on-failure:100 vectorize: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "embeddings-vectorize" - "-p" @@ -158,7 +158,7 @@ services: restart: on-failure:100 embeddings: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "embeddings-hf" - "-p" @@ -168,7 +168,7 @@ services: restart: on-failure:100 kg-extract-definitions: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "kg-extract-definitions" - "-p" @@ -176,7 +176,7 @@ services: restart: on-failure:100 kg-extract-relationships: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "kg-extract-relationships" - "-p" @@ -184,7 +184,7 @@ services: restart: on-failure:100 store-graph-embeddings: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "ge-write-milvus" - "-p" @@ -194,7 +194,7 @@ services: restart: on-failure:100 store-triples: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "triples-write-cassandra" - "-p" @@ -204,7 +204,7 @@ services: restart: on-failure:100 text-completion: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "text-completion-cohere" - "-p" @@ -216,7 +216,7 @@ services: restart: on-failure:100 text-completion-rag: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "text-completion-cohere" - "-p" @@ -232,7 +232,7 @@ services: restart: on-failure:100 #text-completion-rag: - # image: docker.io/trustgraph/trustgraph-flow:0.5.8 + # image: docker.io/trustgraph/trustgraph-flow:0.5.9 # command: # - "text-completion-ollama" # - "-p" @@ -248,7 +248,7 @@ services: # restart: on-failure:100 graph-rag: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "graph-rag" - "-p" diff --git a/docker-compose-ollama.yaml b/docker-compose-ollama.yaml index b2658370..ba078f6a 100644 --- a/docker-compose-ollama.yaml +++ b/docker-compose-ollama.yaml @@ -130,7 +130,7 @@ services: restart: on-failure:100 pdf-decoder: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "pdf-decoder" - "-p" @@ -138,7 +138,7 @@ services: restart: on-failure:100 chunker: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "chunker-recursive" - "-p" @@ -146,7 +146,7 @@ services: restart: on-failure:100 vectorize: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "embeddings-vectorize" - "-p" @@ -154,7 +154,7 @@ services: restart: on-failure:100 embeddings: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "embeddings-hf" - "-p" @@ -164,7 +164,7 @@ services: restart: on-failure:100 kg-extract-definitions: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "kg-extract-definitions" - "-p" @@ -172,7 +172,7 @@ services: restart: on-failure:100 kg-extract-relationships: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "kg-extract-relationships" - "-p" @@ -180,7 +180,7 @@ services: restart: on-failure:100 store-graph-embeddings: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "ge-write-milvus" - "-p" @@ -190,7 +190,7 @@ services: restart: on-failure:100 store-triples: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "triples-write-cassandra" - "-p" @@ -200,7 +200,7 @@ services: restart: on-failure:100 text-completion: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "text-completion-ollama" - "-p" @@ -212,7 +212,7 @@ services: restart: on-failure:100 text-completion-rag: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "text-completion-ollama" - "-p" @@ -228,7 +228,7 @@ services: restart: on-failure:100 graph-rag: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "graph-rag" - "-p" diff --git a/docker-compose-openai.yaml b/docker-compose-openai.yaml new file mode 100644 index 00000000..78435f8b --- /dev/null +++ b/docker-compose-openai.yaml @@ -0,0 +1,236 @@ + +volumes: + cassandra: + pulsar-conf: + pulsar-data: + etcd: + minio-data: + milvus: + prometheus-data: + grafana-storage: + +services: + + cassandra: + image: docker.io/cassandra:4.1.5 + ports: + - "9042:9042" + volumes: + - "cassandra:/var/lib/cassandra" + restart: on-failure:100 + + pulsar: + image: docker.io/apachepulsar/pulsar:3.3.0 + command: bin/pulsar standalone + ports: + - "6650:6650" + - "8080:8080" + volumes: + - "pulsar-conf:/pulsar/conf" + - "pulsar-data:/pulsar/data" + restart: on-failure:100 + + init-pulsar: + image: docker.io/apachepulsar/pulsar:3.3.0 + 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 + restart: on-failure:100 + + pulsar-manager: + image: docker.io/apachepulsar/pulsar-manager:v0.3.0 + ports: + - "9527:9527" + - "7750:7750" + environment: + SPRING_CONFIGURATION_FILE: /pulsar-manager/pulsar-manager/application.properties + restart: on-failure:100 + + etcd: + image: quay.io/coreos/etcd:v3.5.5 + command: + - "etcd" + - "-advertise-client-urls=http://127.0.0.1:2379" + - "-listen-client-urls" + - "http://0.0.0.0:2379" + - "--data-dir" + - "/etcd" + environment: + ETCD_AUTO_COMPACTION_MODE: revision + ETCD_AUTO_COMPACTION_RETENTION: "1000" + ETCD_QUOTA_BACKEND_BYTES: "4294967296" + ETCD_SNAPSHOT_COUNT: "50000" + ports: + - "2379:2379" + volumes: + - "etcd:/etcd" + restart: on-failure:100 + + minio: + image: docker.io/minio/minio:RELEASE.2024-07-04T14-25-45Z + command: + - "minio" + - "server" + - "/minio_data" + - "--console-address" + - ":9001" + environment: + MINIO_ROOT_USER: minioadmin + MINIO_ROOT_PASSWORD: minioadmin + ports: + - "9001:9001" + volumes: + - "minio-data:/minio_data" + restart: on-failure:100 + + milvus: + image: docker.io/milvusdb/milvus:v2.4.5 + command: + - "milvus" + - "run" + - "standalone" + environment: + ETCD_ENDPOINTS: etcd:2379 + MINIO_ADDRESS: minio:9000 + ports: + - "9091:9091" + - "19530:19530" + volumes: + - "milvus:/var/lib/milvus" + restart: on-failure:100 + + prometheus: + image: docker.io/prom/prometheus:v2.53.1 + ports: + - "9090:9090" + volumes: + - "./prometheus:/etc/prometheus" + - "prometheus-data:/prometheus" + restart: on-failure:100 + + grafana: + image: docker.io/grafana/grafana:10.0.0 + 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 + restart: on-failure:100 + + pdf-decoder: + image: docker.io/trustgraph/trustgraph-flow:0.5.9 + command: + - "pdf-decoder" + - "-p" + - "pulsar://pulsar:6650" + restart: on-failure:100 + + chunker: + image: docker.io/trustgraph/trustgraph-flow:0.5.9 + command: + - "chunker-recursive" + - "-p" + - "pulsar://pulsar:6650" + restart: on-failure:100 + + vectorize: + image: docker.io/trustgraph/trustgraph-flow:0.5.9 + command: + - "embeddings-vectorize" + - "-p" + - "pulsar://pulsar:6650" + restart: on-failure:100 + + embeddings: + image: docker.io/trustgraph/trustgraph-flow:0.5.9 + command: + - "embeddings-hf" + - "-p" + - "pulsar://pulsar:6650" +# - "-m" +# - "mixedbread-ai/mxbai-embed-large-v1" + restart: on-failure:100 + + kg-extract-definitions: + image: docker.io/trustgraph/trustgraph-flow:0.5.9 + command: + - "kg-extract-definitions" + - "-p" + - "pulsar://pulsar:6650" + restart: on-failure:100 + + kg-extract-relationships: + image: docker.io/trustgraph/trustgraph-flow:0.5.9 + command: + - "kg-extract-relationships" + - "-p" + - "pulsar://pulsar:6650" + restart: on-failure:100 + + store-graph-embeddings: + image: docker.io/trustgraph/trustgraph-flow:0.5.9 + command: + - "ge-write-milvus" + - "-p" + - "pulsar://pulsar:6650" + - "-t" + - "http://milvus:19530" + restart: on-failure:100 + + store-triples: + image: docker.io/trustgraph/trustgraph-flow:0.5.9 + command: + - "triples-write-cassandra" + - "-p" + - "pulsar://pulsar:6650" + - "-g" + - "cassandra" + restart: on-failure:100 + + text-completion: + image: docker.io/trustgraph/trustgraph-flow:0.5.9 + command: + - "text-completion-openai" + - "-p" + - "pulsar://pulsar:6650" + - "-k" + - ${OPENAI_KEY} + restart: on-failure:100 + + text-completion-rag: + image: docker.io/trustgraph/trustgraph-flow:0.5.9 + command: + - "text-completion-openai" + - "-p" + - "pulsar://pulsar:6650" + - "-k" + - ${OPENAI_KEY} + - "-i" + - "non-persistent://tg/request/text-completion-rag" + - "-o" + - "non-persistent://tg/response/text-completion-rag-response" + restart: on-failure:100 + + graph-rag: + image: docker.io/trustgraph/trustgraph-flow:0.5.9 + command: + - "graph-rag" + - "-p" + - "pulsar://pulsar:6650" + - "--text-completion-request-queue" + - "non-persistent://tg/request/text-completion-rag" + - "--text-completion-response-queue" + - "non-persistent://tg/response/text-completion-rag-response" + restart: on-failure:100 diff --git a/docker-compose-vertexai.yaml b/docker-compose-vertexai.yaml index c08c8394..2a51120d 100644 --- a/docker-compose-vertexai.yaml +++ b/docker-compose-vertexai.yaml @@ -130,7 +130,7 @@ services: restart: on-failure:100 pdf-decoder: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "pdf-decoder" - "-p" @@ -138,7 +138,7 @@ services: restart: on-failure:100 chunker: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "chunker-recursive" - "-p" @@ -146,7 +146,7 @@ services: restart: on-failure:100 vectorize: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "embeddings-vectorize" - "-p" @@ -154,7 +154,7 @@ services: restart: on-failure:100 embeddings: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "embeddings-hf" - "-p" @@ -164,7 +164,7 @@ services: restart: on-failure:100 kg-extract-definitions: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "kg-extract-definitions" - "-p" @@ -172,7 +172,7 @@ services: restart: on-failure:100 kg-extract-relationships: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "kg-extract-relationships" - "-p" @@ -180,7 +180,7 @@ services: restart: on-failure:100 store-graph-embeddings: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "ge-write-milvus" - "-p" @@ -190,7 +190,7 @@ services: restart: on-failure:100 store-triples: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "triples-write-cassandra" - "-p" @@ -200,7 +200,7 @@ services: restart: on-failure:100 text-completion: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "text-completion-vertexai" - "-p" @@ -214,7 +214,7 @@ services: restart: on-failure:100 text-completion-rag: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "text-completion-vertexai" - "-p" @@ -230,7 +230,7 @@ services: restart: on-failure:100 graph-rag: - image: docker.io/trustgraph/trustgraph-flow:0.5.8 + image: docker.io/trustgraph/trustgraph-flow:0.5.9 command: - "graph-rag" - "-p" diff --git a/scripts/text-completion-openai b/scripts/text-completion-openai new file mode 100755 index 00000000..665080c1 --- /dev/null +++ b/scripts/text-completion-openai @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 + +from trustgraph.model.text_completion.openai import run + +run() + diff --git a/setup.py b/setup.py index 5055c0e0..1230d377 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ import os with open("README.md", "r") as fh: long_description = fh.read() -version = "0.5.8" +version = "0.5.9" setuptools.setup( name="trustgraph", @@ -47,6 +47,7 @@ setuptools.setup( "pyarrow", "cohere", "boto3", + "openai", ], scripts=[ "scripts/chunker-recursive", @@ -73,6 +74,7 @@ setuptools.setup( "scripts/text-completion-bedrock", "scripts/text-completion-claude", "scripts/text-completion-ollama", + "scripts/text-completion-openai", "scripts/text-completion-vertexai", "scripts/text-completion-cohere", "scripts/triples-dump-parquet", diff --git a/trustgraph/model/text_completion/openai/__init__.py b/trustgraph/model/text_completion/openai/__init__.py new file mode 100644 index 00000000..f2017af8 --- /dev/null +++ b/trustgraph/model/text_completion/openai/__init__.py @@ -0,0 +1,3 @@ + +from . llm import * + diff --git a/trustgraph/model/text_completion/openai/__main__.py b/trustgraph/model/text_completion/openai/__main__.py new file mode 100755 index 00000000..91342d2d --- /dev/null +++ b/trustgraph/model/text_completion/openai/__main__.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 + +from . llm import run + +if __name__ == '__main__': + run() + diff --git a/trustgraph/model/text_completion/openai/llm.py b/trustgraph/model/text_completion/openai/llm.py new file mode 100755 index 00000000..44226bbd --- /dev/null +++ b/trustgraph/model/text_completion/openai/llm.py @@ -0,0 +1,114 @@ + +""" +Simple LLM service, performs text prompt completion using OpenAI. +Input is prompt, output is response. +""" + +from openai import OpenAI + +from .... schema import TextCompletionRequest, TextCompletionResponse +from .... schema import text_completion_request_queue +from .... schema import text_completion_response_queue +from .... log_level import LogLevel +from .... base import ConsumerProducer + +module = ".".join(__name__.split(".")[1:-1]) + +default_input_queue = text_completion_request_queue +default_output_queue = text_completion_response_queue +default_subscriber = module +default_model = 'gpt-3.5-turbo' + +class Processor(ConsumerProducer): + + def __init__(self, **params): + + input_queue = params.get("input_queue", default_input_queue) + output_queue = params.get("output_queue", default_output_queue) + subscriber = params.get("subscriber", default_subscriber) + model = params.get("model", default_model) + api_key = params.get("api_key") + + super(Processor, self).__init__( + **params | { + "input_queue": input_queue, + "output_queue": output_queue, + "subscriber": subscriber, + "input_schema": TextCompletionRequest, + "output_schema": TextCompletionResponse, + "model": model, + } + ) + + self.model = model + + self.openai = OpenAI(api_key=api_key) + + print("Initialised", flush=True) + + def handle(self, msg): + + v = msg.value() + + # Sender-produced ID + + id = msg.properties()["id"] + + print(f"Handling prompt {id}...", flush=True) + + prompt = v.prompt + resp = self.openai.chat.completions.create( + model=self.model, + messages=[ + { + "role": "user", + "content": [ + { + "type": "text", + "text": prompt + } + ] + } + ], + temperature=0, + max_tokens=4096, + top_p=1, + frequency_penalty=0, + presence_penalty=0, + response_format={ + "type": "text" + } + ) + + print(resp.choices[0].message.content, flush=True) + + print("Send response...", flush=True) + r = TextCompletionResponse(response=resp.choices[0].message.content) + self.send(r, properties={"id": id}) + + print("Done.", flush=True) + + @staticmethod + def add_args(parser): + + ConsumerProducer.add_args( + parser, default_input_queue, default_subscriber, + default_output_queue, + ) + + parser.add_argument( + '-m', '--model', + default="gpt-3.5-turbo", + help=f'LLM model (default: GPT-3.5-Turbo)' + ) + + parser.add_argument( + '-k', '--api-key', + help=f'OpenAI API key' + ) + +def run(): + + Processor.start(module, __doc__) + +