trustgraph-flow 0.16.4__tar.gz → 0.16.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/PKG-INFO +2 -2
- trustgraph-flow-0.16.6/scripts/ge-query-pinecone +6 -0
- trustgraph-flow-0.16.6/scripts/ge-write-pinecone +6 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/setup.py +3 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/api/gateway/service.py +290 -4
- trustgraph-flow-0.16.6/trustgraph/flow_version.py +1 -0
- trustgraph-flow-0.16.6/trustgraph/query/doc_embeddings/pinecone/service.py +142 -0
- trustgraph-flow-0.16.6/trustgraph/query/graph_embeddings/pinecone/service.py +156 -0
- trustgraph-flow-0.16.6/trustgraph/query/triples/cassandra/__init__.py +3 -0
- trustgraph-flow-0.16.6/trustgraph/query/triples/cassandra/__main__.py +7 -0
- trustgraph-flow-0.16.6/trustgraph/query/triples/neo4j/__init__.py +3 -0
- trustgraph-flow-0.16.6/trustgraph/query/triples/neo4j/__main__.py +7 -0
- trustgraph-flow-0.16.6/trustgraph/storage/doc_embeddings/pinecone/write.py +167 -0
- {trustgraph-flow-0.16.4/trustgraph/storage/graph_embeddings/milvus → trustgraph-flow-0.16.6/trustgraph/storage/doc_embeddings/qdrant}/__main__.py +0 -0
- trustgraph-flow-0.16.6/trustgraph/storage/graph_embeddings/pinecone/write.py +167 -0
- trustgraph-flow-0.16.6/trustgraph/storage/triples/cassandra/__init__.py +3 -0
- trustgraph-flow-0.16.6/trustgraph/storage/triples/cassandra/__main__.py +7 -0
- trustgraph-flow-0.16.6/trustgraph/storage/triples/neo4j/__init__.py +3 -0
- trustgraph-flow-0.16.6/trustgraph/storage/triples/neo4j/__main__.py +7 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph_flow.egg-info/PKG-INFO +2 -2
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph_flow.egg-info/SOURCES.txt +14 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph_flow.egg-info/requires.txt +1 -0
- trustgraph-flow-0.16.4/trustgraph/flow_version.py +0 -1
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/README.md +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/agent-manager-react +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/api-gateway +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/chunker-recursive +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/chunker-token +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/de-query-milvus +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/de-query-qdrant +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/de-write-milvus +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/de-write-qdrant +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/document-rag +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/embeddings-ollama +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/embeddings-vectorize +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/ge-query-milvus +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/ge-query-qdrant +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/ge-write-milvus +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/ge-write-qdrant +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/graph-rag +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/kg-extract-definitions +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/kg-extract-relationships +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/kg-extract-topics +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/metering +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/object-extract-row +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/oe-write-milvus +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/pdf-decoder +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/prompt-generic +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/prompt-template +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/rows-write-cassandra +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/run-processing +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/text-completion-azure +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/text-completion-azure-openai +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/text-completion-claude +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/text-completion-cohere +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/text-completion-googleaistudio +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/text-completion-llamafile +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/text-completion-ollama +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/text-completion-openai +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/triples-query-cassandra +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/triples-query-neo4j +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/triples-write-cassandra +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/scripts/triples-write-neo4j +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/setup.cfg +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/agent/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/agent/react/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/agent/react/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/agent/react/agent_manager.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/agent/react/service.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/agent/react/tools.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/agent/react/types.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/api/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/api/gateway/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/api/gateway/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/chunking/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/chunking/recursive/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/chunking/recursive/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/chunking/recursive/chunker.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/chunking/token/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/chunking/token/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/chunking/token/chunker.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/decoding/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/decoding/pdf/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/decoding/pdf/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/decoding/pdf/pdf_decoder.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/direct/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/direct/cassandra.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/direct/milvus_doc_embeddings.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/direct/milvus_graph_embeddings.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/direct/milvus_object_embeddings.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/document_rag.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/embeddings/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/embeddings/ollama/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/embeddings/ollama/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/embeddings/ollama/processor.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/embeddings/vectorize/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/embeddings/vectorize/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/embeddings/vectorize/vectorize.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/extract/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/extract/kg/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/extract/kg/definitions/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/extract/kg/definitions/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/extract/kg/definitions/extract.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/extract/kg/relationships/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/extract/kg/relationships/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/extract/kg/relationships/extract.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/extract/kg/topics/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/extract/kg/topics/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/extract/kg/topics/extract.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/extract/object/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/extract/object/row/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/extract/object/row/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/extract/object/row/extract.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/graph_rag.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/metering/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/metering/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/metering/counter.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/metering/pricelist.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/prompt/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/prompt/generic/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/prompt/generic/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/prompt/generic/prompts.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/prompt/generic/service.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/prompt/template/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/prompt/template/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/prompt/template/prompt_manager.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/prompt/template/service.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/azure/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/azure/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/azure/llm.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/azure_openai/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/azure_openai/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/azure_openai/llm.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/claude/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/claude/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/claude/llm.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/cohere/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/cohere/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/cohere/llm.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/googleaistudio/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/googleaistudio/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/googleaistudio/llm.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/llamafile/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/llamafile/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/llamafile/llm.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/ollama/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/ollama/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/ollama/llm.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/openai/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/openai/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/model/text_completion/openai/llm.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/processing/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/processing/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/processing/processing.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/query/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/query/doc_embeddings/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/query/doc_embeddings/milvus/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/query/doc_embeddings/milvus/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/query/doc_embeddings/milvus/service.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/query/doc_embeddings/qdrant → trustgraph-flow-0.16.6/trustgraph/query/doc_embeddings/pinecone}/__init__.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/query/doc_embeddings/qdrant → trustgraph-flow-0.16.6/trustgraph/query/doc_embeddings/pinecone}/__main__.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/query/graph_embeddings/milvus → trustgraph-flow-0.16.6/trustgraph/query/doc_embeddings/qdrant}/__init__.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/query/graph_embeddings/milvus → trustgraph-flow-0.16.6/trustgraph/query/doc_embeddings/qdrant}/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/query/doc_embeddings/qdrant/service.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/query/graph_embeddings/__init__.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/query/graph_embeddings/qdrant → trustgraph-flow-0.16.6/trustgraph/query/graph_embeddings/milvus}/__init__.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/query/graph_embeddings/qdrant → trustgraph-flow-0.16.6/trustgraph/query/graph_embeddings/milvus}/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/query/graph_embeddings/milvus/service.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/query/triples/cassandra → trustgraph-flow-0.16.6/trustgraph/query/graph_embeddings/pinecone}/__init__.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/query/triples/cassandra → trustgraph-flow-0.16.6/trustgraph/query/graph_embeddings/pinecone}/__main__.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/query/triples/neo4j → trustgraph-flow-0.16.6/trustgraph/query/graph_embeddings/qdrant}/__init__.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/query/triples/neo4j → trustgraph-flow-0.16.6/trustgraph/query/graph_embeddings/qdrant}/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/query/graph_embeddings/qdrant/service.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/query/triples/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/query/triples/cassandra/service.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/query/triples/neo4j/service.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/retrieval/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/retrieval/document_rag/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/retrieval/document_rag/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/retrieval/document_rag/rag.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/retrieval/graph_rag/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/retrieval/graph_rag/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/retrieval/graph_rag/rag.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/storage/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/storage/doc_embeddings/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/storage/doc_embeddings/milvus/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/storage/doc_embeddings/milvus/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/storage/doc_embeddings/milvus/write.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/storage/doc_embeddings/qdrant → trustgraph-flow-0.16.6/trustgraph/storage/doc_embeddings/pinecone}/__init__.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/storage/doc_embeddings/qdrant → trustgraph-flow-0.16.6/trustgraph/storage/doc_embeddings/pinecone}/__main__.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/storage/graph_embeddings/milvus → trustgraph-flow-0.16.6/trustgraph/storage/doc_embeddings/qdrant}/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/storage/doc_embeddings/qdrant/write.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/storage/graph_embeddings/__init__.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/storage/graph_embeddings/qdrant → trustgraph-flow-0.16.6/trustgraph/storage/graph_embeddings/milvus}/__init__.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/storage/graph_embeddings/qdrant → trustgraph-flow-0.16.6/trustgraph/storage/graph_embeddings/milvus}/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/storage/graph_embeddings/milvus/write.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/storage/object_embeddings/milvus → trustgraph-flow-0.16.6/trustgraph/storage/graph_embeddings/pinecone}/__init__.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/storage/object_embeddings/milvus → trustgraph-flow-0.16.6/trustgraph/storage/graph_embeddings/pinecone}/__main__.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/storage/rows/cassandra → trustgraph-flow-0.16.6/trustgraph/storage/graph_embeddings/qdrant}/__init__.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/storage/rows/cassandra → trustgraph-flow-0.16.6/trustgraph/storage/graph_embeddings/qdrant}/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/storage/graph_embeddings/qdrant/write.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/storage/object_embeddings/__init__.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/storage/triples/cassandra → trustgraph-flow-0.16.6/trustgraph/storage/object_embeddings/milvus}/__init__.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/storage/triples/cassandra → trustgraph-flow-0.16.6/trustgraph/storage/object_embeddings/milvus}/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/storage/object_embeddings/milvus/write.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/storage/rows/__init__.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/storage/triples/neo4j → trustgraph-flow-0.16.6/trustgraph/storage/rows/cassandra}/__init__.py +0 -0
- {trustgraph-flow-0.16.4/trustgraph/storage/triples/neo4j → trustgraph-flow-0.16.6/trustgraph/storage/rows/cassandra}/__main__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/storage/rows/cassandra/write.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/storage/triples/__init__.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/storage/triples/cassandra/write.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph/storage/triples/neo4j/write.py +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph_flow.egg-info/dependency_links.txt +0 -0
- {trustgraph-flow-0.16.4 → trustgraph-flow-0.16.6}/trustgraph_flow.egg-info/top_level.txt +0 -0
@@ -1,12 +1,12 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: trustgraph-flow
|
3
|
-
Version: 0.16.
|
3
|
+
Version: 0.16.6
|
4
4
|
Summary: TrustGraph provides a means to run a pipeline of flexible AI processing components in a flexible means to achieve a processing pipeline.
|
5
5
|
Home-page: https://github.com/trustgraph-ai/trustgraph
|
6
6
|
Author: trustgraph.ai
|
7
7
|
Author-email: security@trustgraph.ai
|
8
8
|
License: UNKNOWN
|
9
|
-
Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.16.
|
9
|
+
Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.16.6.tar.gz
|
10
10
|
Platform: UNKNOWN
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
12
12
|
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
@@ -60,6 +60,7 @@ setuptools.setup(
|
|
60
60
|
"jsonschema",
|
61
61
|
"aiohttp",
|
62
62
|
"aiopulsar-py",
|
63
|
+
"pinecone[grpc]",
|
63
64
|
],
|
64
65
|
scripts=[
|
65
66
|
"scripts/api-gateway",
|
@@ -74,8 +75,10 @@ setuptools.setup(
|
|
74
75
|
"scripts/embeddings-ollama",
|
75
76
|
"scripts/embeddings-vectorize",
|
76
77
|
"scripts/ge-query-milvus",
|
78
|
+
"scripts/ge-query-pinecone",
|
77
79
|
"scripts/ge-query-qdrant",
|
78
80
|
"scripts/ge-write-milvus",
|
81
|
+
"scripts/ge-write-pinecone",
|
79
82
|
"scripts/ge-write-qdrant",
|
80
83
|
"scripts/graph-rag",
|
81
84
|
"scripts/kg-extract-definitions",
|
@@ -14,7 +14,7 @@ module = ".".join(__name__.split(".")[1:-1])
|
|
14
14
|
|
15
15
|
import asyncio
|
16
16
|
import argparse
|
17
|
-
from aiohttp import web
|
17
|
+
from aiohttp import web, WSMsgType
|
18
18
|
import json
|
19
19
|
import logging
|
20
20
|
import uuid
|
@@ -47,9 +47,13 @@ from ... schema import GraphRagQuery, GraphRagResponse
|
|
47
47
|
from ... schema import graph_rag_request_queue
|
48
48
|
from ... schema import graph_rag_response_queue
|
49
49
|
|
50
|
-
from ... schema import TriplesQueryRequest, TriplesQueryResponse
|
50
|
+
from ... schema import TriplesQueryRequest, TriplesQueryResponse, Triples
|
51
51
|
from ... schema import triples_request_queue
|
52
52
|
from ... schema import triples_response_queue
|
53
|
+
from ... schema import triples_store_queue
|
54
|
+
|
55
|
+
from ... schema import GraphEmbeddings
|
56
|
+
from ... schema import graph_embeddings_store_queue
|
53
57
|
|
54
58
|
from ... schema import AgentRequest, AgentResponse
|
55
59
|
from ... schema import agent_request_queue
|
@@ -84,6 +88,11 @@ def to_subgraph(x):
|
|
84
88
|
for t in x
|
85
89
|
]
|
86
90
|
|
91
|
+
class Running:
|
92
|
+
def __init__(self): self.running = True
|
93
|
+
def get(self): return self.running
|
94
|
+
def stop(self): self.running = False
|
95
|
+
|
87
96
|
class Publisher:
|
88
97
|
|
89
98
|
def __init__(self, pulsar_host, topic, schema=None, max_size=10,
|
@@ -132,6 +141,7 @@ class Subscriber:
|
|
132
141
|
self.consumer_name = consumer_name
|
133
142
|
self.schema = schema
|
134
143
|
self.q = {}
|
144
|
+
self.full = {}
|
135
145
|
|
136
146
|
async def run(self):
|
137
147
|
while True:
|
@@ -145,10 +155,19 @@ class Subscriber:
|
|
145
155
|
) as consumer:
|
146
156
|
while True:
|
147
157
|
msg = await consumer.receive()
|
148
|
-
|
158
|
+
|
159
|
+
try:
|
160
|
+
id = msg.properties()["id"]
|
161
|
+
except:
|
162
|
+
id = None
|
163
|
+
|
149
164
|
value = msg.value()
|
150
165
|
if id in self.q:
|
151
166
|
await self.q[id].put(value)
|
167
|
+
|
168
|
+
for q in self.full.values():
|
169
|
+
await q.put(value)
|
170
|
+
|
152
171
|
except Exception as e:
|
153
172
|
print("Exception:", e, flush=True)
|
154
173
|
|
@@ -164,6 +183,59 @@ class Subscriber:
|
|
164
183
|
if id in self.q:
|
165
184
|
del self.q[id]
|
166
185
|
|
186
|
+
async def subscribe_all(self, id):
|
187
|
+
q = asyncio.Queue()
|
188
|
+
self.full[id] = q
|
189
|
+
return q
|
190
|
+
|
191
|
+
async def unsubscribe_all(self, id):
|
192
|
+
if id in self.full:
|
193
|
+
del self.full[id]
|
194
|
+
|
195
|
+
def serialize_triples(message):
|
196
|
+
return {
|
197
|
+
"metadata": {
|
198
|
+
"id": message.metadata.id,
|
199
|
+
"metadata": [
|
200
|
+
{
|
201
|
+
"s": t.s.value,
|
202
|
+
"p": t.p.value,
|
203
|
+
"o": t.o.value,
|
204
|
+
}
|
205
|
+
for t in message.metadata.metadata
|
206
|
+
],
|
207
|
+
"user": message.metadata.user,
|
208
|
+
"collection": message.metadata.collection,
|
209
|
+
},
|
210
|
+
"triples": [
|
211
|
+
{
|
212
|
+
"s": t.s.value,
|
213
|
+
"p": t.p.value,
|
214
|
+
"o": t.o.value,
|
215
|
+
}
|
216
|
+
for t in message.triples
|
217
|
+
]
|
218
|
+
}
|
219
|
+
|
220
|
+
def serialize_graph_embeddings(message):
|
221
|
+
return {
|
222
|
+
"metadata": {
|
223
|
+
"id": message.metadata.id,
|
224
|
+
"metadata": [
|
225
|
+
{
|
226
|
+
"s": t.s.value,
|
227
|
+
"p": t.p.value,
|
228
|
+
"o": t.o.value,
|
229
|
+
}
|
230
|
+
for t in message.metadata.metadata
|
231
|
+
],
|
232
|
+
"user": message.metadata.user,
|
233
|
+
"collection": message.metadata.collection,
|
234
|
+
},
|
235
|
+
"vectors": message.vectors,
|
236
|
+
"entity": message.entity.value,
|
237
|
+
}
|
238
|
+
|
167
239
|
class Api:
|
168
240
|
|
169
241
|
def __init__(self, **config):
|
@@ -243,6 +315,28 @@ class Api:
|
|
243
315
|
JsonSchema(EmbeddingsResponse)
|
244
316
|
)
|
245
317
|
|
318
|
+
self.triples_tap = Subscriber(
|
319
|
+
self.pulsar_host, triples_store_queue,
|
320
|
+
"api-gateway", "api-gateway",
|
321
|
+
schema=JsonSchema(Triples)
|
322
|
+
)
|
323
|
+
|
324
|
+
self.triples_pub = Publisher(
|
325
|
+
self.pulsar_host, triples_store_queue,
|
326
|
+
schema=JsonSchema(Triples)
|
327
|
+
)
|
328
|
+
|
329
|
+
self.graph_embeddings_tap = Subscriber(
|
330
|
+
self.pulsar_host, graph_embeddings_store_queue,
|
331
|
+
"api-gateway", "api-gateway",
|
332
|
+
schema=JsonSchema(GraphEmbeddings)
|
333
|
+
)
|
334
|
+
|
335
|
+
self.graph_embeddings_pub = Publisher(
|
336
|
+
self.pulsar_host, graph_embeddings_store_queue,
|
337
|
+
schema=JsonSchema(GraphEmbeddings)
|
338
|
+
)
|
339
|
+
|
246
340
|
self.document_out = Publisher(
|
247
341
|
self.pulsar_host, document_ingest_queue,
|
248
342
|
schema=JsonSchema(Document),
|
@@ -264,6 +358,20 @@ class Api:
|
|
264
358
|
web.post("/api/v1/embeddings", self.embeddings),
|
265
359
|
web.post("/api/v1/load/document", self.load_document),
|
266
360
|
web.post("/api/v1/load/text", self.load_text),
|
361
|
+
web.get("/api/v1/ws", self.socket),
|
362
|
+
|
363
|
+
web.get("/api/v1/stream/triples", self.stream_triples),
|
364
|
+
web.get(
|
365
|
+
"/api/v1/stream/graph-embeddings",
|
366
|
+
self.stream_graph_embeddings
|
367
|
+
),
|
368
|
+
|
369
|
+
web.get("/api/v1/load/triples", self.load_triples),
|
370
|
+
web.get(
|
371
|
+
"/api/v1/load/graph-embeddings",
|
372
|
+
self.load_graph_embeddings
|
373
|
+
),
|
374
|
+
|
267
375
|
])
|
268
376
|
|
269
377
|
async def llm(self, request):
|
@@ -660,6 +768,169 @@ class Api:
|
|
660
768
|
{ "error": str(e) }
|
661
769
|
)
|
662
770
|
|
771
|
+
async def socket(self, request):
|
772
|
+
|
773
|
+
ws = web.WebSocketResponse()
|
774
|
+
await ws.prepare(request)
|
775
|
+
|
776
|
+
async for msg in ws:
|
777
|
+
if msg.type == WSMsgType.TEXT:
|
778
|
+
if msg.data == 'close':
|
779
|
+
await ws.close()
|
780
|
+
else:
|
781
|
+
await ws.send_str(msg.data + '/answer')
|
782
|
+
elif msg.type == WSMsgType.ERROR:
|
783
|
+
print('ws connection closed with exception %s' %
|
784
|
+
ws.exception())
|
785
|
+
|
786
|
+
print('websocket connection closed')
|
787
|
+
|
788
|
+
return ws
|
789
|
+
|
790
|
+
async def stream(self, q, ws, running, fn):
|
791
|
+
|
792
|
+
while running.get():
|
793
|
+
try:
|
794
|
+
resp = await asyncio.wait_for(q.get(), 0.5)
|
795
|
+
await ws.send_json(fn(resp))
|
796
|
+
|
797
|
+
except TimeoutError:
|
798
|
+
continue
|
799
|
+
|
800
|
+
except Exception as e:
|
801
|
+
print(f"Exception: {str(e)}", flush=True)
|
802
|
+
|
803
|
+
async def stream_triples(self, request):
|
804
|
+
|
805
|
+
id = str(uuid.uuid4())
|
806
|
+
|
807
|
+
q = await self.triples_tap.subscribe_all(id)
|
808
|
+
running = Running()
|
809
|
+
|
810
|
+
ws = web.WebSocketResponse()
|
811
|
+
await ws.prepare(request)
|
812
|
+
|
813
|
+
tsk = asyncio.create_task(self.stream(
|
814
|
+
q,
|
815
|
+
ws,
|
816
|
+
running,
|
817
|
+
serialize_triples,
|
818
|
+
))
|
819
|
+
|
820
|
+
async for msg in ws:
|
821
|
+
if msg.type == WSMsgType.ERROR:
|
822
|
+
break
|
823
|
+
else:
|
824
|
+
# Ignore incoming messages
|
825
|
+
pass
|
826
|
+
|
827
|
+
running.stop()
|
828
|
+
|
829
|
+
await self.triples_tap.unsubscribe_all(id)
|
830
|
+
await tsk
|
831
|
+
|
832
|
+
return ws
|
833
|
+
|
834
|
+
async def stream_graph_embeddings(self, request):
|
835
|
+
|
836
|
+
id = str(uuid.uuid4())
|
837
|
+
|
838
|
+
q = await self.graph_embeddings_tap.subscribe_all(id)
|
839
|
+
running = Running()
|
840
|
+
|
841
|
+
ws = web.WebSocketResponse()
|
842
|
+
await ws.prepare(request)
|
843
|
+
|
844
|
+
tsk = asyncio.create_task(self.stream(
|
845
|
+
q,
|
846
|
+
ws,
|
847
|
+
running,
|
848
|
+
serialize_graph_embeddings,
|
849
|
+
))
|
850
|
+
|
851
|
+
async for msg in ws:
|
852
|
+
if msg.type == WSMsgType.ERROR:
|
853
|
+
break
|
854
|
+
else:
|
855
|
+
# Ignore incoming messages
|
856
|
+
pass
|
857
|
+
|
858
|
+
running.stop()
|
859
|
+
|
860
|
+
await self.graph_embeddings_tap.unsubscribe_all(id)
|
861
|
+
await tsk
|
862
|
+
|
863
|
+
return ws
|
864
|
+
|
865
|
+
async def load_triples(self, request):
|
866
|
+
|
867
|
+
ws = web.WebSocketResponse()
|
868
|
+
await ws.prepare(request)
|
869
|
+
|
870
|
+
async for msg in ws:
|
871
|
+
|
872
|
+
try:
|
873
|
+
|
874
|
+
if msg.type == WSMsgType.TEXT:
|
875
|
+
|
876
|
+
data = msg.json()
|
877
|
+
|
878
|
+
elt = Triples(
|
879
|
+
metadata=Metadata(
|
880
|
+
id=data["metadata"]["id"],
|
881
|
+
metadata=to_subgraph(data["metadata"]["metadata"]),
|
882
|
+
user=data["metadata"]["user"],
|
883
|
+
collection=data["metadata"]["collection"],
|
884
|
+
),
|
885
|
+
triples=to_subgraph(data["triples"]),
|
886
|
+
)
|
887
|
+
|
888
|
+
await self.triples_pub.send(None, elt)
|
889
|
+
|
890
|
+
elif msg.type == WSMsgType.ERROR:
|
891
|
+
break
|
892
|
+
|
893
|
+
except Exception as e:
|
894
|
+
|
895
|
+
print("Exception:", e)
|
896
|
+
|
897
|
+
return ws
|
898
|
+
|
899
|
+
async def load_graph_embeddings(self, request):
|
900
|
+
|
901
|
+
ws = web.WebSocketResponse()
|
902
|
+
await ws.prepare(request)
|
903
|
+
|
904
|
+
async for msg in ws:
|
905
|
+
|
906
|
+
try:
|
907
|
+
|
908
|
+
if msg.type == WSMsgType.TEXT:
|
909
|
+
|
910
|
+
data = msg.json()
|
911
|
+
|
912
|
+
elt = GraphEmbeddings(
|
913
|
+
metadata=Metadata(
|
914
|
+
id=data["metadata"]["id"],
|
915
|
+
metadata=to_subgraph(data["metadata"]["metadata"]),
|
916
|
+
user=data["metadata"]["user"],
|
917
|
+
collection=data["metadata"]["collection"],
|
918
|
+
),
|
919
|
+
entity=to_value(data["entity"]),
|
920
|
+
vectors=data["vectors"],
|
921
|
+
)
|
922
|
+
|
923
|
+
await self.graph_embeddings_pub.send(None, elt)
|
924
|
+
|
925
|
+
elif msg.type == WSMsgType.ERROR:
|
926
|
+
break
|
927
|
+
|
928
|
+
except Exception as e:
|
929
|
+
|
930
|
+
print("Exception:", e)
|
931
|
+
|
932
|
+
return ws
|
933
|
+
|
663
934
|
async def app_factory(self):
|
664
935
|
|
665
936
|
self.llm_pub_task = asyncio.create_task(self.llm_in.run())
|
@@ -688,6 +959,22 @@ class Api:
|
|
688
959
|
self.embeddings_out.run()
|
689
960
|
)
|
690
961
|
|
962
|
+
self.triples_tap_task = asyncio.create_task(
|
963
|
+
self.triples_tap.run()
|
964
|
+
)
|
965
|
+
|
966
|
+
self.triples_pub_task = asyncio.create_task(
|
967
|
+
self.triples_pub.run()
|
968
|
+
)
|
969
|
+
|
970
|
+
self.graph_embeddings_tap_task = asyncio.create_task(
|
971
|
+
self.graph_embeddings_tap.run()
|
972
|
+
)
|
973
|
+
|
974
|
+
self.graph_embeddings_pub_task = asyncio.create_task(
|
975
|
+
self.graph_embeddings_pub.run()
|
976
|
+
)
|
977
|
+
|
691
978
|
self.doc_ingest_pub_task = asyncio.create_task(self.document_out.run())
|
692
979
|
|
693
980
|
self.text_ingest_pub_task = asyncio.create_task(self.text_out.run())
|
@@ -699,7 +986,6 @@ class Api:
|
|
699
986
|
|
700
987
|
def run():
|
701
988
|
|
702
|
-
|
703
989
|
parser = argparse.ArgumentParser(
|
704
990
|
prog="api-gateway",
|
705
991
|
description=__doc__
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = "0.16.6"
|
@@ -0,0 +1,142 @@
|
|
1
|
+
|
2
|
+
"""
|
3
|
+
Document embeddings query service. Input is vector, output is an array
|
4
|
+
of chunks. Pinecone implementation.
|
5
|
+
"""
|
6
|
+
|
7
|
+
from pinecone import Pinecone, ServerlessSpec
|
8
|
+
from pinecone.grpc import PineconeGRPC, GRPCClientConfig
|
9
|
+
|
10
|
+
import uuid
|
11
|
+
import os
|
12
|
+
|
13
|
+
from .... schema import DocumentEmbeddingsRequest, DocumentEmbeddingsResponse
|
14
|
+
from .... schema import Error, Value
|
15
|
+
from .... schema import document_embeddings_request_queue
|
16
|
+
from .... schema import document_embeddings_response_queue
|
17
|
+
from .... base import ConsumerProducer
|
18
|
+
|
19
|
+
module = ".".join(__name__.split(".")[1:-1])
|
20
|
+
|
21
|
+
default_input_queue = document_embeddings_request_queue
|
22
|
+
default_output_queue = document_embeddings_response_queue
|
23
|
+
default_subscriber = module
|
24
|
+
default_api_key = os.getenv("PINECONE_API_KEY", "not-specified")
|
25
|
+
|
26
|
+
class Processor(ConsumerProducer):
|
27
|
+
|
28
|
+
def __init__(self, **params):
|
29
|
+
|
30
|
+
input_queue = params.get("input_queue", default_input_queue)
|
31
|
+
output_queue = params.get("output_queue", default_output_queue)
|
32
|
+
subscriber = params.get("subscriber", default_subscriber)
|
33
|
+
|
34
|
+
self.url = params.get("url", None)
|
35
|
+
self.api_key = params.get("api_key", default_api_key)
|
36
|
+
|
37
|
+
if self.url:
|
38
|
+
|
39
|
+
self.pinecone = PineconeGRPC(
|
40
|
+
api_key = self.api_key,
|
41
|
+
host = self.url
|
42
|
+
)
|
43
|
+
|
44
|
+
else:
|
45
|
+
|
46
|
+
self.pinecone = Pinecone(api_key = self.api_key)
|
47
|
+
|
48
|
+
super(Processor, self).__init__(
|
49
|
+
**params | {
|
50
|
+
"input_queue": input_queue,
|
51
|
+
"output_queue": output_queue,
|
52
|
+
"subscriber": subscriber,
|
53
|
+
"input_schema": DocumentEmbeddingsRequest,
|
54
|
+
"output_schema": DocumentEmbeddingsResponse,
|
55
|
+
"url": self.url,
|
56
|
+
}
|
57
|
+
)
|
58
|
+
|
59
|
+
def handle(self, msg):
|
60
|
+
|
61
|
+
try:
|
62
|
+
|
63
|
+
v = msg.value()
|
64
|
+
|
65
|
+
# Sender-produced ID
|
66
|
+
id = msg.properties()["id"]
|
67
|
+
|
68
|
+
print(f"Handling input {id}...", flush=True)
|
69
|
+
|
70
|
+
chunks = []
|
71
|
+
|
72
|
+
for vec in v.vectors:
|
73
|
+
|
74
|
+
dim = len(vec)
|
75
|
+
|
76
|
+
index_name = (
|
77
|
+
"d-" + v.user + "-" + str(dim)
|
78
|
+
)
|
79
|
+
|
80
|
+
index = self.pinecone.Index(index_name)
|
81
|
+
|
82
|
+
results = index.query(
|
83
|
+
namespace=v.collection,
|
84
|
+
vector=vec,
|
85
|
+
top_k=v.limit,
|
86
|
+
include_values=False,
|
87
|
+
include_metadata=True
|
88
|
+
)
|
89
|
+
|
90
|
+
search_result = self.client.query_points(
|
91
|
+
collection_name=collection,
|
92
|
+
query=vec,
|
93
|
+
limit=v.limit,
|
94
|
+
with_payload=True,
|
95
|
+
).points
|
96
|
+
|
97
|
+
for r in results.matches:
|
98
|
+
doc = r.metadata["doc"]
|
99
|
+
chunks.add(doc)
|
100
|
+
|
101
|
+
print("Send response...", flush=True)
|
102
|
+
r = DocumentEmbeddingsResponse(documents=chunks, error=None)
|
103
|
+
self.producer.send(r, properties={"id": id})
|
104
|
+
|
105
|
+
print("Done.", flush=True)
|
106
|
+
|
107
|
+
except Exception as e:
|
108
|
+
|
109
|
+
print(f"Exception: {e}")
|
110
|
+
|
111
|
+
print("Send error response...", flush=True)
|
112
|
+
|
113
|
+
r = DocumentEmbeddingsResponse(
|
114
|
+
error=Error(
|
115
|
+
type = "llm-error",
|
116
|
+
message = str(e),
|
117
|
+
),
|
118
|
+
documents=None,
|
119
|
+
)
|
120
|
+
|
121
|
+
self.producer.send(r, properties={"id": id})
|
122
|
+
|
123
|
+
self.consumer.acknowledge(msg)
|
124
|
+
|
125
|
+
@staticmethod
|
126
|
+
def add_args(parser):
|
127
|
+
|
128
|
+
ConsumerProducer.add_args(
|
129
|
+
parser, default_input_queue, default_subscriber,
|
130
|
+
default_output_queue,
|
131
|
+
)
|
132
|
+
|
133
|
+
parser.add_argument(
|
134
|
+
'-t', '--store-uri',
|
135
|
+
default=default_store_uri,
|
136
|
+
help=f'Milvus store URI (default: {default_store_uri})'
|
137
|
+
)
|
138
|
+
|
139
|
+
def run():
|
140
|
+
|
141
|
+
Processor.start(module, __doc__)
|
142
|
+
|