versionhq 1.2.1.8__py3-none-any.whl → 1.2.1.10__py3-none-any.whl
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.
- versionhq/__init__.py +1 -1
- versionhq/task_graph/draft.py +28 -17
- versionhq/task_graph/model.py +14 -7
- {versionhq-1.2.1.8.dist-info → versionhq-1.2.1.10.dist-info}/METADATA +1 -1
- {versionhq-1.2.1.8.dist-info → versionhq-1.2.1.10.dist-info}/RECORD +8 -8
- {versionhq-1.2.1.8.dist-info → versionhq-1.2.1.10.dist-info}/LICENSE +0 -0
- {versionhq-1.2.1.8.dist-info → versionhq-1.2.1.10.dist-info}/WHEEL +0 -0
- {versionhq-1.2.1.8.dist-info → versionhq-1.2.1.10.dist-info}/top_level.txt +0 -0
versionhq/__init__.py
CHANGED
versionhq/task_graph/draft.py
CHANGED
@@ -49,11 +49,12 @@ def workflow(final_output: Type[BaseModel], context: Any = None, human: bool = T
|
|
49
49
|
)
|
50
50
|
|
51
51
|
task = Task(
|
52
|
-
description=f"Design a resource-efficient workflow to achieve the following goal: {final_output_prompt}.
|
52
|
+
description=dedent(f"Design a resource-efficient workflow to achieve the following goal: {final_output_prompt}. The workflow should consist of a list of detailed tasks that represent decision making points, each with the following information:\nname: A concise name of the task\ndescription: A concise description of the task.\nconnections: A list of target tasks that this task connects to.\ndependency_types: The type of dependency between this task and each of its connected task. \noutput: key output from the task.\n\nUse the following dependency types: {dep_type_prompt}.\n\nPrioritize minimizing resource consumption (computation, memory, and data transfer) when defining tasks, connections, and dependencies. Consider how data is passed between tasks and aim to reduce unnecessary data duplication or transfer. Explain any design choices made to optimize resource usage."),
|
53
53
|
response_fields=[
|
54
54
|
ResponseField(title="tasks", data_type=list, items=dict, properties=[
|
55
55
|
ResponseField(title="name", data_type=str),
|
56
56
|
ResponseField(title="description", data_type=str),
|
57
|
+
ResponseField(title="output", data_type=str),
|
57
58
|
ResponseField(title="connections", data_type=list, items=str),
|
58
59
|
ResponseField(title="dependency_types", data_type=list, items=str),
|
59
60
|
]
|
@@ -66,11 +67,20 @@ def workflow(final_output: Type[BaseModel], context: Any = None, human: bool = T
|
|
66
67
|
return None
|
67
68
|
|
68
69
|
task_items = res.json_dict["tasks"]
|
69
|
-
tasks = [
|
70
|
-
|
70
|
+
tasks, nodes = [], []
|
71
|
+
for item in task_items:
|
72
|
+
class Output(BaseModel):
|
73
|
+
item["output"]: str
|
74
|
+
|
75
|
+
task = Task(name=item["name"], description=item["description"], pydantic_output=Output)
|
76
|
+
tasks.append(task)
|
77
|
+
nodes.append(Node(task=task))
|
78
|
+
|
79
|
+
|
71
80
|
task_graph = TaskGraph(
|
72
81
|
nodes={node.identifier: node for node in nodes},
|
73
|
-
|
82
|
+
concl_format=final_output,
|
83
|
+
concl=None,
|
74
84
|
should_reform=True,
|
75
85
|
)
|
76
86
|
|
@@ -79,23 +89,24 @@ def workflow(final_output: Type[BaseModel], context: Any = None, human: bool = T
|
|
79
89
|
dependency_types = [DependencyType[dt] if DependencyType[dt] else DependencyType.FINISH_TO_START for dt in res["dependency_types"]]
|
80
90
|
|
81
91
|
for i, target_task_name in enumerate(res["connections"]):
|
82
|
-
source = [v for
|
83
|
-
target = [v for
|
92
|
+
source = [v for v in task_graph.nodes.values() if v.task.name == res["name"]][0]
|
93
|
+
target = [v for v in task_graph.nodes.values() if v.task.name == target_task_name][0]
|
84
94
|
dependency_type = dependency_types[i]
|
85
|
-
task_graph.add_dependency(
|
95
|
+
task_graph.add_dependency(
|
96
|
+
source_node_identifier=source.identifier, target_node_identifier=target.identifier, dependency_type=dependency_type)
|
97
|
+
|
86
98
|
|
87
|
-
|
88
|
-
# task_graph.visualize()
|
99
|
+
task_graph.visualize()
|
89
100
|
|
90
|
-
|
91
|
-
|
92
|
-
|
101
|
+
if human:
|
102
|
+
print('Proceed? Y/n:')
|
103
|
+
x = input()
|
93
104
|
|
94
|
-
|
95
|
-
|
105
|
+
if x.lower() == "y":
|
106
|
+
print("ok. generating agent network")
|
96
107
|
|
97
|
-
|
98
|
-
|
99
|
-
|
108
|
+
else:
|
109
|
+
request = input("request?")
|
110
|
+
print('ok. regenerating the graph based on your input: ', request)
|
100
111
|
|
101
112
|
return task_graph
|
versionhq/task_graph/model.py
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
+
import matplotlib
|
2
|
+
matplotlib.use('agg')
|
3
|
+
|
1
4
|
import enum
|
2
5
|
import uuid
|
3
6
|
import networkx as nx
|
4
7
|
import matplotlib.pyplot as plt
|
5
8
|
from abc import ABC
|
6
9
|
from typing import List, Any, Optional, Callable, Dict, Type, Tuple
|
7
|
-
from typing_extensions import Self
|
8
10
|
|
9
|
-
from pydantic import BaseModel, InstanceOf, Field, UUID4, field_validator
|
11
|
+
from pydantic import BaseModel, InstanceOf, Field, UUID4, field_validator
|
10
12
|
from pydantic_core import PydanticCustomError
|
11
13
|
|
12
14
|
from versionhq.task.model import Task, TaskOutput
|
@@ -60,7 +62,7 @@ class Node(BaseModel):
|
|
60
62
|
def is_independent(self) -> bool:
|
61
63
|
return not self.in_degree_nodes and not self.out_degree_nodes
|
62
64
|
|
63
|
-
def handle_task_execution(self, agent: Agent = None, context: str = None) -> TaskOutput | None:
|
65
|
+
def handle_task_execution(self, agent: Agent = None, context: str = None, format: Type[BaseModel] = None) -> TaskOutput | None:
|
64
66
|
"""
|
65
67
|
Start task execution and update status accordingly.
|
66
68
|
"""
|
@@ -72,6 +74,7 @@ class Node(BaseModel):
|
|
72
74
|
self.status = TaskStatus.ERROR
|
73
75
|
return None
|
74
76
|
|
77
|
+
self.task.pydantic_output = self.task.pydantic_output if self.task.pydantic_output else format if type(format) == BaseModel else None
|
75
78
|
res = self.task.execute(agent=agent, context=context)
|
76
79
|
self.status = TaskStatus.COMPLETED if res else TaskStatus.ERROR
|
77
80
|
return res
|
@@ -176,7 +179,7 @@ class Edge(BaseModel):
|
|
176
179
|
return False
|
177
180
|
|
178
181
|
|
179
|
-
def activate(self) -> TaskOutput | None:
|
182
|
+
def activate(self, format: Type[BaseModel] = None) -> TaskOutput | None:
|
180
183
|
"""
|
181
184
|
Activates the edge to initiate task execution of the target node.
|
182
185
|
"""
|
@@ -194,7 +197,7 @@ class Edge(BaseModel):
|
|
194
197
|
time.sleep(self.lag)
|
195
198
|
|
196
199
|
context = self.source.task.output.raw if self.data_transfer else None
|
197
|
-
res = self.target.handle_task_execution(context=context)
|
200
|
+
res = self.target.handle_task_execution(context=context, format=format)
|
198
201
|
return res
|
199
202
|
|
200
203
|
|
@@ -398,7 +401,7 @@ class TaskGraph(Graph):
|
|
398
401
|
return self._return_node_object(identifier).status
|
399
402
|
|
400
403
|
|
401
|
-
def visualize(self, layout: str = None):
|
404
|
+
def visualize(self, layout: str = None, should_save: bool = False):
|
402
405
|
from matplotlib.lines import Line2D
|
403
406
|
from versionhq.task_graph.colors import white, black, darkgrey, grey, primary, orange, lightgreen, green, darkgreen, darkergreen
|
404
407
|
|
@@ -475,7 +478,9 @@ class TaskGraph(Graph):
|
|
475
478
|
|
476
479
|
plt.legend(handles=legend_elements, loc='lower right')
|
477
480
|
plt.title(f"vhq-Diagram {str(self.id)}")
|
478
|
-
|
481
|
+
|
482
|
+
if should_save:
|
483
|
+
self._save(title=f"vhq-Diagram {str(self.id)}")
|
479
484
|
plt.show(block=False)
|
480
485
|
|
481
486
|
|
@@ -559,5 +564,7 @@ class TaskGraph(Graph):
|
|
559
564
|
node_identifier = edge.target.identifier
|
560
565
|
self.outputs.update({ node_identifier: res })
|
561
566
|
|
567
|
+
self.concl = res
|
568
|
+
self.concl_template = self.concl_template if self.concl_template else res.pydantic.__class__ if res.pydantic else None
|
562
569
|
# last_task_output = [v for v in self.outputs.values()][len([v for v in self.outputs.values()]) - 1] if [v for v in self.outputs.values()] else None
|
563
570
|
return res, self.outputs
|
@@ -1,4 +1,4 @@
|
|
1
|
-
versionhq/__init__.py,sha256=
|
1
|
+
versionhq/__init__.py,sha256=ClLVOtkbqwq-6OR4_q7e_YoKHUYVPUtIkwVtq12gfQ8,2883
|
2
2
|
versionhq/_utils/__init__.py,sha256=dzoZr4cBlh-2QZuPzTdehPUCe9lP1dmRtauD7qTjUaA,158
|
3
3
|
versionhq/_utils/i18n.py,sha256=TwA_PnYfDLA6VqlUDPuybdV9lgi3Frh_ASsb_X8jJo8,1483
|
4
4
|
versionhq/_utils/logger.py,sha256=zgogTwAY-ujDLrdryAKhdtoaNe1nOFajmEN0V8aMR34,3155
|
@@ -52,8 +52,8 @@ versionhq/task/structured_response.py,sha256=4q-hQPu7oMMHHXEzh9YW4SJ7N5eCZ7OfZ65
|
|
52
52
|
versionhq/task/TEMPLATES/Description.py,sha256=V-4kh8xpQTKOcDMi2xnuP-fcNk6kuoz1_5tYBlDLQWQ,420
|
53
53
|
versionhq/task_graph/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
54
54
|
versionhq/task_graph/colors.py,sha256=naJCx4Vho4iuJtbW8USUXb-M5uYvd5ds2p8qbjUfRus,669
|
55
|
-
versionhq/task_graph/draft.py,sha256=
|
56
|
-
versionhq/task_graph/model.py,sha256=
|
55
|
+
versionhq/task_graph/draft.py,sha256=_I8H1Tgbox4xcWpZNWRNEPUhdb02H44gl9DDz2HArlU,5078
|
56
|
+
versionhq/task_graph/model.py,sha256=njyHQyHrVTZP46iVkC6YvuMnGcS40vOy1wszRtf7DHY,23971
|
57
57
|
versionhq/tool/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
58
58
|
versionhq/tool/cache_handler.py,sha256=iL8FH7X0G-cdT0uhJwzuhLDaadTXOdfybZcDy151-es,1085
|
59
59
|
versionhq/tool/composio_tool.py,sha256=38mEiVvTkuw1BLD233Bl1Gwxbpss1yfQiZLTWwX6BdA,8648
|
@@ -61,8 +61,8 @@ versionhq/tool/composio_tool_vars.py,sha256=FvBuEXsOQUYnN7RTFxT20kAkiEYkxWKkiVtg
|
|
61
61
|
versionhq/tool/decorator.py,sha256=C4ZM7Xi2gwtEMaSeRo-geo_g_MAkY77WkSLkAuY0AyI,1205
|
62
62
|
versionhq/tool/model.py,sha256=PO4zNWBZcJhYVur381YL1dy6zqurio2jWjtbxOxZMGI,12194
|
63
63
|
versionhq/tool/tool_handler.py,sha256=2m41K8qo5bGCCbwMFferEjT-XZ-mE9F0mDUOBkgivOI,1416
|
64
|
-
versionhq-1.2.1.
|
65
|
-
versionhq-1.2.1.
|
66
|
-
versionhq-1.2.1.
|
67
|
-
versionhq-1.2.1.
|
68
|
-
versionhq-1.2.1.
|
64
|
+
versionhq-1.2.1.10.dist-info/LICENSE,sha256=cRoGGdM73IiDs6nDWKqPlgSv7aR4n-qBXYnJlCMHCeE,1082
|
65
|
+
versionhq-1.2.1.10.dist-info/METADATA,sha256=7uewLR8nv9scszLK4QlDFhx47T_vhPwgXTkpm_D1ETg,22033
|
66
|
+
versionhq-1.2.1.10.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
67
|
+
versionhq-1.2.1.10.dist-info/top_level.txt,sha256=DClQwxDWqIUGeRJkA8vBlgeNsYZs4_nJWMonzFt5Wj0,10
|
68
|
+
versionhq-1.2.1.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|