zrb 1.9.11__py3-none-any.whl → 1.9.13__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.
- zrb/task/llm/error.py +12 -7
- zrb/task/llm/history.py +31 -17
- zrb/util/git_diff_model.py +10 -7
- zrb/util/git_subtree_model.py +8 -9
- zrb/util/todo_model.py +23 -17
- {zrb-1.9.11.dist-info → zrb-1.9.13.dist-info}/METADATA +1 -1
- {zrb-1.9.11.dist-info → zrb-1.9.13.dist-info}/RECORD +9 -9
- {zrb-1.9.11.dist-info → zrb-1.9.13.dist-info}/WHEEL +0 -0
- {zrb-1.9.11.dist-info → zrb-1.9.13.dist-info}/entry_points.txt +0 -0
zrb/task/llm/error.py
CHANGED
@@ -1,18 +1,23 @@
|
|
1
1
|
import json
|
2
2
|
from typing import TYPE_CHECKING, Optional
|
3
3
|
|
4
|
-
from pydantic import BaseModel
|
5
|
-
|
6
4
|
if TYPE_CHECKING:
|
7
5
|
from openai import APIError
|
8
6
|
|
9
7
|
|
10
8
|
# Define a structured error model for tool execution failures
|
11
|
-
class ToolExecutionError
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
class ToolExecutionError:
|
10
|
+
def __init__(
|
11
|
+
self,
|
12
|
+
tool_name: str,
|
13
|
+
error_type: str,
|
14
|
+
message: str,
|
15
|
+
details: Optional[str] = None,
|
16
|
+
):
|
17
|
+
self.tool_name = tool_name
|
18
|
+
self.error_type = error_type
|
19
|
+
self.message = message
|
20
|
+
self.details = details
|
16
21
|
|
17
22
|
|
18
23
|
def extract_api_error_details(error: "APIError") -> str:
|
zrb/task/llm/history.py
CHANGED
@@ -4,8 +4,6 @@ from collections.abc import Callable
|
|
4
4
|
from copy import deepcopy
|
5
5
|
from typing import Any, Optional
|
6
6
|
|
7
|
-
from pydantic import BaseModel, Field
|
8
|
-
|
9
7
|
from zrb.attr.type import StrAttr
|
10
8
|
from zrb.context.any_context import AnyContext
|
11
9
|
from zrb.context.any_shared_context import AnySharedContext
|
@@ -16,19 +14,31 @@ from zrb.util.run import run_async
|
|
16
14
|
|
17
15
|
|
18
16
|
# Define the new ConversationHistoryData model
|
19
|
-
class ConversationHistoryData
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
17
|
+
class ConversationHistoryData:
|
18
|
+
def __init__(
|
19
|
+
self,
|
20
|
+
long_term_context: str = "",
|
21
|
+
conversation_summary: str = "",
|
22
|
+
history: Optional[ListOfDict] = None,
|
23
|
+
messages: Optional[ListOfDict] = None,
|
24
|
+
):
|
25
|
+
self.long_term_context = long_term_context
|
26
|
+
self.conversation_summary = conversation_summary
|
27
|
+
self.history = (
|
28
|
+
history
|
29
|
+
if history is not None
|
30
|
+
else (messages if messages is not None else [])
|
31
|
+
)
|
32
|
+
|
33
|
+
def to_dict(self) -> dict[str, Any]:
|
34
|
+
return {
|
35
|
+
"long_term_context": self.long_term_context,
|
36
|
+
"conversation_summary": self.conversation_summary,
|
37
|
+
"history": self.history,
|
38
|
+
}
|
39
|
+
|
40
|
+
def model_dump_json(self, indent: int = 2) -> str:
|
41
|
+
return json.dumps(self.to_dict(), indent=indent)
|
32
42
|
|
33
43
|
@classmethod
|
34
44
|
async def read_from_sources(
|
@@ -81,7 +91,11 @@ class ConversationHistoryData(BaseModel):
|
|
81
91
|
return data # Already a valid instance
|
82
92
|
if isinstance(data, dict):
|
83
93
|
# This handles both the new format and the old {'context': ..., 'history': ...}
|
84
|
-
return cls
|
94
|
+
return cls(
|
95
|
+
long_term_context=data.get("long_term_context", ""),
|
96
|
+
conversation_summary=data.get("conversation_summary", ""),
|
97
|
+
history=data.get("history", data.get("messages")),
|
98
|
+
)
|
85
99
|
elif isinstance(data, list):
|
86
100
|
# Handle very old format (just a list) - wrap it
|
87
101
|
ctx.log_warning(
|
@@ -183,7 +197,7 @@ async def write_conversation_history(
|
|
183
197
|
ctx, conversation_history_file_attr, render_history_file
|
184
198
|
)
|
185
199
|
if history_file != "":
|
186
|
-
write_file(history_file, history_data.
|
200
|
+
write_file(history_file, json.dumps(history_data.to_dict(), indent=2))
|
187
201
|
|
188
202
|
|
189
203
|
def replace_system_prompt_in_history_list(
|
zrb/util/git_diff_model.py
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
class DiffResult:
|
2
|
+
def __init__(
|
3
|
+
self,
|
4
|
+
created: list[str] | None = None,
|
5
|
+
removed: list[str] | None = None,
|
6
|
+
updated: list[str] | None = None,
|
7
|
+
):
|
8
|
+
self.created = created if created is not None else []
|
9
|
+
self.removed = removed if removed is not None else []
|
10
|
+
self.updated = updated if updated is not None else []
|
zrb/util/git_subtree_model.py
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
|
1
|
+
class SingleSubTreeConfig:
|
2
|
+
def __init__(self, repo_url: str, branch: str, prefix: str):
|
3
|
+
self.repo_url = repo_url
|
4
|
+
self.branch = branch
|
5
|
+
self.prefix = prefix
|
2
6
|
|
3
7
|
|
4
|
-
class
|
5
|
-
|
6
|
-
|
7
|
-
prefix: str
|
8
|
-
|
9
|
-
|
10
|
-
class SubTreeConfig(BaseModel):
|
11
|
-
data: dict[str, SingleSubTreeConfig]
|
8
|
+
class SubTreeConfig:
|
9
|
+
def __init__(self, data: dict[str, SingleSubTreeConfig]):
|
10
|
+
self.data = data
|
zrb/util/todo_model.py
CHANGED
@@ -1,27 +1,33 @@
|
|
1
1
|
import datetime
|
2
|
+
import re
|
2
3
|
|
3
|
-
from pydantic import BaseModel, Field, model_validator
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
creation_date = values.get("creation_date")
|
5
|
+
class TodoTaskModel:
|
6
|
+
def __init__(
|
7
|
+
self,
|
8
|
+
description: str,
|
9
|
+
priority: str | None = "D",
|
10
|
+
completed: bool = False,
|
11
|
+
projects: list[str] | None = None,
|
12
|
+
contexts: list[str] | None = None,
|
13
|
+
keyval: dict[str, str] | None = None,
|
14
|
+
creation_date: datetime.date | None = None,
|
15
|
+
completion_date: datetime.date | None = None,
|
16
|
+
):
|
17
|
+
if priority is not None and not re.match(r"^[A-Z]$", priority):
|
18
|
+
raise ValueError("Invalid priority format")
|
20
19
|
if completion_date and not creation_date:
|
21
20
|
raise ValueError(
|
22
21
|
"creation_date must be specified if completion_date is set."
|
23
22
|
)
|
24
|
-
|
23
|
+
self.priority = priority
|
24
|
+
self.completed = completed
|
25
|
+
self.description = description
|
26
|
+
self.projects = projects if projects is not None else []
|
27
|
+
self.contexts = contexts if contexts is not None else []
|
28
|
+
self.keyval = keyval if keyval is not None else {}
|
29
|
+
self.creation_date = creation_date
|
30
|
+
self.completion_date = completion_date
|
25
31
|
|
26
32
|
def get_additional_info_length(self):
|
27
33
|
"""
|
@@ -341,8 +341,8 @@ zrb/task/llm/agent.py,sha256=BZHbz-YXgSdm1tTwGMR_maqcd3yMFGSdzLyDjuxT_XI,6702
|
|
341
341
|
zrb/task/llm/config.py,sha256=TlyH925_fboIlK2Ixf34tynmenqs9s9rfsnPs4jff78,3490
|
342
342
|
zrb/task/llm/context.py,sha256=LGGQ_mb1dWorfshHjGgXEW_pRweGj-6MZcIUFq3AHy4,2213
|
343
343
|
zrb/task/llm/context_enrichment.py,sha256=djY4fE9C0zUxJPrrb2xDboBXr_2kPUS_b4HjqslVpHg,6051
|
344
|
-
zrb/task/llm/error.py,sha256=
|
345
|
-
zrb/task/llm/history.py,sha256=
|
344
|
+
zrb/task/llm/error.py,sha256=0YE8Unv8H1HPb9QzaCBbykEBKtr8JyUWt6dywPuNOUg,3812
|
345
|
+
zrb/task/llm/history.py,sha256=dqCwJYRoMVrvyMHb4M6-KLcwAUF4tbDCP7qgD1h694s,8540
|
346
346
|
zrb/task/llm/history_summarization.py,sha256=V0G1BiISnxxmD8040PrvT0_dfqGE7zbLtk74KUpuqig,6050
|
347
347
|
zrb/task/llm/print_node.py,sha256=zocTKi9gZDxl2I6KNu095TmMc13Yip6SNuWYnswS680,4060
|
348
348
|
zrb/task/llm/prompt.py,sha256=qhR8qS8RgaQ23D3amaHSHnBNv_NOnFB_1uxaQNc8KFw,3417
|
@@ -378,9 +378,9 @@ zrb/util/codemod/modify_module.py,sha256=2mzi_NxJ-kNFo5G0U_Rqb3JoYQl1s6Izt7b_wAl
|
|
378
378
|
zrb/util/cron.py,sha256=UWqqhhM7DDTPx6wjCIdBndnVh3NRu-sdKazp8aZkXh8,3833
|
379
379
|
zrb/util/file.py,sha256=tm_8qn0vEM8Hz46yXUcvFHfsLtQNqidQaEuB85xqhFE,2806
|
380
380
|
zrb/util/git.py,sha256=GS08OqE-gs6mN-_VqACN82DbI81nzG3FiXeim_-jVAU,8193
|
381
|
-
zrb/util/git_diff_model.py,sha256=
|
381
|
+
zrb/util/git_diff_model.py,sha256=Tg2q6oxQ5chryThzjs0cLcKFGM03CnqvusTo_Ug_oX4,369
|
382
382
|
zrb/util/git_subtree.py,sha256=AyQWCWEi2EIzEpYXRnYN55157KMUql0WHj70QNw5PHU,4612
|
383
|
-
zrb/util/git_subtree_model.py,sha256=
|
383
|
+
zrb/util/git_subtree_model.py,sha256=GB0SJxROdjObMEKRrm6cHV2Fsda3aqEb2JxVwo1sfnM,293
|
384
384
|
zrb/util/group.py,sha256=T82yr3qg9I5k10VPXkMyrIRIqyfzadSH813bqzwKEPI,4718
|
385
385
|
zrb/util/init_path.py,sha256=9eN7CkWNGhDBpjTQs2j9YHVMzui7Y8DEb1WP4aTPzeo,659
|
386
386
|
zrb/util/load.py,sha256=DK0KYSlu48HCoGPqnW1IxnE3pHrZSPCstfz8Fjyqqv8,2140
|
@@ -390,10 +390,10 @@ zrb/util/string/conversion.py,sha256=sMmstzbrNgLvWAQukqoXz45JtsNpJrniudAtzJaQlYw
|
|
390
390
|
zrb/util/string/format.py,sha256=MwWGAwSdtOgR_2uz-JCXlg_q-uRYUUI-G8CGkfdgqik,1198
|
391
391
|
zrb/util/string/name.py,sha256=SXEfxJ1-tDOzHqmSV8kvepRVyMqs2XdV_vyoh_9XUu0,1584
|
392
392
|
zrb/util/todo.py,sha256=r9_KYF2-hLKMNjsp6AFK9zivykMrywd-kJ4bCwfdafI,19323
|
393
|
-
zrb/util/todo_model.py,sha256=
|
393
|
+
zrb/util/todo_model.py,sha256=hhzAX-uFl5rsg7iVX1ULlJOfBtblwQ_ieNUxBWfc-Os,1670
|
394
394
|
zrb/xcom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
395
395
|
zrb/xcom/xcom.py,sha256=o79rxR9wphnShrcIushA0Qt71d_p3ZTxjNf7x9hJB78,1571
|
396
|
-
zrb-1.9.
|
397
|
-
zrb-1.9.
|
398
|
-
zrb-1.9.
|
399
|
-
zrb-1.9.
|
396
|
+
zrb-1.9.13.dist-info/METADATA,sha256=6Yn22mBzufYdh4OQW8OnKZd2gO7ppZF_5sb74h1fyaM,9778
|
397
|
+
zrb-1.9.13.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
398
|
+
zrb-1.9.13.dist-info/entry_points.txt,sha256=-Pg3ElWPfnaSM-XvXqCxEAa-wfVI6BEgcs386s8C8v8,46
|
399
|
+
zrb-1.9.13.dist-info/RECORD,,
|
File without changes
|
File without changes
|