trustgraph-base 2.7.3__tar.gz → 2.7.5__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_base-2.7.3 → trustgraph_base-2.7.5}/PKG-INFO +1 -1
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/api/__init__.py +2 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/api/async_flow.py +52 -1
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/api/async_socket_client.py +35 -2
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/api/flow.py +49 -1
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/api/socket_client.py +34 -1
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/api/types.py +18 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/__init__.py +2 -0
- trustgraph_base-2.7.5/trustgraph/base/image_to_text_service.py +170 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/llm_service.py +10 -3
- trustgraph_base-2.7.5/trustgraph/base/schema_compatibility.py +90 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/text_completion_client.py +9 -3
- trustgraph_base-2.7.5/trustgraph/base_version.py +1 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/__init__.py +7 -0
- trustgraph_base-2.7.5/trustgraph/messaging/translators/image_to_text.py +52 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/text_completion.py +11 -4
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/__init__.py +2 -1
- trustgraph_base-2.7.5/trustgraph/schema/services/image_to_text.py +24 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/llm.py +3 -1
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph_base.egg-info/PKG-INFO +1 -1
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph_base.egg-info/SOURCES.txt +4 -0
- trustgraph_base-2.7.3/trustgraph/base_version.py +0 -1
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/README.md +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/pyproject.toml +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/setup.cfg +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/api/api.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/api/async_bulk_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/api/async_metrics.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/api/bulk_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/api/collection.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/api/config.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/api/exceptions.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/api/explainability.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/api/knowledge.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/api/library.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/api/metrics.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/agent_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/agent_service.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/async_processor.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/audit_publisher.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/backend.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/cassandra_config.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/chunking_service.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/collection_config_handler.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/config_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/consumer.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/consumer_spec.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/document_embeddings_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/document_embeddings_query_service.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/document_embeddings_store_service.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/dynamic_tool_service.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/embeddings_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/embeddings_service.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/flow.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/flow_processor.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/graph_embeddings_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/graph_embeddings_query_service.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/graph_embeddings_store_service.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/graph_rag_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/iam_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/kafka_backend.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/keyword_index_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/keyword_index_service.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/librarian_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/librarian_spec.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/logging.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/metrics.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/parameter_spec.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/processor_group.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/producer.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/producer_spec.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/prompt_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/publisher.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/pubsub.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/pulsar_backend.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/qdrant_config.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/rabbitmq_backend.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/request_response_spec.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/reranker_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/reranker_service.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/row_embeddings_query_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/serialization.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/spec.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/structured_query_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/subscriber.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/subscriber_spec.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/tool_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/tool_service.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/tool_service_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/triples_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/triples_query_service.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/triples_store_service.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/base/workspace_processor.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/clients/__init__.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/clients/agent_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/clients/base.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/clients/config_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/clients/document_embeddings_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/clients/document_rag_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/clients/embeddings_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/clients/graph_embeddings_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/clients/graph_rag_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/clients/llm_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/clients/prompt_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/clients/row_embeddings_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/clients/triples_query_client.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/exceptions.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/i18n/__init__.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/i18n/packs/__init__.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/i18n/packs/ar.json +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/i18n/packs/en.json +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/i18n/packs/es.json +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/i18n/packs/he.json +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/i18n/packs/hi.json +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/i18n/packs/pt.json +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/i18n/packs/ru.json +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/i18n/packs/sw.json +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/i18n/packs/tr.json +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/i18n/packs/zh-cn.json +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/knowledge/__init__.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/knowledge/defs.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/knowledge/document.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/knowledge/identifier.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/knowledge/organization.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/knowledge/publication.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/log_level.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/registry.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/__init__.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/agent.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/base.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/collection.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/config.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/diagnosis.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/document_loading.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/embeddings.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/embeddings_query.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/flow.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/iam.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/knowledge.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/library.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/metadata.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/nlp_query.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/primitives.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/prompt.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/reranker.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/retrieval.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/rows_query.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/sparql_query.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/structured_query.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/tool.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/messaging/translators/triples.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/objects/__init__.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/objects/field.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/objects/object.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/provenance/__init__.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/provenance/agent.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/provenance/namespaces.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/provenance/triples.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/provenance/uris.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/provenance/vocabulary.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/rdf.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/__init__.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/core/__init__.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/core/metadata.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/core/primitives.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/core/topic.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/knowledge/__init__.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/knowledge/document.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/knowledge/embeddings.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/knowledge/graph.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/knowledge/knowledge.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/knowledge/nlp.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/knowledge/object.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/knowledge/rows.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/knowledge/structured.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/agent.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/audit.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/collection.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/config.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/diagnosis.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/flow.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/iam.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/library.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/lookup.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/nlp_query.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/prompt.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/query.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/reranker.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/retrieval.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/rows_query.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/sparql_query.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/storage.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/structured_query.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph/schema/services/tool_service.py +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph_base.egg-info/dependency_links.txt +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph_base.egg-info/entry_points.txt +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph_base.egg-info/requires.txt +0 -0
- {trustgraph_base-2.7.3 → trustgraph_base-2.7.5}/trustgraph_base.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: trustgraph-base
|
|
3
|
-
Version: 2.7.
|
|
3
|
+
Version: 2.7.5
|
|
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
|
Author-email: "trustgraph.ai" <security@trustgraph.ai>
|
|
6
6
|
Project-URL: Homepage, https://github.com/trustgraph-ai/trustgraph
|
|
@@ -107,6 +107,7 @@ from .types import (
|
|
|
107
107
|
AgentAnswer,
|
|
108
108
|
RAGChunk,
|
|
109
109
|
TextCompletionResult,
|
|
110
|
+
ImageToTextResult,
|
|
110
111
|
ProvenanceEvent,
|
|
111
112
|
)
|
|
112
113
|
|
|
@@ -186,6 +187,7 @@ __all__ = [
|
|
|
186
187
|
"AgentAnswer",
|
|
187
188
|
"RAGChunk",
|
|
188
189
|
"TextCompletionResult",
|
|
190
|
+
"ImageToTextResult",
|
|
189
191
|
"ProvenanceEvent",
|
|
190
192
|
|
|
191
193
|
# Exceptions
|
|
@@ -12,9 +12,10 @@ AsyncSocketClient instead.
|
|
|
12
12
|
|
|
13
13
|
import aiohttp
|
|
14
14
|
import json
|
|
15
|
+
import base64
|
|
15
16
|
from typing import Optional, Dict, Any, List
|
|
16
17
|
|
|
17
|
-
from . types import TextCompletionResult
|
|
18
|
+
from . types import TextCompletionResult, ImageToTextResult
|
|
18
19
|
|
|
19
20
|
from . exceptions import ProtocolException, ApplicationException
|
|
20
21
|
|
|
@@ -476,6 +477,56 @@ class AsyncFlowInstance:
|
|
|
476
477
|
model=result.get("model"),
|
|
477
478
|
)
|
|
478
479
|
|
|
480
|
+
async def image_to_text(self, image: bytes, mime_type: str,
|
|
481
|
+
prompt: Optional[str] = None,
|
|
482
|
+
system: Optional[str] = None,
|
|
483
|
+
**kwargs: Any) -> ImageToTextResult:
|
|
484
|
+
"""
|
|
485
|
+
Describe an image using the image-to-text service (non-streaming).
|
|
486
|
+
|
|
487
|
+
Args:
|
|
488
|
+
image: Image content as bytes
|
|
489
|
+
mime_type: Image MIME type (e.g. "image/jpeg")
|
|
490
|
+
prompt: Optional user prompt (backend default used if None)
|
|
491
|
+
system: Optional system prompt
|
|
492
|
+
**kwargs: Additional service-specific parameters
|
|
493
|
+
|
|
494
|
+
Returns:
|
|
495
|
+
ImageToTextResult: Result with text, in_token, out_token, model
|
|
496
|
+
|
|
497
|
+
Example:
|
|
498
|
+
```python
|
|
499
|
+
async_flow = await api.async_flow()
|
|
500
|
+
flow = async_flow.id("default")
|
|
501
|
+
|
|
502
|
+
with open("photo.jpg", "rb") as f:
|
|
503
|
+
result = await flow.image_to_text(
|
|
504
|
+
image=f.read(),
|
|
505
|
+
mime_type="image/jpeg",
|
|
506
|
+
)
|
|
507
|
+
print(result.text)
|
|
508
|
+
print(f"Tokens: {result.in_token} in, {result.out_token} out")
|
|
509
|
+
```
|
|
510
|
+
"""
|
|
511
|
+
# The image rides the JSON wire format as base64 text
|
|
512
|
+
request_data = {
|
|
513
|
+
"image": base64.b64encode(image).decode("utf-8"),
|
|
514
|
+
"mime_type": mime_type,
|
|
515
|
+
}
|
|
516
|
+
if prompt is not None:
|
|
517
|
+
request_data["prompt"] = prompt
|
|
518
|
+
if system is not None:
|
|
519
|
+
request_data["system"] = system
|
|
520
|
+
request_data.update(kwargs)
|
|
521
|
+
|
|
522
|
+
result = await self.request("image-to-text", request_data)
|
|
523
|
+
return ImageToTextResult(
|
|
524
|
+
text=result.get("description", ""),
|
|
525
|
+
in_token=result.get("in_token"),
|
|
526
|
+
out_token=result.get("out_token"),
|
|
527
|
+
model=result.get("model"),
|
|
528
|
+
)
|
|
529
|
+
|
|
479
530
|
async def graph_rag(self, query: str, collection: str,
|
|
480
531
|
max_subgraph_size: int = 1000, max_subgraph_count: int = 5,
|
|
481
532
|
max_entity_distance: int = 3, **kwargs: Any) -> str:
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
import json
|
|
3
|
+
import base64
|
|
3
4
|
import asyncio
|
|
4
5
|
import websockets
|
|
5
6
|
from typing import Optional, Dict, Any, AsyncIterator, Union
|
|
6
7
|
|
|
7
|
-
from . types import AgentThought, AgentObservation, AgentAnswer, RAGChunk, TextCompletionResult
|
|
8
|
-
from . exceptions import ProtocolException, ApplicationException
|
|
8
|
+
from . types import AgentThought, AgentObservation, AgentAnswer, RAGChunk, TextCompletionResult, ImageToTextResult
|
|
9
|
+
from . exceptions import ProtocolException, ApplicationException, raise_from_error_dict
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class AsyncSocketClient:
|
|
@@ -353,6 +354,38 @@ class AsyncSocketFlowInstance:
|
|
|
353
354
|
if isinstance(chunk, RAGChunk):
|
|
354
355
|
yield chunk
|
|
355
356
|
|
|
357
|
+
async def image_to_text(self, image: bytes, mime_type: str,
|
|
358
|
+
prompt: Optional[str] = None,
|
|
359
|
+
system: Optional[str] = None,
|
|
360
|
+
**kwargs) -> ImageToTextResult:
|
|
361
|
+
"""Describe an image using the image-to-text service (non-streaming).
|
|
362
|
+
|
|
363
|
+
Returns an ImageToTextResult with the description text and token counts.
|
|
364
|
+
"""
|
|
365
|
+
# The image rides the JSON wire format as base64 text
|
|
366
|
+
request = {
|
|
367
|
+
"image": base64.b64encode(image).decode("utf-8"),
|
|
368
|
+
"mime_type": mime_type,
|
|
369
|
+
}
|
|
370
|
+
if prompt is not None:
|
|
371
|
+
request["prompt"] = prompt
|
|
372
|
+
if system is not None:
|
|
373
|
+
request["system"] = system
|
|
374
|
+
request.update(kwargs)
|
|
375
|
+
|
|
376
|
+
result = await self.client._send_request("image-to-text", self.flow_id, request)
|
|
377
|
+
|
|
378
|
+
# Service errors arrive inside the response body
|
|
379
|
+
if isinstance(result, dict) and result.get("error"):
|
|
380
|
+
raise_from_error_dict(result["error"])
|
|
381
|
+
|
|
382
|
+
return ImageToTextResult(
|
|
383
|
+
text=result.get("description", ""),
|
|
384
|
+
in_token=result.get("in_token"),
|
|
385
|
+
out_token=result.get("out_token"),
|
|
386
|
+
model=result.get("model"),
|
|
387
|
+
)
|
|
388
|
+
|
|
356
389
|
async def graph_rag(self, query: str, collection: str,
|
|
357
390
|
max_subgraph_size: int = 1000, max_subgraph_count: int = 5,
|
|
358
391
|
max_entity_distance: int = 3, streaming: bool = False, **kwargs):
|
|
@@ -11,7 +11,7 @@ import base64
|
|
|
11
11
|
|
|
12
12
|
from .. knowledge import hash, Uri, Literal, QuotedTriple
|
|
13
13
|
from .. schema import IRI, LITERAL, TRIPLE
|
|
14
|
-
from . types import Triple, TextCompletionResult
|
|
14
|
+
from . types import Triple, TextCompletionResult, ImageToTextResult
|
|
15
15
|
from . exceptions import ProtocolException
|
|
16
16
|
|
|
17
17
|
|
|
@@ -296,6 +296,54 @@ class FlowInstance:
|
|
|
296
296
|
model=result.get("model"),
|
|
297
297
|
)
|
|
298
298
|
|
|
299
|
+
def image_to_text(self, image, mime_type, prompt=None, system=None):
|
|
300
|
+
"""
|
|
301
|
+
Describe an image using the flow's image-to-text service.
|
|
302
|
+
|
|
303
|
+
Args:
|
|
304
|
+
image: Image content as bytes
|
|
305
|
+
mime_type: Image MIME type (e.g. "image/jpeg")
|
|
306
|
+
prompt: Optional user prompt (backend default used if None)
|
|
307
|
+
system: Optional system prompt
|
|
308
|
+
|
|
309
|
+
Returns:
|
|
310
|
+
ImageToTextResult: Result with text, in_token, out_token, model
|
|
311
|
+
|
|
312
|
+
Example:
|
|
313
|
+
```python
|
|
314
|
+
flow = api.flow().id("default")
|
|
315
|
+
with open("photo.jpg", "rb") as f:
|
|
316
|
+
result = flow.image_to_text(
|
|
317
|
+
image=f.read(),
|
|
318
|
+
mime_type="image/jpeg",
|
|
319
|
+
)
|
|
320
|
+
print(result.text)
|
|
321
|
+
print(f"Tokens: {result.in_token} in, {result.out_token} out")
|
|
322
|
+
```
|
|
323
|
+
"""
|
|
324
|
+
|
|
325
|
+
# The image rides the JSON wire format as base64 text
|
|
326
|
+
input = {
|
|
327
|
+
"image": base64.b64encode(image).decode("utf-8"),
|
|
328
|
+
"mime_type": mime_type,
|
|
329
|
+
}
|
|
330
|
+
if prompt is not None:
|
|
331
|
+
input["prompt"] = prompt
|
|
332
|
+
if system is not None:
|
|
333
|
+
input["system"] = system
|
|
334
|
+
|
|
335
|
+
result = self.request(
|
|
336
|
+
"service/image-to-text",
|
|
337
|
+
input
|
|
338
|
+
)
|
|
339
|
+
|
|
340
|
+
return ImageToTextResult(
|
|
341
|
+
text=result.get("description", ""),
|
|
342
|
+
in_token=result.get("in_token"),
|
|
343
|
+
out_token=result.get("out_token"),
|
|
344
|
+
model=result.get("model"),
|
|
345
|
+
)
|
|
346
|
+
|
|
299
347
|
def agent(self, question,state=None, group=None, history=None):
|
|
300
348
|
"""
|
|
301
349
|
Execute an agent operation with reasoning and tool use capabilities.
|
|
@@ -9,13 +9,14 @@ multiplexes requests by ID.
|
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
11
|
import json
|
|
12
|
+
import base64
|
|
12
13
|
import asyncio
|
|
13
14
|
import websockets
|
|
14
15
|
from websockets.exceptions import ConnectionClosed
|
|
15
16
|
from typing import Optional, Dict, Any, Iterator, Union, List
|
|
16
17
|
from threading import Lock
|
|
17
18
|
|
|
18
|
-
from . types import AgentThought, AgentObservation, AgentAnswer, RAGChunk, StreamingChunk, ProvenanceEvent, TextCompletionResult
|
|
19
|
+
from . types import AgentThought, AgentObservation, AgentAnswer, RAGChunk, StreamingChunk, ProvenanceEvent, TextCompletionResult, ImageToTextResult
|
|
19
20
|
from . exceptions import ProtocolException, raise_from_error_dict
|
|
20
21
|
|
|
21
22
|
|
|
@@ -673,6 +674,38 @@ class SocketFlowInstance:
|
|
|
673
674
|
if isinstance(chunk, RAGChunk):
|
|
674
675
|
yield chunk
|
|
675
676
|
|
|
677
|
+
def image_to_text(self, image: bytes, mime_type: str,
|
|
678
|
+
prompt: Optional[str] = None,
|
|
679
|
+
system: Optional[str] = None,
|
|
680
|
+
**kwargs: Any) -> ImageToTextResult:
|
|
681
|
+
"""Describe an image using the image-to-text service (non-streaming).
|
|
682
|
+
|
|
683
|
+
Returns an ImageToTextResult with the description text and token counts.
|
|
684
|
+
"""
|
|
685
|
+
# The image rides the JSON wire format as base64 text
|
|
686
|
+
request = {
|
|
687
|
+
"image": base64.b64encode(image).decode("utf-8"),
|
|
688
|
+
"mime_type": mime_type,
|
|
689
|
+
}
|
|
690
|
+
if prompt is not None:
|
|
691
|
+
request["prompt"] = prompt
|
|
692
|
+
if system is not None:
|
|
693
|
+
request["system"] = system
|
|
694
|
+
request.update(kwargs)
|
|
695
|
+
|
|
696
|
+
result = self.client._send_request_sync("image-to-text", self.flow_id, request, False)
|
|
697
|
+
|
|
698
|
+
# Service errors arrive inside the response body
|
|
699
|
+
if isinstance(result, dict) and result.get("error"):
|
|
700
|
+
raise_from_error_dict(result["error"])
|
|
701
|
+
|
|
702
|
+
return ImageToTextResult(
|
|
703
|
+
text=result.get("description", ""),
|
|
704
|
+
in_token=result.get("in_token"),
|
|
705
|
+
out_token=result.get("out_token"),
|
|
706
|
+
model=result.get("model"),
|
|
707
|
+
)
|
|
708
|
+
|
|
676
709
|
def graph_rag(
|
|
677
710
|
self,
|
|
678
711
|
query: str,
|
|
@@ -240,6 +240,24 @@ class TextCompletionResult:
|
|
|
240
240
|
model: Optional[str] = None
|
|
241
241
|
sources: List[Dict[str, str]] = dataclasses.field(default_factory=list)
|
|
242
242
|
|
|
243
|
+
@dataclasses.dataclass
|
|
244
|
+
class ImageToTextResult:
|
|
245
|
+
"""
|
|
246
|
+
Result from an image-to-text request.
|
|
247
|
+
|
|
248
|
+
Returned by image_to_text(). Non-streaming only.
|
|
249
|
+
|
|
250
|
+
Attributes:
|
|
251
|
+
text: Text description of the image
|
|
252
|
+
in_token: Input token count (None if not available)
|
|
253
|
+
out_token: Output token count (None if not available)
|
|
254
|
+
model: Model identifier (None if not available)
|
|
255
|
+
"""
|
|
256
|
+
text: Optional[str]
|
|
257
|
+
in_token: Optional[int] = None
|
|
258
|
+
out_token: Optional[int] = None
|
|
259
|
+
model: Optional[str] = None
|
|
260
|
+
|
|
243
261
|
@dataclasses.dataclass
|
|
244
262
|
class ProvenanceEvent:
|
|
245
263
|
"""
|
|
@@ -44,9 +44,11 @@ from . agent_client import AgentClientSpec
|
|
|
44
44
|
from . structured_query_client import StructuredQueryClientSpec
|
|
45
45
|
from . reranker_client import RerankerClientSpec
|
|
46
46
|
from . reranker_service import RerankerService
|
|
47
|
+
from . image_to_text_service import ImageToTextService, ImageDescriptionResult
|
|
47
48
|
from . keyword_index_service import KeywordIndexService
|
|
48
49
|
from . keyword_index_client import KeywordIndexClientSpec, KeywordIndexClient
|
|
49
50
|
from . row_embeddings_query_client import RowEmbeddingsQueryClientSpec
|
|
50
51
|
from . collection_config_handler import CollectionConfigHandler
|
|
51
52
|
from . audit_publisher import AuditPublisher
|
|
53
|
+
from . schema_compatibility import is_strict_mode_compatible
|
|
52
54
|
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Image-to-text description base class
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from argparse import ArgumentParser
|
|
8
|
+
|
|
9
|
+
import logging
|
|
10
|
+
from prometheus_client import Histogram, Info
|
|
11
|
+
|
|
12
|
+
from .. schema import ImageToTextRequest, ImageToTextResponse, Error
|
|
13
|
+
from .. exceptions import TooManyRequests
|
|
14
|
+
from .. base import FlowProcessor, ConsumerSpec, ProducerSpec, ParameterSpec
|
|
15
|
+
|
|
16
|
+
# Module logger
|
|
17
|
+
logger = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
default_ident = "image-to-text"
|
|
20
|
+
default_concurrency = 1
|
|
21
|
+
|
|
22
|
+
class ImageDescriptionResult:
|
|
23
|
+
def __init__(
|
|
24
|
+
self, text = None, in_token = None, out_token = None,
|
|
25
|
+
model = None,
|
|
26
|
+
):
|
|
27
|
+
self.text = text
|
|
28
|
+
self.in_token = in_token
|
|
29
|
+
self.out_token = out_token
|
|
30
|
+
self.model = model
|
|
31
|
+
__slots__ = ["text", "in_token", "out_token", "model"]
|
|
32
|
+
|
|
33
|
+
class ImageToTextService(FlowProcessor):
|
|
34
|
+
"""
|
|
35
|
+
Extensible service processing image description requests.
|
|
36
|
+
|
|
37
|
+
This class handles the core logic of dispatching image-to-text
|
|
38
|
+
requests to integrated underlying vision model providers
|
|
39
|
+
(e.g. OpenAI).
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
def __init__(self, **params):
|
|
43
|
+
|
|
44
|
+
id = params.get("id", default_ident)
|
|
45
|
+
concurrency = params.get("concurrency", 1)
|
|
46
|
+
|
|
47
|
+
super(ImageToTextService, self).__init__(**params | {
|
|
48
|
+
"id": id,
|
|
49
|
+
"concurrency": concurrency,
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
self.register_specification(
|
|
53
|
+
ConsumerSpec(
|
|
54
|
+
name = "request",
|
|
55
|
+
schema = ImageToTextRequest,
|
|
56
|
+
handler = self.on_request,
|
|
57
|
+
concurrency = concurrency,
|
|
58
|
+
)
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
self.register_specification(
|
|
62
|
+
ProducerSpec(
|
|
63
|
+
name = "response",
|
|
64
|
+
schema = ImageToTextResponse
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
self.register_specification(
|
|
69
|
+
ParameterSpec(
|
|
70
|
+
name = "model",
|
|
71
|
+
)
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
if not hasattr(__class__, "image_to_text_metric"):
|
|
75
|
+
__class__.image_to_text_metric = Histogram(
|
|
76
|
+
'image_to_text_duration',
|
|
77
|
+
'Image-to-text duration (seconds)',
|
|
78
|
+
["id", "flow"],
|
|
79
|
+
buckets=[
|
|
80
|
+
0.25, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0,
|
|
81
|
+
8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
|
|
82
|
+
17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0,
|
|
83
|
+
30.0, 35.0, 40.0, 45.0, 50.0, 60.0, 80.0, 100.0,
|
|
84
|
+
120.0
|
|
85
|
+
]
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
if not hasattr(__class__, "image_to_text_model_metric"):
|
|
89
|
+
__class__.image_to_text_model_metric = Info(
|
|
90
|
+
'image_to_text_model',
|
|
91
|
+
'Image-to-text model',
|
|
92
|
+
["processor", "flow"]
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
async def on_request(self, msg, consumer, flow):
|
|
96
|
+
|
|
97
|
+
try:
|
|
98
|
+
|
|
99
|
+
request = msg.value()
|
|
100
|
+
|
|
101
|
+
# Sender-produced ID
|
|
102
|
+
|
|
103
|
+
id = msg.properties()["id"]
|
|
104
|
+
|
|
105
|
+
model = flow("model")
|
|
106
|
+
|
|
107
|
+
with __class__.image_to_text_metric.labels(
|
|
108
|
+
id=self.id,
|
|
109
|
+
flow=f"{flow.name}-{consumer.name}",
|
|
110
|
+
).time():
|
|
111
|
+
|
|
112
|
+
response = await self.describe_image(
|
|
113
|
+
request.image, request.mime_type,
|
|
114
|
+
request.prompt, request.system, model,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
await flow("response").send(
|
|
118
|
+
ImageToTextResponse(
|
|
119
|
+
error=None,
|
|
120
|
+
description=response.text,
|
|
121
|
+
in_token=response.in_token,
|
|
122
|
+
out_token=response.out_token,
|
|
123
|
+
model=response.model,
|
|
124
|
+
),
|
|
125
|
+
properties={"id": id}
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
__class__.image_to_text_model_metric.labels(
|
|
129
|
+
processor = self.id,
|
|
130
|
+
flow = flow.name
|
|
131
|
+
).info({
|
|
132
|
+
"model": str(model) if model is not None else "",
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
except TooManyRequests as e:
|
|
136
|
+
raise e
|
|
137
|
+
|
|
138
|
+
except Exception as e:
|
|
139
|
+
|
|
140
|
+
# Apart from rate limits, treat all exceptions as unrecoverable
|
|
141
|
+
|
|
142
|
+
logger.error(f"Image-to-text service exception: {e}", exc_info=True)
|
|
143
|
+
|
|
144
|
+
logger.debug("Sending error response...")
|
|
145
|
+
|
|
146
|
+
await flow.producer["response"].send(
|
|
147
|
+
ImageToTextResponse(
|
|
148
|
+
error=Error(
|
|
149
|
+
type = "image-to-text-error",
|
|
150
|
+
message = str(e),
|
|
151
|
+
),
|
|
152
|
+
description=None,
|
|
153
|
+
in_token=None,
|
|
154
|
+
out_token=None,
|
|
155
|
+
model=None,
|
|
156
|
+
),
|
|
157
|
+
properties={"id": id}
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
@staticmethod
|
|
161
|
+
def add_args(parser: ArgumentParser) -> None:
|
|
162
|
+
|
|
163
|
+
parser.add_argument(
|
|
164
|
+
'-c', '--concurrency',
|
|
165
|
+
type=int,
|
|
166
|
+
default=default_concurrency,
|
|
167
|
+
help=f'Concurrent processing threads (default: {default_concurrency})'
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
FlowProcessor.add_args(parser)
|
|
@@ -126,6 +126,8 @@ class LlmService(FlowProcessor):
|
|
|
126
126
|
|
|
127
127
|
# Check if streaming is requested and supported
|
|
128
128
|
streaming = getattr(request, 'streaming', False)
|
|
129
|
+
response_format = getattr(request, 'response_format', None)
|
|
130
|
+
schema = getattr(request, 'schema', None)
|
|
129
131
|
|
|
130
132
|
if streaming and self.supports_streaming():
|
|
131
133
|
|
|
@@ -136,7 +138,8 @@ class LlmService(FlowProcessor):
|
|
|
136
138
|
).time():
|
|
137
139
|
|
|
138
140
|
async for chunk in self.generate_content_stream(
|
|
139
|
-
request.system, request.prompt, model, temperature
|
|
141
|
+
request.system, request.prompt, model, temperature,
|
|
142
|
+
response_format=response_format, schema=schema,
|
|
140
143
|
):
|
|
141
144
|
await flow("response").send(
|
|
142
145
|
TextCompletionResponse(
|
|
@@ -159,7 +162,8 @@ class LlmService(FlowProcessor):
|
|
|
159
162
|
).time():
|
|
160
163
|
|
|
161
164
|
response = await self.generate_content(
|
|
162
|
-
request.system, request.prompt, model, temperature
|
|
165
|
+
request.system, request.prompt, model, temperature,
|
|
166
|
+
response_format=response_format, schema=schema,
|
|
163
167
|
)
|
|
164
168
|
|
|
165
169
|
await flow("response").send(
|
|
@@ -215,7 +219,10 @@ class LlmService(FlowProcessor):
|
|
|
215
219
|
"""
|
|
216
220
|
return False
|
|
217
221
|
|
|
218
|
-
async def generate_content_stream(
|
|
222
|
+
async def generate_content_stream(
|
|
223
|
+
self, system, prompt, model=None, temperature=None,
|
|
224
|
+
response_format=None, schema=None,
|
|
225
|
+
):
|
|
219
226
|
"""
|
|
220
227
|
Override in subclass to implement streaming.
|
|
221
228
|
Should yield LlmChunk objects.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
logger = logging.getLogger(__name__)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def is_strict_mode_compatible(schema):
|
|
8
|
+
"""
|
|
9
|
+
Check whether a JSON schema is compatible with LLM structured-output
|
|
10
|
+
strict mode. Returns True if the schema can be passed directly to
|
|
11
|
+
providers like OpenAI, vLLM, etc.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
if schema is None:
|
|
15
|
+
return False
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
_check_node(schema)
|
|
19
|
+
return True
|
|
20
|
+
except _IncompatibleSchema as e:
|
|
21
|
+
logger.debug("Schema not strict-mode compatible: %s", e)
|
|
22
|
+
return False
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class _IncompatibleSchema(Exception):
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _check_node(node):
|
|
30
|
+
|
|
31
|
+
if not isinstance(node, dict):
|
|
32
|
+
return
|
|
33
|
+
|
|
34
|
+
node_type = node.get("type")
|
|
35
|
+
|
|
36
|
+
if node_type == "object" or (
|
|
37
|
+
node_type is None and "properties" in node
|
|
38
|
+
):
|
|
39
|
+
_check_object(node)
|
|
40
|
+
|
|
41
|
+
if node_type == "array":
|
|
42
|
+
items = node.get("items")
|
|
43
|
+
if items:
|
|
44
|
+
_check_node(items)
|
|
45
|
+
|
|
46
|
+
for keyword in ("oneOf", "anyOf", "allOf"):
|
|
47
|
+
for child in node.get(keyword, []):
|
|
48
|
+
_check_node(child)
|
|
49
|
+
|
|
50
|
+
_check_unsupported_constraints(node)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _check_object(node):
|
|
54
|
+
|
|
55
|
+
props = node.get("properties")
|
|
56
|
+
if props is None:
|
|
57
|
+
raise _IncompatibleSchema(
|
|
58
|
+
"object without properties (open-ended)"
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
if node.get("additionalProperties") is not False:
|
|
62
|
+
raise _IncompatibleSchema(
|
|
63
|
+
"object missing additionalProperties: false"
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
required = set(node.get("required", []))
|
|
67
|
+
for key in props:
|
|
68
|
+
if key not in required:
|
|
69
|
+
raise _IncompatibleSchema(
|
|
70
|
+
f"property '{key}' not in required"
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
for value in props.values():
|
|
74
|
+
_check_node(value)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
UNSUPPORTED_KEYWORDS = {
|
|
78
|
+
"minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum",
|
|
79
|
+
"minLength", "maxLength", "pattern",
|
|
80
|
+
"minItems", "maxItems",
|
|
81
|
+
"minProperties", "maxProperties",
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _check_unsupported_constraints(node):
|
|
86
|
+
found = UNSUPPORTED_KEYWORDS & node.keys()
|
|
87
|
+
if found:
|
|
88
|
+
raise _IncompatibleSchema(
|
|
89
|
+
f"unsupported constraints: {', '.join(sorted(found))}"
|
|
90
|
+
)
|
|
@@ -14,11 +14,15 @@ class TextCompletionResult:
|
|
|
14
14
|
|
|
15
15
|
class TextCompletionClient(RequestResponse):
|
|
16
16
|
|
|
17
|
-
async def text_completion(
|
|
17
|
+
async def text_completion(
|
|
18
|
+
self, system, prompt, timeout=600,
|
|
19
|
+
response_format=None, schema=None,
|
|
20
|
+
):
|
|
18
21
|
|
|
19
22
|
resp = await self.request(
|
|
20
23
|
TextCompletionRequest(
|
|
21
|
-
system
|
|
24
|
+
system=system, prompt=prompt, streaming=False,
|
|
25
|
+
response_format=response_format, schema=schema,
|
|
22
26
|
),
|
|
23
27
|
timeout=timeout
|
|
24
28
|
)
|
|
@@ -35,6 +39,7 @@ class TextCompletionClient(RequestResponse):
|
|
|
35
39
|
|
|
36
40
|
async def text_completion_stream(
|
|
37
41
|
self, system, prompt, handler, timeout=600,
|
|
42
|
+
response_format=None, schema=None,
|
|
38
43
|
):
|
|
39
44
|
"""
|
|
40
45
|
Streaming text completion. `handler` is an async callable invoked
|
|
@@ -54,7 +59,8 @@ class TextCompletionClient(RequestResponse):
|
|
|
54
59
|
|
|
55
60
|
final = await self.request(
|
|
56
61
|
TextCompletionRequest(
|
|
57
|
-
system
|
|
62
|
+
system=system, prompt=prompt, streaming=True,
|
|
63
|
+
response_format=response_format, schema=schema,
|
|
58
64
|
),
|
|
59
65
|
recipient=on_chunk,
|
|
60
66
|
timeout=timeout,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.7.5"
|
|
@@ -5,6 +5,7 @@ from .translators import *
|
|
|
5
5
|
from .translators.agent import AgentRequestTranslator, AgentResponseTranslator
|
|
6
6
|
from .translators.embeddings import EmbeddingsRequestTranslator, EmbeddingsResponseTranslator
|
|
7
7
|
from .translators.text_completion import TextCompletionRequestTranslator, TextCompletionResponseTranslator
|
|
8
|
+
from .translators.image_to_text import ImageToTextRequestTranslator, ImageToTextResponseTranslator
|
|
8
9
|
from .translators.retrieval import (
|
|
9
10
|
DocumentRagRequestTranslator, DocumentRagResponseTranslator,
|
|
10
11
|
GraphRagRequestTranslator, GraphRagResponseTranslator
|
|
@@ -50,6 +51,12 @@ TranslatorRegistry.register_service(
|
|
|
50
51
|
TextCompletionResponseTranslator()
|
|
51
52
|
)
|
|
52
53
|
|
|
54
|
+
TranslatorRegistry.register_service(
|
|
55
|
+
"image-to-text",
|
|
56
|
+
ImageToTextRequestTranslator(),
|
|
57
|
+
ImageToTextResponseTranslator()
|
|
58
|
+
)
|
|
59
|
+
|
|
53
60
|
TranslatorRegistry.register_service(
|
|
54
61
|
"document-rag",
|
|
55
62
|
DocumentRagRequestTranslator(),
|