versionhq 1.2.3.0__py3-none-any.whl → 1.2.3.4__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
@@ -32,7 +32,7 @@ from versionhq.agent_network.formation import form_agent_network
32
32
  from versionhq.task_graph.draft import workflow
33
33
 
34
34
 
35
- __version__ = "1.2.3.0"
35
+ __version__ = "1.2.3.4"
36
36
  __all__ = [
37
37
  "Agent",
38
38
 
@@ -2,92 +2,25 @@ import uuid
2
2
  from abc import ABC
3
3
  from datetime import datetime
4
4
  from typing import Any, Dict, List, Optional
5
- from typing_extensions import Self
5
+
6
6
  from pydantic import UUID4, InstanceOf, BaseModel, ConfigDict, Field, field_validator, model_validator
7
7
  from pydantic_core import PydanticCustomError
8
8
 
9
- from versionhq.clients.product.model import Product
10
- from versionhq.clients.customer.model import Customer
11
9
  from versionhq.agent.model import Agent
12
10
  from versionhq.agent_network.model import AgentNetwork
11
+ from versionhq.clients.product.model import Product
12
+ from versionhq.clients.customer.model import Customer
13
13
  from versionhq.tool.composio_tool_vars import ComposioAppName
14
14
 
15
15
 
16
- class ScoreFormat:
17
- def __init__(self, rate: float | int = 0, weight: int = 1):
18
- self.rate = rate
19
- self.weight = weight
20
- self.aggregate = rate * weight
21
-
22
-
23
- class Score:
24
- """
25
- Evaluate the score on 0 (no performance) to 1 scale.
26
- `rate`: Any float from 0.0 to 1.0 given by an agent.
27
- `weight`: Importance of each factor to the aggregated score.
28
- """
29
-
30
- def __init__(
31
- self,
32
- brand_tone: ScoreFormat = ScoreFormat(0, 0),
33
- audience: ScoreFormat = ScoreFormat(0, 0),
34
- track_record: ScoreFormat = ScoreFormat(0, 0),
35
- **kwargs: Optional[Dict[str, ScoreFormat]],
36
- ):
37
- self.brand_tone = brand_tone
38
- self.audience = audience
39
- self.track_record = track_record
40
- self.kwargs = kwargs
41
-
42
-
43
- def result(self) -> int:
44
- aggregate_score = int(self.brand_tone.aggregate) + int(self.audience.aggregate) + int(self.track_record.aggregate)
45
- denominator = self.brand_tone.weight + self.audience.weight + self.track_record.weight
46
-
47
- for k, v in self.kwargs.items():
48
- aggregate_score += v.aggregate
49
- denominator += v.weight
50
-
51
- if denominator == 0:
52
- return 0
53
-
54
- return round(aggregate_score / denominator, 2)
55
-
56
-
57
-
58
16
  class MessagingComponent(ABC, BaseModel):
59
17
  layer_id: int = Field(default=0, description="add id of the layer: 0, 1, 2")
60
18
  message: str = Field(default=None, max_length=1024, description="text message content to be sent")
61
- score: InstanceOf[Score] = Field(default=None)
19
+ score: Optional[float | int] = Field(default=None)
62
20
  condition: str = Field(default=None, description="condition to execute the next component")
63
21
  interval: Optional[str] = Field(default=None, description="ideal interval to set to assess the condition")
64
22
 
65
23
 
66
- def store_scoring_result(self, subject: str, score_raw: int | Score | ScoreFormat = None) -> Self:
67
- """
68
- Set up the `score` field
69
- """
70
-
71
- if isinstance(score_raw, Score):
72
- setattr(self, "score", score_raw)
73
-
74
- elif isinstance(score_raw, ScoreFormat):
75
- score_instance = Score()
76
- setattr(score_instance, subject, score_raw)
77
- setattr(self, "score", score_instance)
78
-
79
- elif isinstance(score_raw, int) or isinstance(score_raw, float):
80
- score_instance, score_format_instance = Score(), ScoreFormat(rate=score_raw, weight=1)
81
- setattr(score_instance, "kwargs", { subject: score_format_instance })
82
- setattr(self, "score", score_instance)
83
-
84
- else:
85
- pass
86
-
87
- return self
88
-
89
-
90
-
91
24
  class MessagingWorkflow(ABC, BaseModel):
92
25
  """
93
26
  Store 3 layers of messaging workflow sent to `customer` on the `product`
@@ -97,7 +97,7 @@ class LTMSQLiteStorage:
97
97
  ]
98
98
 
99
99
  except sqlite3.Error as e:
100
- self._logger.log(level="error", message=f"MEMORY ERROR: An error occurred while querying LTM: {str(e)}",color="red")
100
+ self._logger.log(level="error", message=f"MEMORY ERROR: An error occurred while querying LTM: {str(e)}", color="red")
101
101
  return None
102
102
 
103
103
 
@@ -1,4 +1,4 @@
1
- EVALUATE="""Evaluate the provided task output against the given task description, assigning a score between 0 (worst) and 1 (best) based on the specified criteria. Scores should be numerical (integers or decimals). Provide specific suggestions for improvement. Do not assign identical scores to different criteria unless otherwise you have clear reasons to do so:
1
+ EVALUATE="""Evaluate the provided task output against the given task description, assigning a score between 0 (worst) and 1 (best) based on the specified criteria. Scores should be numerical (integers or decimals). Weight should be numerical (integers or decimals) and represents importance of the criteria to the final result. Provide specific suggestions for improvement. Do not assign identical scores to different criteria unless otherwise you have clear reasons to do so:
2
2
  Task output: {task_output}
3
3
  Task description: {task_description}
4
4
  Evaluation criteria: {eval_criteria}
@@ -1,64 +1,22 @@
1
- from typing import List, Optional, Dict, Any
1
+ from typing import List, Any
2
2
  from typing_extensions import Self
3
3
 
4
4
  from pydantic import BaseModel, model_validator
5
+ import pandas as pd
6
+ from sklearn.preprocessing import MinMaxScaler
5
7
 
6
8
  from versionhq.memory.model import MemoryMetadata
7
9
 
8
- """
9
- Evaluate task output from accuracy, token consumption, and latency perspectives, and mark the score from 0 to 1.
10
- """
11
-
12
-
13
- class ScoreFormat:
14
- def __init__(self, rate: float | int = 0, weight: int = 1):
15
- self.rate = rate
16
- self.weight = weight
17
- self.aggregate = rate * weight
18
-
19
-
20
- class Score:
21
- """
22
- Evaluate the score on 0 (no performance) to 1 scale.
23
- `rate`: Any float from 0.0 to 1.0 given by an agent.
24
- `weight`: Importance of each factor to the aggregated score.
25
- """
26
-
27
- def __init__(self, config: Optional[Dict[str, ScoreFormat]] = None):
28
- self.config = config
29
-
30
- if self.config:
31
- for k, v in self.config.items():
32
- if isinstance(v, ScoreFormat):
33
- setattr(self, k, v)
34
-
35
-
36
- def result(self) -> float:
37
- aggregate_score, denominator = 0, 0
38
-
39
- for k, v in self.__dict__.items():
40
- aggregate_score += v.aggregate
41
- denominator += v.weight
42
-
43
- if denominator == 0:
44
- return 0
45
-
46
- return round(aggregate_score / denominator, 3)
47
-
48
10
 
49
11
  class EvaluationItem(BaseModel):
50
12
  """
51
13
  A Pydantic class to store the evaluation result with scoring and suggestion based on the given criteria.
14
+ This class will be used as a response format for the eval task.
52
15
  """
53
16
  criteria: str
54
17
  suggestion: str
55
18
  score: float
56
-
57
- def _format_score(self, weight: int = 1) -> ScoreFormat | None:
58
- if self.score and isinstance(self.score, float):
59
- return ScoreFormat(rate=self.score, weight=weight)
60
-
61
- else: return None
19
+ weight: int = 1
62
20
 
63
21
 
64
22
  class Evaluation(BaseModel):
@@ -111,33 +69,43 @@ class Evaluation(BaseModel):
111
69
  return shot_prompt
112
70
 
113
71
 
114
- @property
115
- def aggregate_score(self) -> float:
72
+ def _normalize_df(self) -> pd.DataFrame:
116
73
  """
117
- Calcurate aggregate score from evaluation items.
74
+ Creates a pandas DataFrame from a list of EvaluationItem objects containing 'weight' and 'score' columns, and normalizes them using MinMaxScaler.
75
+
76
+ Args:
77
+ items: A list of EvaluationItem objects.
78
+
79
+ Returns:
80
+ A pandas DataFrame with normalized 'weight' and 'score' columns, or an empty DataFrame if the input is empty.
118
81
  """
119
82
  if not self.items:
120
- return 0
83
+ return pd.DataFrame()
121
84
 
122
- aggregate_score = 0
123
- denominator = 0
85
+ data = { 'weight': [item.weight for item in self.items], 'score': [item.score for item in self.items] }
86
+ df = pd.DataFrame(data)
124
87
 
125
- for item in self.items:
126
- score_format = item._format_score()
127
- aggregate_score += score_format.aggregate if score_format else 0
128
- denominator += score_format.weight if score_format else 0
88
+ scaler = MinMaxScaler(feature_range=(0, 1))
89
+ df[['weight', 'score']] = scaler.fit_transform(df[['weight', 'score']])
129
90
 
130
- if denominator == 0:
91
+ return df
92
+
93
+
94
+ @property
95
+ def aggregate_score(self) -> int | float:
96
+ if not self.items:
131
97
  return 0
132
98
 
133
- return round(aggregate_score / denominator, 2)
99
+ df = self._normalize_df()
100
+ df['weighted_score'] = df['weight'] * df['score']
101
+ aggregate_score = round(df['weighted_score'].sum(), 3)
102
+ return aggregate_score
134
103
 
135
104
 
136
105
  @property
137
106
  def suggestion_summary(self) -> str | None:
138
- """
139
- Returns a summary of the suggestions
140
- """
107
+ """Returns a summary of the suggestions"""
108
+
141
109
  if not self.items:
142
110
  return None
143
111
 
versionhq/task/model.py CHANGED
@@ -228,13 +228,21 @@ class TaskOutput(BaseModel):
228
228
  self._tokens += task_eval._tokens
229
229
 
230
230
  if res.pydantic:
231
- item = EvaluationItem(score=res.pydantic.score, suggestion=res.pydantic.suggestion, criteria=res.pydantic.criteria)
231
+ item = EvaluationItem(
232
+ score=res.pydantic.score,
233
+ weight=res.pydantic.weight,
234
+ suggestion=res.pydantic.suggestion,
235
+ criteria=res.pydantic.criteria
236
+ )
232
237
  self.evaluation.items.append(item)
233
238
 
234
239
  else:
235
240
  try:
236
241
  item = EvaluationItem(
237
- score=float(res.json_dict["score"]), suggestion=res.json_dict["suggestion"], criteria=res.json_dict["criteria"]
242
+ score=float(res.json_dict["score"]),
243
+ weight=float(res.json_dict["weight"]),
244
+ suggestion=res.json_dict["suggestion"],
245
+ criteria=res.json_dict["criteria"]
238
246
  )
239
247
  self.evaluation.items.append(item)
240
248
  except Exception as e:
@@ -246,10 +254,7 @@ class TaskOutput(BaseModel):
246
254
 
247
255
  @property
248
256
  def aggregate_score(self) -> float | int:
249
- if self.evaluation is None:
250
- return 0
251
- else:
252
- self.evaluation.aggregate_score
257
+ return self.evaluation.aggregate_score if self.evaluation is not None else 0
253
258
 
254
259
 
255
260
  @property
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: versionhq
3
- Version: 1.2.3.0
3
+ Version: 1.2.3.4
4
4
  Summary: An agentic orchestration framework for building agent networks that handle task automation.
5
5
  Author-email: Kuriko Iwai <kuriko@versi0n.io>
6
6
  License: MIT License
@@ -48,8 +48,8 @@ Requires-Dist: regex==2024.11.6
48
48
  Requires-Dist: requests>=2.32.3
49
49
  Requires-Dist: pydantic>=2.10.6
50
50
  Requires-Dist: werkzeug>=3.1.3
51
- Requires-Dist: typing
52
- Requires-Dist: json-repair
51
+ Requires-Dist: typing>=0.0.0
52
+ Requires-Dist: json-repair>=0.0.0
53
53
  Requires-Dist: litellm>=1.55.8
54
54
  Requires-Dist: openai>=1.64.0
55
55
  Requires-Dist: composio-openai>=0.6.9
@@ -68,27 +68,24 @@ Requires-Dist: composio-core==0.7.0
68
68
  Requires-Dist: networkx>=3.4.2
69
69
  Requires-Dist: matplotlib>=3.10.0
70
70
  Requires-Dist: boto3>=1.37.1
71
- Provides-Extra: torch
72
- Requires-Dist: torch>=2.6.0; extra == "torch"
73
- Requires-Dist: torchvision>=0.21.0; extra == "torch"
74
- Requires-Dist: pytorch-triton-xpu>=3.2.0; sys_platform == "linux" and extra == "torch"
75
71
  Provides-Extra: docling
76
72
  Requires-Dist: docling>=2.25.2; extra == "docling"
77
73
  Provides-Extra: mem0ai
78
74
  Requires-Dist: mem0ai>=0.1.55; extra == "mem0ai"
79
75
  Provides-Extra: pdfplumber
80
76
  Requires-Dist: pdfplumber>=0.11.5; extra == "pdfplumber"
81
- Provides-Extra: pandas
82
- Requires-Dist: pandas>=2.2.3; extra == "pandas"
83
- Provides-Extra: numpy
84
- Requires-Dist: numpy>=1.26.4; extra == "numpy"
85
77
  Provides-Extra: pygraphviz
86
78
  Requires-Dist: pygraphviz>=1.14; extra == "pygraphviz"
87
79
  Provides-Extra: tools
88
80
  Requires-Dist: html2text>=2024.2.26; extra == "tools"
89
81
  Requires-Dist: sec-api>=1.0.28; extra == "tools"
90
- Provides-Extra: eval
91
- Requires-Dist: scikit-learn>=1.6.1; extra == "eval"
82
+ Provides-Extra: torch
83
+ Requires-Dist: torch>=2.6.0; extra == "torch"
84
+ Requires-Dist: torchvision>=0.21.0; extra == "torch"
85
+ Provides-Extra: evals
86
+ Requires-Dist: scikit-learn>=1.6.1; extra == "evals"
87
+ Requires-Dist: numpy>=1.26.4; extra == "evals"
88
+ Requires-Dist: pandas>=2.2.3; extra == "evals"
92
89
 
93
90
  # Overview
94
91
 
@@ -1,4 +1,4 @@
1
- versionhq/__init__.py,sha256=Co8oha5gA6GLy73HAkQ-HmC8IaXLGOK5YeIOT6KMnDc,2980
1
+ versionhq/__init__.py,sha256=OB2B9WOc-P9RyhFLEhs2zS0E34d7GwED1POMAfSp4Cg,2980
2
2
  versionhq/_utils/__init__.py,sha256=d-vYVcORZKG-kkLe_fzE8VbViDpAk9DDOKe2fVK25ew,178
3
3
  versionhq/_utils/i18n.py,sha256=TwA_PnYfDLA6VqlUDPuybdV9lgi3Frh_ASsb_X8jJo8,1483
4
4
  versionhq/_utils/llm_as_a_judge.py,sha256=RM0oYfoeanuUyUL3Ewl6_8Xn1F5Axd285UMH46kxG1I,2378
@@ -23,7 +23,7 @@ versionhq/clients/customer/model.py,sha256=_AtaVVMm9MgCwrQ-HTRQ2oXUMKrSCEfZwE2Jd
23
23
  versionhq/clients/product/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  versionhq/clients/product/model.py,sha256=3w__pug9XRe4LIm9wX8C8WKqi40r081Eb1q2vWk9UaU,3694
25
25
  versionhq/clients/workflow/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
- versionhq/clients/workflow/model.py,sha256=fqmTx8Y6P6i-sK045ENO88GDbf4WYY4hUA26RfEH8Ek,6011
26
+ versionhq/clients/workflow/model.py,sha256=_yCbmwzexjQqEGli7XX0vFG6yFnAOe9QDoMWQaU_qZE,3920
27
27
  versionhq/knowledge/__init__.py,sha256=qW7IgssTA4_bFFV9ziOcYRfGjlq1c8bkb-HnfWknpuQ,567
28
28
  versionhq/knowledge/_utils.py,sha256=YWRF8U533cfZes_gZqUvdj-K24MD2ri1R0gjc_aPYyc,402
29
29
  versionhq/knowledge/embedding.py,sha256=KfHc__1THxb5jrg1EMrF-v944RDuIr2hE0l-MtM3Bp0,6826
@@ -39,17 +39,17 @@ versionhq/memory/contextual_memory.py,sha256=QEMVvHuEXxY7M6-12S8HhyFKf108KfX8Zzt
39
39
  versionhq/memory/model.py,sha256=VQR1229t7GQPMItlGAHLtJrb6LrZfSoRA1DRW4z0SOU,8234
40
40
  versionhq/storage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
41
  versionhq/storage/base.py,sha256=p-Jas0fXQan_qotnRD6seQxrT2lj-uw9-SmHQhdppcs,355
42
- versionhq/storage/ltm_sqlite_storage.py,sha256=K0Assani1QfFuq5FMxkcMmRlmLUOvw-RNkKyMV70U3g,3956
42
+ versionhq/storage/ltm_sqlite_storage.py,sha256=LeJE4ZPUWjyY1E5nNCHoKujTHFDR2BO_LAMvAOX-WHg,3957
43
43
  versionhq/storage/mem0_storage.py,sha256=ZY8MELBWaINRv9YuRW5MxH7dj2cII-L0i3xSD6o1-2M,3781
44
44
  versionhq/storage/rag_storage.py,sha256=bS2eE874obarYl-4hT6ZWYWTRsqtfuGpKgKzERmM6Uo,7433
45
45
  versionhq/storage/task_output_storage.py,sha256=M8vInLJ5idGAq17w1juHKXtyPyF-B-rK_P8UcqD-Px8,5357
46
46
  versionhq/storage/utils.py,sha256=r5ghA_ktdR2IuzlzKqZYCjsNxztEMzyhWLneA4cFuWY,748
47
47
  versionhq/task/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
- versionhq/task/evaluation.py,sha256=iRLzppqwKaiGpbsr9gMbf6T7NQe6rxTA6OBcWhmiCKs,4473
48
+ versionhq/task/evaluation.py,sha256=yKnqj3UwdNAMaFEBZmWWf0Hc09-M9hM8VETnaovlFco,3817
49
49
  versionhq/task/formatter.py,sha256=N8Kmk9vtrMtBdgJ8J7RmlKNMdZWSmV8O1bDexmCWgU0,643
50
- versionhq/task/model.py,sha256=rJmyEUM1DnX1mkN_0etYXqBJP_YADXVXZhFR5R-h8ZA,28915
50
+ versionhq/task/model.py,sha256=8HQLzzAfM03gHL5M_7oL7UW-mZvI7rPCJ2Jxsv49VtI,29122
51
51
  versionhq/task/structured_response.py,sha256=4q-hQPu7oMMHHXEzh9YW4SJ7N5eCZ7OfZ65juyl_jCI,5000
52
- versionhq/task/TEMPLATES/Description.py,sha256=EkwJHc65G32MjWyn3rcp0ATmMaVPHuYKaykyByU5r4g,751
52
+ versionhq/task/TEMPLATES/Description.py,sha256=hKhpbz0ztbkUMXz9KiL-P40fis9OB5ICOdL9jCtgAhU,864
53
53
  versionhq/task_graph/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
54
  versionhq/task_graph/colors.py,sha256=naJCx4Vho4iuJtbW8USUXb-M5uYvd5ds2p8qbjUfRus,669
55
55
  versionhq/task_graph/draft.py,sha256=l18XacRsbDhAv6CvKMnUMI26IDuizA1UNWHbL1q5gn4,5099
@@ -62,8 +62,8 @@ versionhq/tool/decorator.py,sha256=C4ZM7Xi2gwtEMaSeRo-geo_g_MAkY77WkSLkAuY0AyI,1
62
62
  versionhq/tool/model.py,sha256=Nc2f9frTK5tH4kh6EeEAk1Fi1w19kEXLOcsBwHCS1a4,12189
63
63
  versionhq/tool/rag_tool.py,sha256=dW5o-83V4bMFFJEj3PUm7XjblwrYJGmZVBlCpPj6CeM,3852
64
64
  versionhq/tool/tool_handler.py,sha256=2m41K8qo5bGCCbwMFferEjT-XZ-mE9F0mDUOBkgivOI,1416
65
- versionhq-1.2.3.0.dist-info/LICENSE,sha256=cRoGGdM73IiDs6nDWKqPlgSv7aR4n-qBXYnJlCMHCeE,1082
66
- versionhq-1.2.3.0.dist-info/METADATA,sha256=ecBan7bE1D3h9QCoGrmez3swRMqLhJsxilByj0pJCyg,21535
67
- versionhq-1.2.3.0.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
68
- versionhq-1.2.3.0.dist-info/top_level.txt,sha256=DClQwxDWqIUGeRJkA8vBlgeNsYZs4_nJWMonzFt5Wj0,10
69
- versionhq-1.2.3.0.dist-info/RECORD,,
65
+ versionhq-1.2.3.4.dist-info/LICENSE,sha256=cRoGGdM73IiDs6nDWKqPlgSv7aR4n-qBXYnJlCMHCeE,1082
66
+ versionhq-1.2.3.4.dist-info/METADATA,sha256=6ctQ8pQeU6rOuUOO0AxAmVy4v0MYDk2QJbZyCWHFBR0,21418
67
+ versionhq-1.2.3.4.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
68
+ versionhq-1.2.3.4.dist-info/top_level.txt,sha256=DClQwxDWqIUGeRJkA8vBlgeNsYZs4_nJWMonzFt5Wj0,10
69
+ versionhq-1.2.3.4.dist-info/RECORD,,