zrb 1.9.10__py3-none-any.whl → 1.9.12__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/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(BaseModel):
20
- long_term_context: str = Field(
21
- default="",
22
- description="A markdown-formatted string containing curated, long-term context.",
23
- )
24
- conversation_summary: str = Field(
25
- default="",
26
- description="A free-text summary of the conversation history.",
27
- )
28
- history: ListOfDict = Field(
29
- default_factory=list,
30
- description="The recent, un-summarized conversation history.",
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.model_validate(data)
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.model_dump_json(indent=2))
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.py CHANGED
@@ -1,16 +1,11 @@
1
1
  import os
2
2
  from collections.abc import Callable
3
- from typing import Any
4
-
5
- from pydantic import BaseModel
3
+ from typing import TYPE_CHECKING, Any
6
4
 
7
5
  from zrb.util.cmd.command import run_command
8
6
 
9
-
10
- class DiffResult(BaseModel):
11
- created: list[str]
12
- removed: list[str]
13
- updated: list[str]
7
+ if TYPE_CHECKING:
8
+ from zrb.util.git_diff_model import DiffResult
14
9
 
15
10
 
16
11
  async def get_diff(
@@ -18,7 +13,7 @@ async def get_diff(
18
13
  source_commit: str,
19
14
  current_commit: str,
20
15
  print_method: Callable[..., Any] = print,
21
- ) -> DiffResult:
16
+ ) -> "DiffResult":
22
17
  """
23
18
  Get the difference between two commits in a Git repository.
24
19
 
@@ -34,6 +29,8 @@ async def get_diff(
34
29
  Raises:
35
30
  Exception: If the git command returns a non-zero exit code.
36
31
  """
32
+ from zrb.util.git_diff_model import DiffResult
33
+
37
34
  cmd_result, exit_code = await run_command(
38
35
  cmd=["git", "diff", source_commit, current_commit],
39
36
  cwd=repo_dir,
@@ -0,0 +1,7 @@
1
+ from pydantic import BaseModel
2
+
3
+
4
+ class DiffResult(BaseModel):
5
+ created: list[str]
6
+ removed: list[str]
7
+ updated: list[str]
zrb/util/git_subtree.py CHANGED
@@ -1,24 +1,15 @@
1
1
  import os
2
2
  from collections.abc import Callable
3
- from typing import Any
4
-
5
- from pydantic import BaseModel
3
+ from typing import TYPE_CHECKING, Any
6
4
 
7
5
  from zrb.util.cmd.command import run_command
8
6
  from zrb.util.file import read_file, write_file
9
7
 
8
+ if TYPE_CHECKING:
9
+ from zrb.util.git_subtree_model import SubTreeConfig
10
10
 
11
- class SingleSubTreeConfig(BaseModel):
12
- repo_url: str
13
- branch: str
14
- prefix: str
15
-
16
-
17
- class SubTreeConfig(BaseModel):
18
- data: dict[str, SingleSubTreeConfig]
19
11
 
20
-
21
- def load_config(repo_dir: str) -> SubTreeConfig:
12
+ def load_config(repo_dir: str):
22
13
  """
23
14
  Load the subtree configuration from subtrees.json.
24
15
 
@@ -28,13 +19,15 @@ def load_config(repo_dir: str) -> SubTreeConfig:
28
19
  Returns:
29
20
  SubTreeConfig: The loaded subtree configuration.
30
21
  """
22
+ from zrb.util.git_subtree_model import SubTreeConfig
23
+
31
24
  file_path = os.path.join(repo_dir, "subtrees.json")
32
25
  if not os.path.exists(file_path):
33
26
  return SubTreeConfig(data={})
34
27
  return SubTreeConfig.model_validate_json(read_file(file_path))
35
28
 
36
29
 
37
- def save_config(repo_dir: str, config: SubTreeConfig):
30
+ def save_config(repo_dir: str, config: "SubTreeConfig"):
38
31
  """
39
32
  Save the subtree configuration to subtrees.json.
40
33
 
@@ -70,6 +63,8 @@ async def add_subtree(
70
63
  name already exists.
71
64
  Exception: If the git command returns a non-zero exit code.
72
65
  """
66
+ from zrb.util.git_subtree_model import SingleSubTreeConfig
67
+
73
68
  config = load_config(repo_dir)
74
69
  if os.path.isdir(prefix):
75
70
  raise ValueError(f"Directory exists: {prefix}")
@@ -0,0 +1,11 @@
1
+ from pydantic import BaseModel
2
+
3
+
4
+ class SingleSubTreeConfig(BaseModel):
5
+ repo_url: str
6
+ branch: str
7
+ prefix: str
8
+
9
+
10
+ class SubTreeConfig(BaseModel):
11
+ data: dict[str, SingleSubTreeConfig]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: zrb
3
- Version: 1.9.10
3
+ Version: 1.9.12
4
4
  Summary: Your Automation Powerhouse
5
5
  Home-page: https://github.com/state-alchemists/zrb
6
6
  License: AGPL-3.0-or-later
@@ -342,7 +342,7 @@ 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
344
  zrb/task/llm/error.py,sha256=s5PSK3ibGupMzOM0P81nstHWrMr3205H0FSDwfhWUDA,3662
345
- zrb/task/llm/history.py,sha256=cpaNqoEzsNAgzZGPPdohA8U5nTrVWmZ3P1Y5RTtXDgc,7986
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
@@ -377,8 +377,10 @@ zrb/util/codemod/modify_method.py,sha256=5fioXjqNQmrf4CV2qlTZHpViF9PMnNer4FvuKam
377
377
  zrb/util/codemod/modify_module.py,sha256=2mzi_NxJ-kNFo5G0U_Rqb3JoYQl1s6Izt7b_wAl10F0,715
378
378
  zrb/util/cron.py,sha256=UWqqhhM7DDTPx6wjCIdBndnVh3NRu-sdKazp8aZkXh8,3833
379
379
  zrb/util/file.py,sha256=tm_8qn0vEM8Hz46yXUcvFHfsLtQNqidQaEuB85xqhFE,2806
380
- zrb/util/git.py,sha256=gS_Y9sQgJbY0PfgSQiowLvV3Nf0y9C8nT3j6z6oEsG8,8186
381
- zrb/util/git_subtree.py,sha256=E_UB5OIgm8WkHL9beifRxpZ25_BB9p1H578OhLZTgRU,4611
380
+ zrb/util/git.py,sha256=GS08OqE-gs6mN-_VqACN82DbI81nzG3FiXeim_-jVAU,8193
381
+ zrb/util/git_diff_model.py,sha256=Fthl2nyBz3D5fIfbMCPEFBWfXUB6qA4rQWApKaimaI8,131
382
+ zrb/util/git_subtree.py,sha256=AyQWCWEi2EIzEpYXRnYN55157KMUql0WHj70QNw5PHU,4612
383
+ zrb/util/git_subtree_model.py,sha256=mDMUG6mju1_-XXpIE41EqFdu_gmDeeJ3OAxqcJunY7g,196
382
384
  zrb/util/group.py,sha256=T82yr3qg9I5k10VPXkMyrIRIqyfzadSH813bqzwKEPI,4718
383
385
  zrb/util/init_path.py,sha256=9eN7CkWNGhDBpjTQs2j9YHVMzui7Y8DEb1WP4aTPzeo,659
384
386
  zrb/util/load.py,sha256=DK0KYSlu48HCoGPqnW1IxnE3pHrZSPCstfz8Fjyqqv8,2140
@@ -391,7 +393,7 @@ zrb/util/todo.py,sha256=r9_KYF2-hLKMNjsp6AFK9zivykMrywd-kJ4bCwfdafI,19323
391
393
  zrb/util/todo_model.py,sha256=0SJ8aLYfJAscDOk5JsH7pXP3h1rAG91VMCS20-c2Y6A,1576
392
394
  zrb/xcom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
393
395
  zrb/xcom/xcom.py,sha256=o79rxR9wphnShrcIushA0Qt71d_p3ZTxjNf7x9hJB78,1571
394
- zrb-1.9.10.dist-info/METADATA,sha256=naCcHpyKVqi7EqfXhaJPzV4fyjeSClYKXws2yjpyZno,9778
395
- zrb-1.9.10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
396
- zrb-1.9.10.dist-info/entry_points.txt,sha256=-Pg3ElWPfnaSM-XvXqCxEAa-wfVI6BEgcs386s8C8v8,46
397
- zrb-1.9.10.dist-info/RECORD,,
396
+ zrb-1.9.12.dist-info/METADATA,sha256=-DI8RzdASD_NeRQmc2UTza0e2DoLwD-CFQm4YqENtBk,9778
397
+ zrb-1.9.12.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
398
+ zrb-1.9.12.dist-info/entry_points.txt,sha256=-Pg3ElWPfnaSM-XvXqCxEAa-wfVI6BEgcs386s8C8v8,46
399
+ zrb-1.9.12.dist-info/RECORD,,
File without changes