mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 00:16:23 +02:00
Fix config inconsistency (#609)
* Plural/singular confusion in config key * Flow class vs flow blueprint nomenclature change * Update docs & CLI to reflect the above
This commit is contained in:
parent
99f17d1b9d
commit
b08db761d7
36 changed files with 816 additions and 814 deletions
|
|
@ -28,42 +28,42 @@ class Flow:
|
|||
def id(self, id="default"):
|
||||
return FlowInstance(api=self, id=id)
|
||||
|
||||
def list_classes(self):
|
||||
def list_blueprints(self):
|
||||
|
||||
# The input consists of system and prompt strings
|
||||
input = {
|
||||
"operation": "list-classes",
|
||||
"operation": "list-blueprints",
|
||||
}
|
||||
|
||||
return self.request(request = input)["class-names"]
|
||||
return self.request(request = input)["blueprint-names"]
|
||||
|
||||
def get_class(self, class_name):
|
||||
def get_blueprint(self, blueprint_name):
|
||||
|
||||
# The input consists of system and prompt strings
|
||||
input = {
|
||||
"operation": "get-class",
|
||||
"class-name": class_name,
|
||||
"operation": "get-blueprint",
|
||||
"blueprint-name": blueprint_name,
|
||||
}
|
||||
|
||||
return json.loads(self.request(request = input)["class-definition"])
|
||||
return json.loads(self.request(request = input)["blueprint-definition"])
|
||||
|
||||
def put_class(self, class_name, definition):
|
||||
def put_blueprint(self, blueprint_name, definition):
|
||||
|
||||
# The input consists of system and prompt strings
|
||||
input = {
|
||||
"operation": "put-class",
|
||||
"class-name": class_name,
|
||||
"class-definition": json.dumps(definition),
|
||||
"operation": "put-blueprint",
|
||||
"blueprint-name": blueprint_name,
|
||||
"blueprint-definition": json.dumps(definition),
|
||||
}
|
||||
|
||||
self.request(request = input)
|
||||
|
||||
def delete_class(self, class_name):
|
||||
def delete_blueprint(self, blueprint_name):
|
||||
|
||||
# The input consists of system and prompt strings
|
||||
input = {
|
||||
"operation": "delete-class",
|
||||
"class-name": class_name,
|
||||
"operation": "delete-blueprint",
|
||||
"blueprint-name": blueprint_name,
|
||||
}
|
||||
|
||||
self.request(request = input)
|
||||
|
|
@ -87,13 +87,13 @@ class Flow:
|
|||
|
||||
return json.loads(self.request(request = input)["flow"])
|
||||
|
||||
def start(self, class_name, id, description, parameters=None):
|
||||
def start(self, blueprint_name, id, description, parameters=None):
|
||||
|
||||
# The input consists of system and prompt strings
|
||||
input = {
|
||||
"operation": "start-flow",
|
||||
"flow-id": id,
|
||||
"class-name": class_name,
|
||||
"blueprint-name": blueprint_name,
|
||||
"description": description,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,13 +63,13 @@ class FlowProcessor(AsyncProcessor):
|
|||
logger.info(f"Got config version {version}")
|
||||
|
||||
# Skip over invalid data
|
||||
if "flows-active" not in config: return
|
||||
if "active-flow" not in config: return
|
||||
|
||||
# Check there's configuration information for me
|
||||
if self.id in config["flows-active"]:
|
||||
if self.id in config["active-flow"]:
|
||||
|
||||
# Get my flow config
|
||||
flow_config = json.loads(config["flows-active"][self.id])
|
||||
flow_config = json.loads(config["active-flow"][self.id])
|
||||
|
||||
else:
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ class FlowRequestTranslator(MessageTranslator):
|
|||
def to_pulsar(self, data: Dict[str, Any]) -> FlowRequest:
|
||||
return FlowRequest(
|
||||
operation=data.get("operation"),
|
||||
class_name=data.get("class-name"),
|
||||
class_definition=data.get("class-definition"),
|
||||
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")
|
||||
|
|
@ -21,10 +21,10 @@ class FlowRequestTranslator(MessageTranslator):
|
|||
|
||||
if obj.operation is not None:
|
||||
result["operation"] = obj.operation
|
||||
if obj.class_name is not None:
|
||||
result["class-name"] = obj.class_name
|
||||
if obj.class_definition is not None:
|
||||
result["class-definition"] = obj.class_definition
|
||||
if obj.blueprint_name is not None:
|
||||
result["blueprint-name"] = obj.blueprint_name
|
||||
if obj.blueprint_definition is not None:
|
||||
result["blueprint-definition"] = obj.blueprint_definition
|
||||
if obj.description is not None:
|
||||
result["description"] = obj.description
|
||||
if obj.flow_id is not None:
|
||||
|
|
@ -44,12 +44,12 @@ class FlowResponseTranslator(MessageTranslator):
|
|||
def from_pulsar(self, obj: FlowResponse) -> Dict[str, Any]:
|
||||
result = {}
|
||||
|
||||
if obj.class_names is not None:
|
||||
result["class-names"] = obj.class_names
|
||||
if obj.blueprint_names is not None:
|
||||
result["blueprint-names"] = obj.blueprint_names
|
||||
if obj.flow_ids is not None:
|
||||
result["flow-ids"] = obj.flow_ids
|
||||
if obj.class_definition is not None:
|
||||
result["class-definition"] = obj.class_definition
|
||||
if obj.blueprint_definition is not None:
|
||||
result["blueprint-definition"] = obj.blueprint_definition
|
||||
if obj.flow is not None:
|
||||
result["flow"] = obj.flow
|
||||
if obj.description is not None:
|
||||
|
|
|
|||
|
|
@ -7,27 +7,27 @@ from ..core.primitives import Error
|
|||
############################################################################
|
||||
|
||||
# Flow service:
|
||||
# list_classes() -> (classname[])
|
||||
# get_class(classname) -> (class)
|
||||
# put_class(class) -> (class)
|
||||
# delete_class(classname) -> ()
|
||||
# list_blueprints() -> (blueprintname[])
|
||||
# get_blueprint(blueprintname) -> (blueprint)
|
||||
# put_blueprint(blueprint) -> (blueprint)
|
||||
# delete_blueprint(blueprintname) -> ()
|
||||
#
|
||||
# list_flows() -> (flowid[])
|
||||
# get_flow(flowid) -> (flow)
|
||||
# start_flow(flowid, classname) -> ()
|
||||
# start_flow(flowid, blueprintname) -> ()
|
||||
# stop_flow(flowid) -> ()
|
||||
|
||||
# Prompt services, abstract the prompt generation
|
||||
@dataclass
|
||||
class FlowRequest:
|
||||
operation: str = "" # list-classes, get-class, put-class, delete-class
|
||||
operation: str = "" # list-blueprints, get-blueprint, put-blueprint, delete-blueprint
|
||||
# list-flows, get-flow, start-flow, stop-flow
|
||||
|
||||
# get_class, put_class, delete_class, start_flow
|
||||
class_name: str = ""
|
||||
# get_blueprint, put_blueprint, delete_blueprint, start_flow
|
||||
blueprint_name: str = ""
|
||||
|
||||
# put_class
|
||||
class_definition: str = ""
|
||||
# put_blueprint
|
||||
blueprint_definition: str = ""
|
||||
|
||||
# start_flow
|
||||
description: str = ""
|
||||
|
|
@ -40,14 +40,14 @@ class FlowRequest:
|
|||
|
||||
@dataclass
|
||||
class FlowResponse:
|
||||
# list_classes
|
||||
class_names: list[str] = field(default_factory=list)
|
||||
# list_blueprints
|
||||
blueprint_names: list[str] = field(default_factory=list)
|
||||
|
||||
# list_flows
|
||||
flow_ids: list[str] = field(default_factory=list)
|
||||
|
||||
# get_class
|
||||
class_definition: str = ""
|
||||
# get_blueprint
|
||||
blueprint_definition: str = ""
|
||||
|
||||
# get_flow
|
||||
flow: str = ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue