mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-01 17:39:39 +02:00
feat: workspace-based multi-tenancy, replacing user as tenancy axis (#840)
Introduces `workspace` as the isolation boundary for config, flows,
library, and knowledge data. Removes `user` as a schema-level field
throughout the code, API specs, and tests; workspace provides the
same separation more cleanly at the trusted flow.workspace layer
rather than through client-supplied message fields.
Design
------
- IAM tech spec (docs/tech-specs/iam.md) documents current state,
proposed auth/access model, and migration direction.
- Data ownership model (docs/tech-specs/data-ownership-model.md)
captures the workspace/collection/flow hierarchy.
Schema + messaging
------------------
- Drop `user` field from AgentRequest/Step, GraphRagQuery,
DocumentRagQuery, Triples/Graph/Document/Row EmbeddingsRequest,
Sparql/Rows/Structured QueryRequest, ToolServiceRequest.
- Keep collection/workspace routing via flow.workspace at the
service layer.
- Translators updated to not serialise/deserialise user.
API specs
---------
- OpenAPI schemas and path examples cleaned of user fields.
- Websocket async-api messages updated.
- Removed the unused parameters/User.yaml.
Services + base
---------------
- Librarian, collection manager, knowledge, config: all operations
scoped by workspace. Config client API takes workspace as first
positional arg.
- `flow.workspace` set at flow start time by the infrastructure;
no longer pass-through from clients.
- Tool service drops user-personalisation passthrough.
CLI + SDK
---------
- tg-init-workspace and workspace-aware import/export.
- All tg-* commands drop user args; accept --workspace.
- Python API/SDK (flow, socket_client, async_*, explainability,
library) drop user kwargs from every method signature.
MCP server
----------
- All tool endpoints drop user parameters; socket_manager no longer
keyed per user.
Flow service
------------
- Closure-based topic cleanup on flow stop: only delete topics
whose blueprint template was parameterised AND no remaining
live flow (across all workspaces) still resolves to that topic.
Three scopes fall out naturally from template analysis:
* {id} -> per-flow, deleted on stop
* {blueprint} -> per-blueprint, kept while any flow of the
same blueprint exists
* {workspace} -> per-workspace, kept while any flow in the
workspace exists
* literal -> global, never deleted (e.g. tg.request.librarian)
Fixes a bug where stopping a flow silently destroyed the global
librarian exchange, wedging all library operations until manual
restart.
RabbitMQ backend
----------------
- heartbeat=60, blocked_connection_timeout=300. Catches silently
dead connections (broker restart, orphaned channels, network
partitions) within ~2 heartbeat windows, so the consumer
reconnects and re-binds its queue rather than sitting forever
on a zombie connection.
Tests
-----
- Full test refresh: unit, integration, contract, provenance.
- Dropped user-field assertions and constructor kwargs across
~100 test files.
- Renamed user-collection isolation tests to workspace-collection.
This commit is contained in:
parent
9332089b3d
commit
d35473f7f7
377 changed files with 6868 additions and 5785 deletions
|
|
@ -13,7 +13,6 @@ class AgentRequestTranslator(MessageTranslator):
|
|||
state=data.get("state", None),
|
||||
group=data.get("group", None),
|
||||
history=data.get("history", []),
|
||||
user=data.get("user", "trustgraph"),
|
||||
collection=data.get("collection", "default"),
|
||||
streaming=data.get("streaming", False),
|
||||
session_id=data.get("session_id", ""),
|
||||
|
|
@ -33,7 +32,6 @@ class AgentRequestTranslator(MessageTranslator):
|
|||
"state": obj.state,
|
||||
"group": obj.group,
|
||||
"history": obj.history,
|
||||
"user": obj.user,
|
||||
"collection": getattr(obj, "collection", "default"),
|
||||
"streaming": getattr(obj, "streaming", False),
|
||||
"session_id": getattr(obj, "session_id", ""),
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class CollectionManagementRequestTranslator(MessageTranslator):
|
|||
def decode(self, data: Dict[str, Any]) -> CollectionManagementRequest:
|
||||
return CollectionManagementRequest(
|
||||
operation=data.get("operation"),
|
||||
user=data.get("user"),
|
||||
workspace=data.get("workspace", ""),
|
||||
collection=data.get("collection"),
|
||||
timestamp=data.get("timestamp"),
|
||||
name=data.get("name"),
|
||||
|
|
@ -24,8 +24,8 @@ class CollectionManagementRequestTranslator(MessageTranslator):
|
|||
|
||||
if obj.operation is not None:
|
||||
result["operation"] = obj.operation
|
||||
if obj.user is not None:
|
||||
result["user"] = obj.user
|
||||
if obj.workspace:
|
||||
result["workspace"] = obj.workspace
|
||||
if obj.collection is not None:
|
||||
result["collection"] = obj.collection
|
||||
if obj.timestamp is not None:
|
||||
|
|
@ -63,7 +63,6 @@ class CollectionManagementResponseTranslator(MessageTranslator):
|
|||
if "collections" in data:
|
||||
for coll_data in data["collections"]:
|
||||
collections.append(CollectionMetadata(
|
||||
user=coll_data.get("user"),
|
||||
collection=coll_data.get("collection"),
|
||||
name=coll_data.get("name"),
|
||||
description=coll_data.get("description"),
|
||||
|
|
@ -91,7 +90,6 @@ class CollectionManagementResponseTranslator(MessageTranslator):
|
|||
result["collections"] = []
|
||||
for coll in obj.collections:
|
||||
result["collections"].append({
|
||||
"user": coll.user,
|
||||
"collection": coll.collection,
|
||||
"name": coll.name,
|
||||
"description": coll.description,
|
||||
|
|
|
|||
|
|
@ -23,13 +23,15 @@ class ConfigRequestTranslator(MessageTranslator):
|
|||
ConfigValue(
|
||||
type=v["type"],
|
||||
key=v["key"],
|
||||
value=v["value"]
|
||||
value=v["value"],
|
||||
workspace=v.get("workspace", ""),
|
||||
)
|
||||
for v in data["values"]
|
||||
]
|
||||
|
||||
return ConfigRequest(
|
||||
operation=data.get("operation"),
|
||||
workspace=data.get("workspace", ""),
|
||||
keys=keys,
|
||||
type=data.get("type"),
|
||||
values=values
|
||||
|
|
@ -37,10 +39,13 @@ class ConfigRequestTranslator(MessageTranslator):
|
|||
|
||||
def encode(self, obj: ConfigRequest) -> Dict[str, Any]:
|
||||
result = {}
|
||||
|
||||
|
||||
if obj.operation is not None:
|
||||
result["operation"] = obj.operation
|
||||
|
||||
if obj.workspace is not None:
|
||||
result["workspace"] = obj.workspace
|
||||
|
||||
if obj.type is not None:
|
||||
result["type"] = obj.type
|
||||
|
||||
|
|
@ -56,13 +61,14 @@ class ConfigRequestTranslator(MessageTranslator):
|
|||
if obj.values is not None:
|
||||
result["values"] = [
|
||||
{
|
||||
**({"workspace": v.workspace} if v.workspace else {}),
|
||||
"type": v.type,
|
||||
"key": v.key,
|
||||
"value": v.value
|
||||
"value": v.value,
|
||||
}
|
||||
for v in obj.values
|
||||
]
|
||||
|
||||
|
||||
return result
|
||||
|
||||
|
||||
|
|
@ -81,13 +87,14 @@ class ConfigResponseTranslator(MessageTranslator):
|
|||
if obj.values is not None:
|
||||
result["values"] = [
|
||||
{
|
||||
**({"workspace": v.workspace} if v.workspace else {}),
|
||||
"type": v.type,
|
||||
"key": v.key,
|
||||
"value": v.value
|
||||
"value": v.value,
|
||||
}
|
||||
for v in obj.values
|
||||
]
|
||||
|
||||
|
||||
if obj.directory is not None:
|
||||
result["directory"] = obj.directory
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ class DocumentTranslator(SendTranslator):
|
|||
metadata=Metadata(
|
||||
id=data.get("id"),
|
||||
root=data.get("root", ""),
|
||||
user=data.get("user", "trustgraph"),
|
||||
collection=data.get("collection", "default"),
|
||||
),
|
||||
data=base64.b64encode(doc).decode("utf-8")
|
||||
|
|
@ -56,8 +55,6 @@ class DocumentTranslator(SendTranslator):
|
|||
metadata_dict["id"] = obj.metadata.id
|
||||
if obj.metadata.root:
|
||||
metadata_dict["root"] = obj.metadata.root
|
||||
if obj.metadata.user:
|
||||
metadata_dict["user"] = obj.metadata.user
|
||||
if obj.metadata.collection:
|
||||
metadata_dict["collection"] = obj.metadata.collection
|
||||
|
||||
|
|
@ -79,7 +76,6 @@ class TextDocumentTranslator(SendTranslator):
|
|||
metadata=Metadata(
|
||||
id=data.get("id"),
|
||||
root=data.get("root", ""),
|
||||
user=data.get("user", "trustgraph"),
|
||||
collection=data.get("collection", "default"),
|
||||
),
|
||||
text=text.encode("utf-8")
|
||||
|
|
@ -96,8 +92,6 @@ class TextDocumentTranslator(SendTranslator):
|
|||
metadata_dict["id"] = obj.metadata.id
|
||||
if obj.metadata.root:
|
||||
metadata_dict["root"] = obj.metadata.root
|
||||
if obj.metadata.user:
|
||||
metadata_dict["user"] = obj.metadata.user
|
||||
if obj.metadata.collection:
|
||||
metadata_dict["collection"] = obj.metadata.collection
|
||||
|
||||
|
|
@ -115,7 +109,6 @@ class ChunkTranslator(SendTranslator):
|
|||
metadata=Metadata(
|
||||
id=data.get("id"),
|
||||
root=data.get("root", ""),
|
||||
user=data.get("user", "trustgraph"),
|
||||
collection=data.get("collection", "default"),
|
||||
),
|
||||
chunk=data["chunk"].encode("utf-8") if isinstance(data["chunk"], str) else data["chunk"]
|
||||
|
|
@ -132,8 +125,6 @@ class ChunkTranslator(SendTranslator):
|
|||
metadata_dict["id"] = obj.metadata.id
|
||||
if obj.metadata.root:
|
||||
metadata_dict["root"] = obj.metadata.root
|
||||
if obj.metadata.user:
|
||||
metadata_dict["user"] = obj.metadata.user
|
||||
if obj.metadata.collection:
|
||||
metadata_dict["collection"] = obj.metadata.collection
|
||||
|
||||
|
|
@ -161,7 +152,6 @@ class DocumentEmbeddingsTranslator(SendTranslator):
|
|||
metadata=Metadata(
|
||||
id=metadata.get("id"),
|
||||
root=metadata.get("root", ""),
|
||||
user=metadata.get("user", "trustgraph"),
|
||||
collection=metadata.get("collection", "default"),
|
||||
),
|
||||
chunks=chunks
|
||||
|
|
@ -184,8 +174,6 @@ class DocumentEmbeddingsTranslator(SendTranslator):
|
|||
metadata_dict["id"] = obj.metadata.id
|
||||
if obj.metadata.root:
|
||||
metadata_dict["root"] = obj.metadata.root
|
||||
if obj.metadata.user:
|
||||
metadata_dict["user"] = obj.metadata.user
|
||||
if obj.metadata.collection:
|
||||
metadata_dict["collection"] = obj.metadata.collection
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ class DocumentEmbeddingsRequestTranslator(MessageTranslator):
|
|||
return DocumentEmbeddingsRequest(
|
||||
vector=data["vector"],
|
||||
limit=int(data.get("limit", 10)),
|
||||
user=data.get("user", "trustgraph"),
|
||||
collection=data.get("collection", "default")
|
||||
)
|
||||
|
||||
|
|
@ -23,7 +22,6 @@ class DocumentEmbeddingsRequestTranslator(MessageTranslator):
|
|||
return {
|
||||
"vector": obj.vector,
|
||||
"limit": obj.limit,
|
||||
"user": obj.user,
|
||||
"collection": obj.collection
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +58,6 @@ class GraphEmbeddingsRequestTranslator(MessageTranslator):
|
|||
return GraphEmbeddingsRequest(
|
||||
vector=data["vector"],
|
||||
limit=int(data.get("limit", 10)),
|
||||
user=data.get("user", "trustgraph"),
|
||||
collection=data.get("collection", "default")
|
||||
)
|
||||
|
||||
|
|
@ -68,7 +65,6 @@ class GraphEmbeddingsRequestTranslator(MessageTranslator):
|
|||
return {
|
||||
"vector": obj.vector,
|
||||
"limit": obj.limit,
|
||||
"user": obj.user,
|
||||
"collection": obj.collection
|
||||
}
|
||||
|
||||
|
|
@ -108,7 +104,6 @@ class RowEmbeddingsRequestTranslator(MessageTranslator):
|
|||
return RowEmbeddingsRequest(
|
||||
vector=data["vector"],
|
||||
limit=int(data.get("limit", 10)),
|
||||
user=data.get("user", "trustgraph"),
|
||||
collection=data.get("collection", "default"),
|
||||
schema_name=data.get("schema_name", ""),
|
||||
index_name=data.get("index_name")
|
||||
|
|
@ -118,7 +113,6 @@ class RowEmbeddingsRequestTranslator(MessageTranslator):
|
|||
result = {
|
||||
"vector": obj.vector,
|
||||
"limit": obj.limit,
|
||||
"user": obj.user,
|
||||
"collection": obj.collection,
|
||||
"schema_name": obj.schema_name,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,18 +9,21 @@ class FlowRequestTranslator(MessageTranslator):
|
|||
def decode(self, data: Dict[str, Any]) -> FlowRequest:
|
||||
return FlowRequest(
|
||||
operation=data.get("operation"),
|
||||
workspace=data.get("workspace", ""),
|
||||
blueprint_name=data.get("blueprint-name"),
|
||||
blueprint_definition=data.get("blueprint-definition"),
|
||||
description=data.get("description"),
|
||||
flow_id=data.get("flow-id"),
|
||||
parameters=data.get("parameters")
|
||||
)
|
||||
|
||||
|
||||
def encode(self, obj: FlowRequest) -> Dict[str, Any]:
|
||||
result = {}
|
||||
|
||||
if obj.operation is not None:
|
||||
result["operation"] = obj.operation
|
||||
if obj.workspace is not None:
|
||||
result["workspace"] = obj.workspace
|
||||
if obj.blueprint_name is not None:
|
||||
result["blueprint-name"] = obj.blueprint_name
|
||||
if obj.blueprint_definition is not None:
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ class KnowledgeRequestTranslator(MessageTranslator):
|
|||
metadata=Metadata(
|
||||
id=data["triples"]["metadata"]["id"],
|
||||
root=data["triples"]["metadata"].get("root", ""),
|
||||
user=data["triples"]["metadata"]["user"],
|
||||
collection=data["triples"]["metadata"]["collection"]
|
||||
),
|
||||
triples=self.subgraph_translator.decode(data["triples"]["triples"]),
|
||||
|
|
@ -33,7 +32,6 @@ class KnowledgeRequestTranslator(MessageTranslator):
|
|||
metadata=Metadata(
|
||||
id=data["graph-embeddings"]["metadata"]["id"],
|
||||
root=data["graph-embeddings"]["metadata"].get("root", ""),
|
||||
user=data["graph-embeddings"]["metadata"]["user"],
|
||||
collection=data["graph-embeddings"]["metadata"]["collection"]
|
||||
),
|
||||
entities=[
|
||||
|
|
@ -47,7 +45,7 @@ class KnowledgeRequestTranslator(MessageTranslator):
|
|||
|
||||
return KnowledgeRequest(
|
||||
operation=data.get("operation"),
|
||||
user=data.get("user"),
|
||||
workspace=data.get("workspace", ""),
|
||||
id=data.get("id"),
|
||||
flow=data.get("flow"),
|
||||
collection=data.get("collection"),
|
||||
|
|
@ -60,8 +58,8 @@ class KnowledgeRequestTranslator(MessageTranslator):
|
|||
|
||||
if obj.operation:
|
||||
result["operation"] = obj.operation
|
||||
if obj.user:
|
||||
result["user"] = obj.user
|
||||
if obj.workspace:
|
||||
result["workspace"] = obj.workspace
|
||||
if obj.id:
|
||||
result["id"] = obj.id
|
||||
if obj.flow:
|
||||
|
|
@ -74,7 +72,6 @@ class KnowledgeRequestTranslator(MessageTranslator):
|
|||
"metadata": {
|
||||
"id": obj.triples.metadata.id,
|
||||
"root": obj.triples.metadata.root,
|
||||
"user": obj.triples.metadata.user,
|
||||
"collection": obj.triples.metadata.collection,
|
||||
},
|
||||
"triples": self.subgraph_translator.encode(obj.triples.triples),
|
||||
|
|
@ -85,7 +82,6 @@ class KnowledgeRequestTranslator(MessageTranslator):
|
|||
"metadata": {
|
||||
"id": obj.graph_embeddings.metadata.id,
|
||||
"root": obj.graph_embeddings.metadata.root,
|
||||
"user": obj.graph_embeddings.metadata.user,
|
||||
"collection": obj.graph_embeddings.metadata.collection,
|
||||
},
|
||||
"entities": [
|
||||
|
|
@ -122,7 +118,6 @@ class KnowledgeResponseTranslator(MessageTranslator):
|
|||
"metadata": {
|
||||
"id": obj.triples.metadata.id,
|
||||
"root": obj.triples.metadata.root,
|
||||
"user": obj.triples.metadata.user,
|
||||
"collection": obj.triples.metadata.collection,
|
||||
},
|
||||
"triples": self.subgraph_translator.encode(obj.triples.triples),
|
||||
|
|
@ -136,7 +131,6 @@ class KnowledgeResponseTranslator(MessageTranslator):
|
|||
"metadata": {
|
||||
"id": obj.graph_embeddings.metadata.id,
|
||||
"root": obj.graph_embeddings.metadata.root,
|
||||
"user": obj.graph_embeddings.metadata.user,
|
||||
"collection": obj.graph_embeddings.metadata.collection,
|
||||
},
|
||||
"entities": [
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class LibraryRequestTranslator(MessageTranslator):
|
|||
document_metadata=doc_metadata,
|
||||
processing_metadata=proc_metadata,
|
||||
content=content,
|
||||
user=data.get("user", ""),
|
||||
workspace=data.get("workspace", ""),
|
||||
collection=data.get("collection", ""),
|
||||
criteria=criteria,
|
||||
# Chunked upload fields
|
||||
|
|
@ -76,8 +76,8 @@ class LibraryRequestTranslator(MessageTranslator):
|
|||
result["processing-metadata"] = self.proc_metadata_translator.encode(obj.processing_metadata)
|
||||
if obj.content:
|
||||
result["content"] = obj.content.decode("utf-8") if isinstance(obj.content, bytes) else obj.content
|
||||
if obj.user:
|
||||
result["user"] = obj.user
|
||||
if obj.workspace:
|
||||
result["workspace"] = obj.workspace
|
||||
if obj.collection:
|
||||
result["collection"] = obj.collection
|
||||
if obj.criteria is not None:
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class DocumentMetadataTranslator(Translator):
|
|||
title=data.get("title"),
|
||||
comments=data.get("comments"),
|
||||
metadata=self.subgraph_translator.decode(metadata) if metadata is not None else [],
|
||||
user=data.get("user"),
|
||||
workspace=data.get("workspace"),
|
||||
tags=data.get("tags"),
|
||||
parent_id=data.get("parent-id", ""),
|
||||
document_type=data.get("document-type", "source"),
|
||||
|
|
@ -40,8 +40,8 @@ class DocumentMetadataTranslator(Translator):
|
|||
result["comments"] = obj.comments
|
||||
if obj.metadata is not None:
|
||||
result["metadata"] = self.subgraph_translator.encode(obj.metadata)
|
||||
if obj.user:
|
||||
result["user"] = obj.user
|
||||
if obj.workspace:
|
||||
result["workspace"] = obj.workspace
|
||||
if obj.tags is not None:
|
||||
result["tags"] = obj.tags
|
||||
if obj.parent_id:
|
||||
|
|
@ -61,7 +61,7 @@ class ProcessingMetadataTranslator(Translator):
|
|||
document_id=data.get("document-id"),
|
||||
time=data.get("time"),
|
||||
flow=data.get("flow"),
|
||||
user=data.get("user"),
|
||||
workspace=data.get("workspace"),
|
||||
collection=data.get("collection"),
|
||||
tags=data.get("tags")
|
||||
)
|
||||
|
|
@ -77,8 +77,8 @@ class ProcessingMetadataTranslator(Translator):
|
|||
result["time"] = obj.time
|
||||
if obj.flow:
|
||||
result["flow"] = obj.flow
|
||||
if obj.user:
|
||||
result["user"] = obj.user
|
||||
if obj.workspace:
|
||||
result["workspace"] = obj.workspace
|
||||
if obj.collection:
|
||||
result["collection"] = obj.collection
|
||||
if obj.tags is not None:
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ class DocumentRagRequestTranslator(MessageTranslator):
|
|||
def decode(self, data: Dict[str, Any]) -> DocumentRagQuery:
|
||||
return DocumentRagQuery(
|
||||
query=data["query"],
|
||||
user=data.get("user", "trustgraph"),
|
||||
collection=data.get("collection", "default"),
|
||||
doc_limit=int(data.get("doc-limit", 20)),
|
||||
streaming=data.get("streaming", False)
|
||||
|
|
@ -19,7 +18,6 @@ class DocumentRagRequestTranslator(MessageTranslator):
|
|||
def encode(self, obj: DocumentRagQuery) -> Dict[str, Any]:
|
||||
return {
|
||||
"query": obj.query,
|
||||
"user": obj.user,
|
||||
"collection": obj.collection,
|
||||
"doc-limit": obj.doc_limit,
|
||||
"streaming": getattr(obj, "streaming", False)
|
||||
|
|
@ -96,7 +94,6 @@ class GraphRagRequestTranslator(MessageTranslator):
|
|||
def decode(self, data: Dict[str, Any]) -> GraphRagQuery:
|
||||
return GraphRagQuery(
|
||||
query=data["query"],
|
||||
user=data.get("user", "trustgraph"),
|
||||
collection=data.get("collection", "default"),
|
||||
entity_limit=int(data.get("entity-limit", 50)),
|
||||
triple_limit=int(data.get("triple-limit", 30)),
|
||||
|
|
@ -110,7 +107,6 @@ class GraphRagRequestTranslator(MessageTranslator):
|
|||
def encode(self, obj: GraphRagQuery) -> Dict[str, Any]:
|
||||
return {
|
||||
"query": obj.query,
|
||||
"user": obj.user,
|
||||
"collection": obj.collection,
|
||||
"entity-limit": obj.entity_limit,
|
||||
"triple-limit": obj.triple_limit,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ class RowsQueryRequestTranslator(MessageTranslator):
|
|||
|
||||
def decode(self, data: Dict[str, Any]) -> RowsQueryRequest:
|
||||
return RowsQueryRequest(
|
||||
user=data.get("user", "trustgraph"),
|
||||
collection=data.get("collection", "default"),
|
||||
query=data.get("query", ""),
|
||||
variables=data.get("variables", {}),
|
||||
|
|
@ -18,7 +17,6 @@ class RowsQueryRequestTranslator(MessageTranslator):
|
|||
|
||||
def encode(self, obj: RowsQueryRequest) -> Dict[str, Any]:
|
||||
result = {
|
||||
"user": obj.user,
|
||||
"collection": obj.collection,
|
||||
"query": obj.query,
|
||||
"variables": dict(obj.variables) if obj.variables else {}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ class SparqlQueryRequestTranslator(MessageTranslator):
|
|||
|
||||
def decode(self, data: Dict[str, Any]) -> SparqlQueryRequest:
|
||||
return SparqlQueryRequest(
|
||||
user=data.get("user", "trustgraph"),
|
||||
collection=data.get("collection", "default"),
|
||||
query=data.get("query", ""),
|
||||
limit=int(data.get("limit", 10000)),
|
||||
|
|
@ -22,7 +21,6 @@ class SparqlQueryRequestTranslator(MessageTranslator):
|
|||
|
||||
def encode(self, obj: SparqlQueryRequest) -> Dict[str, Any]:
|
||||
return {
|
||||
"user": obj.user,
|
||||
"collection": obj.collection,
|
||||
"query": obj.query,
|
||||
"limit": obj.limit,
|
||||
|
|
|
|||
|
|
@ -10,14 +10,12 @@ class StructuredQueryRequestTranslator(MessageTranslator):
|
|||
def decode(self, data: Dict[str, Any]) -> StructuredQueryRequest:
|
||||
return StructuredQueryRequest(
|
||||
question=data.get("question", ""),
|
||||
user=data.get("user", "trustgraph"), # Default fallback
|
||||
collection=data.get("collection", "default") # Default fallback
|
||||
collection=data.get("collection", "default")
|
||||
)
|
||||
|
||||
|
||||
def encode(self, obj: StructuredQueryRequest) -> Dict[str, Any]:
|
||||
return {
|
||||
"question": obj.question,
|
||||
"user": obj.user,
|
||||
"collection": obj.collection
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,16 +22,14 @@ class TriplesQueryRequestTranslator(MessageTranslator):
|
|||
o=o,
|
||||
g=g,
|
||||
limit=int(data.get("limit", 10000)),
|
||||
user=data.get("user", "trustgraph"),
|
||||
collection=data.get("collection", "default"),
|
||||
streaming=data.get("streaming", False),
|
||||
batch_size=int(data.get("batch-size", 20)),
|
||||
)
|
||||
|
||||
|
||||
def encode(self, obj: TriplesQueryRequest) -> Dict[str, Any]:
|
||||
result = {
|
||||
"limit": obj.limit,
|
||||
"user": obj.user,
|
||||
"collection": obj.collection,
|
||||
"streaming": obj.streaming,
|
||||
"batch-size": obj.batch_size,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue