versionhq 1.2.1.12__py3-none-any.whl → 1.2.1.14__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/agent/model.py +23 -7
- versionhq/task/model.py +1 -1
- versionhq/task_graph/draft.py +9 -10
- {versionhq-1.2.1.12.dist-info → versionhq-1.2.1.14.dist-info}/METADATA +1 -1
- {versionhq-1.2.1.12.dist-info → versionhq-1.2.1.14.dist-info}/RECORD +9 -9
- {versionhq-1.2.1.12.dist-info → versionhq-1.2.1.14.dist-info}/LICENSE +0 -0
- {versionhq-1.2.1.12.dist-info → versionhq-1.2.1.14.dist-info}/WHEEL +0 -0
- {versionhq-1.2.1.12.dist-info → versionhq-1.2.1.14.dist-info}/top_level.txt +0 -0
versionhq/__init__.py
CHANGED
versionhq/agent/model.py
CHANGED
@@ -3,7 +3,6 @@ import uuid
|
|
3
3
|
from typing import Any, Dict, List, Optional, TypeVar, Callable, Type
|
4
4
|
from typing_extensions import Self
|
5
5
|
from dotenv import load_dotenv
|
6
|
-
import litellm
|
7
6
|
|
8
7
|
from pydantic import UUID4, BaseModel, Field, InstanceOf, PrivateAttr, model_validator, field_validator
|
9
8
|
from pydantic_core import PydanticCustomError
|
@@ -57,9 +56,7 @@ class TokenProcess:
|
|
57
56
|
# @track_agent()
|
58
57
|
class Agent(BaseModel):
|
59
58
|
"""
|
60
|
-
A class to store agent
|
61
|
-
Agents must have `role`, `goal`, and `llm` = DEFAULT_MODEL_NAME as default.
|
62
|
-
Then run validation on `backstory`, `llm`, `tools`, `rpm` (request per min), `knowledge`, and `memory`.
|
59
|
+
A Pydantic class to store an agent object. Agents must have `role` and `goal` to start.
|
63
60
|
"""
|
64
61
|
|
65
62
|
__hash__ = object.__hash__
|
@@ -453,7 +450,6 @@ class Agent(BaseModel):
|
|
453
450
|
return self
|
454
451
|
|
455
452
|
|
456
|
-
|
457
453
|
def invoke(
|
458
454
|
self,
|
459
455
|
prompts: str,
|
@@ -515,8 +511,6 @@ class Agent(BaseModel):
|
|
515
511
|
raise ValueError("Invalid response from LLM call - None or empty.")
|
516
512
|
|
517
513
|
|
518
|
-
|
519
|
-
|
520
514
|
def execute_task(self, task, context: Optional[Any] = None, task_tools: Optional[List[Tool | ToolSet]] = list()) -> str:
|
521
515
|
"""
|
522
516
|
Format a task prompt, adding context from knowledge and memory (if given), and invoke LLM.
|
@@ -582,5 +576,27 @@ class Agent(BaseModel):
|
|
582
576
|
return raw_response
|
583
577
|
|
584
578
|
|
579
|
+
def start(self, context: Any = None) -> Any | None:
|
580
|
+
"""
|
581
|
+
Defines and executes a task when it is not given and returns TaskOutput object.
|
582
|
+
"""
|
583
|
+
|
584
|
+
if not self.goal or not self.role:
|
585
|
+
return None
|
586
|
+
|
587
|
+
from versionhq.task.model import Task, ResponseField
|
588
|
+
|
589
|
+
class Output(BaseModel):
|
590
|
+
result: str
|
591
|
+
steps: list[str]
|
592
|
+
|
593
|
+
task = Task(
|
594
|
+
description=f"Generate a simple result in a sentence to achieve the goal: {self.goal}. If needed, list up necessary steps in concise manner.",
|
595
|
+
pydantic_output=Output
|
596
|
+
)
|
597
|
+
res = task.execute(agent=self, context=context)
|
598
|
+
return res
|
599
|
+
|
600
|
+
|
585
601
|
def __repr__(self):
|
586
602
|
return f"Agent(role={self.role}, goal={self.goal}"
|
versionhq/task/model.py
CHANGED
@@ -363,7 +363,7 @@ Response format: {response_format}
|
|
363
363
|
Ref. Output image: {output_formats_to_follow}
|
364
364
|
"""
|
365
365
|
else:
|
366
|
-
output_prompt = "Return your response as a valid JSON serializable string, enclosed in double quotes. Do not use single quotes, trailing commas, or other non-standard JSON syntax."
|
366
|
+
output_prompt = "You MUST Return your response as a valid JSON serializable string, enclosed in double quotes. Do not use single quotes, trailing commas, or other non-standard JSON syntax."
|
367
367
|
|
368
368
|
return dedent(output_prompt)
|
369
369
|
|
versionhq/task_graph/draft.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import sys
|
2
2
|
from typing import Type, Any
|
3
|
-
from pydantic import BaseModel
|
3
|
+
from pydantic import BaseModel
|
4
4
|
from pydantic._internal._model_construction import ModelMetaclass
|
5
5
|
from textwrap import dedent
|
6
6
|
if 'pydantic.main' not in sys.modules:
|
@@ -10,11 +10,11 @@ sys.modules['pydantic.main'].ModelMetaclass = ModelMetaclass
|
|
10
10
|
|
11
11
|
from versionhq.agent.model import Agent
|
12
12
|
from versionhq.task.model import ResponseField
|
13
|
-
from versionhq.task_graph.model import TaskGraph, Task, DependencyType, Node
|
13
|
+
from versionhq.task_graph.model import TaskGraph, Task, DependencyType, Node
|
14
14
|
from versionhq._utils.logger import Logger
|
15
15
|
|
16
16
|
|
17
|
-
def workflow(final_output: Type[BaseModel], context: Any = None, human: bool =
|
17
|
+
def workflow(final_output: Type[BaseModel], context: Any = None, human: bool = False) -> TaskGraph | None:
|
18
18
|
"""
|
19
19
|
Generate a TaskGraph object to generate the givne final_output most resource-efficiently.
|
20
20
|
"""
|
@@ -52,13 +52,12 @@ def workflow(final_output: Type[BaseModel], context: Any = None, human: bool = T
|
|
52
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 in a word.\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
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
)
|
55
|
+
ResponseField(title="name", data_type=str),
|
56
|
+
ResponseField(title="description", data_type=str),
|
57
|
+
ResponseField(title="output", data_type=str),
|
58
|
+
ResponseField(title="connections", data_type=list, items=str),
|
59
|
+
ResponseField(title="dependency_types", data_type=list, items=str),
|
60
|
+
])
|
62
61
|
]
|
63
62
|
)
|
64
63
|
res = task.execute(agent=graph_expert, context=[context_prompt, context])
|
@@ -1,4 +1,4 @@
|
|
1
|
-
versionhq/__init__.py,sha256=
|
1
|
+
versionhq/__init__.py,sha256=iRSTMITQMFFixAJsBgg0Og100UdL-svAq0H0EoXjM6U,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
|
@@ -7,7 +7,7 @@ versionhq/_utils/usage_metrics.py,sha256=NXF18dn5NNvGK7EsQ4AAghpR8ppYOjMx6ABenLL
|
|
7
7
|
versionhq/_utils/vars.py,sha256=bZ5Dx_bFKlt3hi4-NNGXqdk7B23If_WaTIju2fiTyPQ,57
|
8
8
|
versionhq/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
9
|
versionhq/agent/inhouse_agents.py,sha256=snDtgDmvZB2bZKH_RTcz5uFOMl3MTjLJwTQBebFt8hk,2532
|
10
|
-
versionhq/agent/model.py,sha256=
|
10
|
+
versionhq/agent/model.py,sha256=eFmkNuCJhXRhdYJR59J5PFxw5aghLvBrPRj4NXd7J0w,25873
|
11
11
|
versionhq/agent/parser.py,sha256=riG0dkdQCxH7uJ0AbdVdg7WvL0BXhUgJht0VtQvxJBc,4082
|
12
12
|
versionhq/agent/rpm_controller.py,sha256=grezIxyBci_lDlwAlgWFRyR5KOocXeOhYkgN02dNFNE,2360
|
13
13
|
versionhq/agent/TEMPLATES/Backstory.py,sha256=IAhGnnt6VUMe3wO6IzeyZPDNu7XE7Uiu3VEXUreOcKs,532
|
@@ -47,12 +47,12 @@ versionhq/task/evaluate.py,sha256=WdUgjbZL62XrxyWe5MTz29scfzwmuAHGxJ7GvAB8Fmk,39
|
|
47
47
|
versionhq/task/formation.py,sha256=WH604q9bRmWH7KQCrk2qKJwisCopYX5CjJvsj4TgFjI,6894
|
48
48
|
versionhq/task/formatter.py,sha256=N8Kmk9vtrMtBdgJ8J7RmlKNMdZWSmV8O1bDexmCWgU0,643
|
49
49
|
versionhq/task/log_handler.py,sha256=LT7YnO7gcPR9IZS7eRvMjnHh8crMBFtqduxd8dxIbkk,1680
|
50
|
-
versionhq/task/model.py,sha256=
|
50
|
+
versionhq/task/model.py,sha256=EcUW7nktGBd9CBenKLh-5HBRa02wrwYF6WeF8ju04tc,28538
|
51
51
|
versionhq/task/structured_response.py,sha256=4q-hQPu7oMMHHXEzh9YW4SJ7N5eCZ7OfZ65juyl_jCI,5000
|
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=
|
55
|
+
versionhq/task_graph/draft.py,sha256=rt41kJ85g5l501K7PC-PVtn1oWmKABKsznorfivcDpc,5096
|
56
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
|
@@ -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.14.dist-info/LICENSE,sha256=cRoGGdM73IiDs6nDWKqPlgSv7aR4n-qBXYnJlCMHCeE,1082
|
65
|
+
versionhq-1.2.1.14.dist-info/METADATA,sha256=s7vOZmrrn59L5L6ItVtEVzg92yHmrv58PXAr805sbZQ,22033
|
66
|
+
versionhq-1.2.1.14.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
67
|
+
versionhq-1.2.1.14.dist-info/top_level.txt,sha256=DClQwxDWqIUGeRJkA8vBlgeNsYZs4_nJWMonzFt5Wj0,10
|
68
|
+
versionhq-1.2.1.14.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|