versionhq 1.1.7.3__py3-none-any.whl → 1.1.7.5__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 CHANGED
@@ -17,7 +17,7 @@ from versionhq.team.model import Team, TeamOutput
17
17
  from versionhq.tool.model import Tool
18
18
 
19
19
 
20
- __version__ = "1.1.7.3"
20
+ __version__ = "1.1.7.5"
21
21
  __all__ = [
22
22
  "Agent",
23
23
  "Customer",
@@ -61,21 +61,21 @@ class MessagingComponent(ABC, BaseModel):
61
61
  score: Union[float, InstanceOf[Score]] = Field(default=None)
62
62
 
63
63
 
64
- def store_scoring_result(self, scoring_subject: str, score: Union[int, Score, ScoreFormat] = None):
64
+ def store_scoring_result(self, scoring_subject: str, score_raw: Union[int, Score, ScoreFormat] = None):
65
65
  """
66
66
  Set up the `score` field
67
67
  """
68
68
 
69
- if isinstance(score, Score):
70
- setattr(self, "score", score)
69
+ if isinstance(score_raw, Score):
70
+ setattr(self, "score", score_raw)
71
71
 
72
- elif isinstance(score, ScoreFormat):
72
+ elif isinstance(score_raw, ScoreFormat):
73
73
  score_instance = Score()
74
- setattr(score_instance, scoring_subject, score)
74
+ setattr(score_instance, scoring_subject, score_raw)
75
75
  setattr(self, "score", score_instance)
76
76
 
77
- elif isinstance(score, int) or isinstance(score, float):
78
- score_instance, score_format_instance = Score(), ScoreFormat(rate=score, weight=1)
77
+ elif isinstance(score_raw, int) or isinstance(score_raw, float):
78
+ score_instance, score_format_instance = Score(), ScoreFormat(rate=score_raw, weight=1)
79
79
  setattr(score_instance, "kwargs", { scoring_subject: score_format_instance })
80
80
  setattr(self, "score", score_instance)
81
81
 
versionhq/task/model.py CHANGED
@@ -158,6 +158,7 @@ class Task(BaseModel):
158
158
  async_execution: bool = Field(default=False,description="whether the task should be executed asynchronously or not")
159
159
  config: Optional[Dict[str, Any]] = Field(default=None, description="configuration for the agent")
160
160
  callback: Optional[Any] = Field(default=None, description="callback to be executed after the task is completed.")
161
+ callback_kwargs: Optional[Dict[str, Any]] = Field(default_factory=dict, description="kwargs for the callback when the callback is callable")
161
162
 
162
163
  # recording
163
164
  processed_by_agents: Set[str] = Field(default_factory=set)
@@ -371,7 +372,7 @@ Your outputs MUST adhere to the following format and should NOT include any irre
371
372
 
372
373
 
373
374
  # task execution
374
- def execute_sync(self, agent, context: Optional[str] = None, callback_kwargs: Dict[str, Any] = None) -> TaskOutput:
375
+ def execute_sync(self, agent, context: Optional[str] = None) -> TaskOutput:
375
376
  """
376
377
  Execute the task synchronously.
377
378
  When the task has context, make sure we have executed all the tasks in the context first.
@@ -380,12 +381,12 @@ Your outputs MUST adhere to the following format and should NOT include any irre
380
381
  if self.context:
381
382
  for task in self.context:
382
383
  if task.output is None:
383
- task._execute_core(agent, context, callback_kwargs)
384
+ task._execute_core(agent, context)
384
385
 
385
386
  return self._execute_core(agent, context)
386
387
 
387
388
 
388
- def execute_async(self, agent, context: Optional[str] = None, callback_kwargs: Dict[str, Any] = None) -> Future[TaskOutput]:
389
+ def execute_async(self, agent, context: Optional[str] = None) -> Future[TaskOutput]:
389
390
  """
390
391
  Execute the task asynchronously.
391
392
  """
@@ -394,36 +395,55 @@ Your outputs MUST adhere to the following format and should NOT include any irre
394
395
  threading.Thread(
395
396
  daemon=True,
396
397
  target=self._execute_task_async,
397
- args=(agent, context, callback_kwargs, future),
398
+ args=(agent, context, future),
398
399
  ).start()
399
400
  return future
400
401
 
401
402
 
402
- def _execute_task_async(self, agent, context: Optional[str], callback_kwargs: Dict[str, Any], future: Future[TaskOutput]) -> None:
403
+ def _execute_task_async(self, agent, context: Optional[str], future: Future[TaskOutput]) -> None:
403
404
  """
404
405
  Execute the task asynchronously with context handling.
405
406
  """
406
407
 
407
- result = self._execute_core(agent, context, callback_kwargs)
408
+ result = self._execute_core(agent, context)
408
409
  future.set_result(result)
409
410
 
410
411
 
411
- def _execute_core(self, agent, context: Optional[str], callback_kwargs: Optional[Dict[str, Any]] = None) -> TaskOutput:
412
+ def _execute_core(self, agent, context: Optional[str]) -> TaskOutput:
412
413
  """
413
414
  Run the core execution logic of the task.
414
415
  To speed up the process, when the format is not expected to return, we will skip the conversion process.
416
+ When the task is allowed to delegate to another agent, we will select a responsible one in order of manager_agent > peer_agent > anoymous agent.
415
417
  """
416
418
  from versionhq.agent.model import Agent
419
+ from versionhq.team.model import Team
417
420
 
418
421
  self.prompt_context = context
419
422
 
420
423
  if self.allow_delegation:
421
- agent = Agent(role="delegated_agent", goal=agent.goal, llm=agent.llm) #! REFINEME - logic to pick up the high performer
424
+ agent_to_delegate = None
425
+
426
+ if hasattr(agent, "team") and isinstance(agent.team, Team):
427
+ if agent.team.manager_agent:
428
+ agent_to_delegate = agent.team.manager_agent
429
+ else:
430
+ peers = [member.agent for member in agent.team.members if member.is_manager == False and member.agent.id is not agent.id]
431
+ if len(peers) > 0:
432
+ agent_to_delegate = peers[0]
433
+ else:
434
+ agent_to_delegate = Agent(role="delegated_agent", goal=agent.goal, llm=agent.llm)
435
+
436
+ agent = agent_to_delegate
422
437
  self.delegations += 1
423
438
 
424
- output_raw = agent.execute_task(task=self, context=context)
425
- output_json_dict = self.create_json_output(raw_result=output_raw) if self.expected_output_json is True else None
426
- output_pydantic = self.create_pydantic_output(output_json_dict=output_json_dict) if self.expected_output_pydantic else None
439
+ output_raw, output_json_dict, output_pydantic = agent.execute_task(task=self, context=context), None, None
440
+
441
+ if self.expected_output_json:
442
+ output_json_dict = self.create_json_output(raw_result=output_raw)
443
+
444
+ if self.expected_output_pydantic:
445
+ output_pydantic = self.create_pydantic_output(output_json_dict=output_json_dict)
446
+
427
447
  task_output = TaskOutput(
428
448
  task_id=self.id,
429
449
  raw=output_raw,
@@ -436,10 +456,7 @@ Your outputs MUST adhere to the following format and should NOT include any irre
436
456
  # self._set_end_execution_time(start_time)
437
457
 
438
458
  if self.callback:
439
- if isinstance(self.callback, Callable):
440
- self.callback(**callback_kwargs)
441
- else:
442
- self.callback(self.output)
459
+ self.callback({ **self.callback_kwargs, **self.output.__dict__ })
443
460
 
444
461
  # if self._execution_span:
445
462
  # # self._telemetry.task_ended(self._execution_span, self, agent.team)
versionhq/team/model.py CHANGED
@@ -111,7 +111,7 @@ class TeamOutput(BaseModel):
111
111
  class TeamMember(ABC, BaseModel):
112
112
  agent: Agent | None = Field(default=None, description="store the agent to be a member")
113
113
  is_manager: bool = Field(default=False)
114
- task: Task | None = Field(default=None)
114
+ task: Optional[Task] = Field(default=None)
115
115
 
116
116
 
117
117
  class Team(BaseModel):
@@ -145,7 +145,6 @@ class Team(BaseModel):
145
145
  default_factory=list,
146
146
  description="list of callback functions to be executed after the team kickoff. i.e., store the result in repo"
147
147
  )
148
- task_callback: Optional[Any] = Field(default=None, description="callback to be executed after each task for all agents execution")
149
148
  step_callback: Optional[Any] = Field(default=None, description="callback to be executed after each step for all agents execution")
150
149
 
151
150
  verbose: bool = Field(default=True)
@@ -379,7 +378,7 @@ class Team(BaseModel):
379
378
  """
380
379
  Executes tasks sequentially and returns the final output in TeamOutput class.
381
380
  When we have a manager agent, we will start from executing manager agent's tasks.
382
- Priority
381
+ Priority:
383
382
  1. Team tasks > 2. Manager task > 3. Member tasks (in order of index)
384
383
  """
385
384
 
@@ -412,7 +411,7 @@ class Team(BaseModel):
412
411
 
413
412
  if task.async_execution:
414
413
  context = create_raw_outputs(tasks=[task, ],task_outputs=([last_sync_output,] if last_sync_output else []))
415
- future = task.execute_async(agent=responsible_agent, context=context,
414
+ future = task.execute_async(agent=responsible_agent, context=context
416
415
  # tools=responsible_agent.tools
417
416
  )
418
417
  futures.append((task, future, task_index))
@@ -422,7 +421,7 @@ class Team(BaseModel):
422
421
  futures.clear()
423
422
 
424
423
  context = create_raw_outputs(tasks=[task,], task_outputs=([ last_sync_output,] if last_sync_output else [] ))
425
- task_output = task.execute_sync(agent=responsible_agent, context=context,
424
+ task_output = task.execute_sync(agent=responsible_agent, context=context
426
425
  # tools=responsible_agent.tools
427
426
  )
428
427
  if responsible_agent is self.manager_agent:
@@ -463,9 +462,6 @@ class Team(BaseModel):
463
462
  # self._inputs = inputs
464
463
  # self._interpolate_inputs(inputs)
465
464
 
466
- for task in self.tasks:
467
- if not task.callback:
468
- task.callback = self.task_callback
469
465
 
470
466
  # i18n = I18N(prompt_file=self.prompt_file)
471
467
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: versionhq
3
- Version: 1.1.7.3
3
+ Version: 1.1.7.5
4
4
  Summary: LLM orchestration frameworks for model-agnostic AI agents that handle complex outbound workflows
5
5
  Author-email: Kuriko Iwai <kuriko@versi0n.io>
6
6
  License: MIT License
@@ -52,7 +52,11 @@ Requires-Dist: wheel>=0.45.1
52
52
 
53
53
  # Overview
54
54
 
55
- ![MIT license](https://img.shields.io/badge/License-MIT-green) [![Publisher](https://github.com/versionHQ/multi-agent-system/actions/workflows/publish.yml/badge.svg)](https://github.com/versionHQ/multi-agent-system/actions/workflows/publish.yml) ![PyPi](https://img.shields.io/badge/pypi-v1.1.7.0-blue) ![python ver](https://img.shields.io/badge/Python-3.12/3.13-purple) ![pyenv ver](https://img.shields.io/badge/pyenv-2.4.23-orange)
55
+ ![MIT license](https://img.shields.io/badge/License-MIT-green)
56
+ [![Publisher](https://github.com/versionHQ/multi-agent-system/actions/workflows/publish.yml/badge.svg)](https://github.com/versionHQ/multi-agent-system/actions/workflows/publish.yml)
57
+ ![PyPI](https://img.shields.io/badge/PyPI-v1.1.7.5-blue)
58
+ ![python ver](https://img.shields.io/badge/Python-3.12/3.13-purple)
59
+ ![pyenv ver](https://img.shields.io/badge/pyenv-2.4.23-orange)
56
60
 
57
61
 
58
62
  An LLM orchestration frameworks for multi-agent systems with RAG to autopilot outbound workflows.
@@ -64,10 +68,11 @@ Messaging workflows are created at individual level, and will be deployed on thi
64
68
 
65
69
  **Visit:**
66
70
 
67
- - [Landing page](https://home.versi0n.io)
68
- - [Client app](https://versi0n.io/)
69
- - [Orchestration frameworks](https://github.com/versionHQ/multi-agent-system)
70
- - [Test client app](https://github.com/versionHQ/test-client-app)
71
+ - [PyPI](https://pypi.org/project/versionhq/)
72
+ - [Github (LLM orchestration)](https://github.com/versionHQ/multi-agent-system)
73
+ - [Github (Test client app)](https://github.com/versionHQ/test-client-app)
74
+ - [Use case](https://versi0n.io/) - client app (alpha)
75
+
71
76
 
72
77
  <hr />
73
78
 
@@ -87,6 +92,8 @@ LLM-powered `agent`s and `team`s use `tool`s and their own knowledge to complete
87
92
 
88
93
  - [Key Features](#key-features)
89
94
  - [Usage](#usage)
95
+ - [Case 1. Build an AI agent on LLM of your choice and execute a task:](#case-1-build-an-ai-agent-on-llm-of-your-choice-and-execute-a-task)
96
+ - [Case 2. Form a team to handle multiple tasks:](#case-2-form-a-team-to-handle-multiple-tasks)
90
97
  - [Technologies Used](#technologies-used)
91
98
  - [Project Structure](#project-structure)
92
99
  - [Setup](#setup)
@@ -132,7 +139,8 @@ Multiple `agents` can form a `team` to complete complex tasks together.
132
139
 
133
140
  2. You can use the `versionhq` module in your Python app.
134
141
 
135
- - **i.e.,** Make LLM-based agent execute the task and return JSON dict.
142
+
143
+ ### Case 1. Build an AI agent on LLM of your choice and execute a task:
136
144
 
137
145
  ```
138
146
  from versionhq.agent.model import Agent
@@ -142,6 +150,7 @@ Multiple `agents` can form a `team` to complete complex tasks together.
142
150
  role="demo",
143
151
  goal="amazing project goal",
144
152
  skillsets=["skill_1", "skill_2", ],
153
+ tools=["amazing RAG tool",]
145
154
  llm="llm-of-your-choice"
146
155
  )
147
156
 
@@ -165,7 +174,41 @@ This will return a dictionary with keys defined in the `ResponseField`.
165
174
  { test1: "answer1", "test2": ["answer2-1", "answer2-2", "answer2-3",] }
166
175
  ```
167
176
 
168
- For more info: [PyPI package](https://pypi.org/project/versionhq/)
177
+ ### Case 2. Form a team to handle multiple tasks:
178
+
179
+ ```
180
+ from versionhq.agent.model import Agent
181
+ from versionhq.task.model import Task, ResponseField
182
+ from versionhq.team.model import Team, TeamMember
183
+
184
+ agent_a = Agent(role="agent a", goal="My amazing goals", llm="llm-of-your-choice")
185
+ agent_b = Agent(role="agent b", goal="My amazing goals", llm="llm-of-your-choice")
186
+
187
+ task_1 = Task(
188
+ description="Analyze the client's business model.",
189
+ output_field_list=[ResponseField(title="test1", type=str, required=True),],
190
+ allow_delegation=True
191
+ )
192
+
193
+ task_2 = Task(
194
+ description="Define the cohort.",
195
+ output_field_list=[ResponseField(title="test1", type=int, required=True),],
196
+ allow_delegation=False
197
+ )
198
+
199
+ team = Team(
200
+ members=[
201
+ TeamMember(agent=agent_a, is_manager=False, task=task_1),
202
+ TeamMember(agent=agent_b, is_manager=True, task=task_2),
203
+ ],
204
+ )
205
+ res = team.kickoff()
206
+ ```
207
+
208
+ This will return a list with dictionaries with keys defined in the `ResponseField` of each task.
209
+
210
+ Tasks can be delegated to a team manager, peers in the team, or completely new agent.
211
+
169
212
 
170
213
  <hr />
171
214
 
@@ -1,4 +1,4 @@
1
- versionhq/__init__.py,sha256=EToQMoZAxs1MXIIOAOuj-McBRRO8WmAkCj4JJMKdgS0,871
1
+ versionhq/__init__.py,sha256=HUTPmQJfxelI9dE_8G3mSK6--29L_B9zbIs_adJ1SJI,871
2
2
  versionhq/_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  versionhq/_utils/cache_handler.py,sha256=zDQKzIn7vp-M2-uepHFxgJstjfftZS5mzXKL_-4uVvI,370
4
4
  versionhq/_utils/i18n.py,sha256=TwA_PnYfDLA6VqlUDPuybdV9lgi3Frh_ASsb_X8jJo8,1483
@@ -18,22 +18,22 @@ versionhq/clients/customer/model.py,sha256=rQnCv_wdCdrYAsUjyB6X6ULiuWfqcBBoarXcQ
18
18
  versionhq/clients/product/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  versionhq/clients/product/model.py,sha256=Us3UnzYlub6ipBislMN-JrvxZx0ocl9PtQJINJ8XtBA,2385
20
20
  versionhq/clients/workflow/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
- versionhq/clients/workflow/model.py,sha256=8EbrUdS0vUhutx3_8M8A0Dw1BXpCqp5AFWbg4SGHj9M,5695
21
+ versionhq/clients/workflow/model.py,sha256=qpRCDwULhSLWDFkSYrvXW5m07bKDrwttTmqsYA9ZVP4,5727
22
22
  versionhq/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  versionhq/llm/llm_vars.py,sha256=YZoXqFBW7XpclUZ14_AAz7WOjoyCXnGcI959GSpX2q0,5343
24
24
  versionhq/llm/model.py,sha256=PdwisrlrsDqd6gXwXCyGbGTRTeGZ8SXpt_gfua8qunk,8266
25
25
  versionhq/task/__init__.py,sha256=g4mCATnn1mUXxsfQ5p6IpPawr8O421wVIT8kMKEcxQw,180
26
26
  versionhq/task/formatter.py,sha256=N8Kmk9vtrMtBdgJ8J7RmlKNMdZWSmV8O1bDexmCWgU0,643
27
- versionhq/task/model.py,sha256=wbDXLfGBSGfFafRrj_EQkJRDz99bcHTRmBtlhTFt3-4,17926
27
+ versionhq/task/model.py,sha256=4Uh0OBLUO_YXaejxHbOHtNa4vckgI3abSaPz80_s9X4,18519
28
28
  versionhq/team/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
- versionhq/team/model.py,sha256=JlbQRp3oBDj1xhjcjqW7pNmqpvYCC-ojZJ1RmJsnSWM,20071
29
+ versionhq/team/model.py,sha256=RyspmYVtXW3f4MKjWT1mnpM9XdE435d8HbEQms7LHMU,19821
30
30
  versionhq/team/team_planner.py,sha256=B1UOn_DYVVterUn2CAd80jfO4sViJCCXPJA3abSSugg,2143
31
31
  versionhq/tool/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
32
  versionhq/tool/decorator.py,sha256=Y-j4jkoujD5LUvpe8uf3p5Zagk2XVaRKC9rkIE-2geo,1189
33
33
  versionhq/tool/model.py,sha256=JZOEcZRIEfcrjL8DgrFYDt4YNgMF8rXS26RK6D2x9mc,6906
34
34
  versionhq/tool/tool_handler.py,sha256=e-2VfG9zFpfPG_oMoPXye93GDovs7FuUASWQwUTLrJ0,1498
35
- versionhq-1.1.7.3.dist-info/LICENSE,sha256=7CCXuMrAjPVsUvZrsBq9DsxI2rLDUSYXR_qj4yO_ZII,1077
36
- versionhq-1.1.7.3.dist-info/METADATA,sha256=SWavJEaaRBeuOexx0gHwsTvgqZirMXDmAVxVImrVraQ,14413
37
- versionhq-1.1.7.3.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
38
- versionhq-1.1.7.3.dist-info/top_level.txt,sha256=DClQwxDWqIUGeRJkA8vBlgeNsYZs4_nJWMonzFt5Wj0,10
39
- versionhq-1.1.7.3.dist-info/RECORD,,
35
+ versionhq-1.1.7.5.dist-info/LICENSE,sha256=7CCXuMrAjPVsUvZrsBq9DsxI2rLDUSYXR_qj4yO_ZII,1077
36
+ versionhq-1.1.7.5.dist-info/METADATA,sha256=g95oUiLVJPtABZEz1CLjq2opMbjWMLtD0XLXu3zG4Rw,15801
37
+ versionhq-1.1.7.5.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
38
+ versionhq-1.1.7.5.dist-info/top_level.txt,sha256=DClQwxDWqIUGeRJkA8vBlgeNsYZs4_nJWMonzFt5Wj0,10
39
+ versionhq-1.1.7.5.dist-info/RECORD,,