pygent 0.1.5__py3-none-any.whl → 0.1.7__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.
- pygent/agent.py +13 -1
- pygent/runtime.py +2 -2
- pygent/tools.py +10 -0
- {pygent-0.1.5.dist-info → pygent-0.1.7.dist-info}/METADATA +2 -3
- {pygent-0.1.5.dist-info → pygent-0.1.7.dist-info}/RECORD +9 -9
- {pygent-0.1.5.dist-info → pygent-0.1.7.dist-info}/WHEEL +0 -0
- {pygent-0.1.5.dist-info → pygent-0.1.7.dist-info}/entry_points.txt +0 -0
- {pygent-0.1.5.dist-info → pygent-0.1.7.dist-info}/licenses/LICENSE +0 -0
- {pygent-0.1.5.dist-info → pygent-0.1.7.dist-info}/top_level.txt +0 -0
pygent/agent.py
CHANGED
@@ -35,7 +35,7 @@ class Agent:
|
|
35
35
|
{"role": "system", "content": SYSTEM_MSG}
|
36
36
|
])
|
37
37
|
|
38
|
-
def step(self, user_msg: str)
|
38
|
+
def step(self, user_msg: str):
|
39
39
|
self.history.append({"role": "user", "content": user_msg})
|
40
40
|
assistant_msg = self.model.chat(self.history, self.model_name, TOOL_SCHEMAS)
|
41
41
|
self.history.append(assistant_msg)
|
@@ -47,6 +47,18 @@ class Agent:
|
|
47
47
|
console.print(Panel(output, title=f"tool:{call.function.name}"))
|
48
48
|
else:
|
49
49
|
console.print(assistant_msg.content)
|
50
|
+
return assistant_msg
|
51
|
+
|
52
|
+
def run_until_stop(self, user_msg: str, max_steps: int = 10) -> None:
|
53
|
+
"""Run steps automatically until the model calls the ``stop`` tool or
|
54
|
+
the step limit is reached."""
|
55
|
+
msg = user_msg
|
56
|
+
for _ in range(max_steps):
|
57
|
+
assistant_msg = self.step(msg)
|
58
|
+
calls = assistant_msg.tool_calls or []
|
59
|
+
if any(c.function.name == "stop" for c in calls):
|
60
|
+
break
|
61
|
+
msg = "continue"
|
50
62
|
|
51
63
|
|
52
64
|
def run_interactive(use_docker: bool | None = None) -> None: # pragma: no cover
|
pygent/runtime.py
CHANGED
@@ -71,8 +71,8 @@ class Runtime:
|
|
71
71
|
)
|
72
72
|
return proc.stdout + proc.stderr
|
73
73
|
|
74
|
-
def write_file(self,
|
75
|
-
p = self.base_dir /
|
74
|
+
def write_file(self, path: Union[str, Path], content: str) -> str:
|
75
|
+
p = self.base_dir / path
|
76
76
|
p.parent.mkdir(parents=True, exist_ok=True)
|
77
77
|
p.write_text(content)
|
78
78
|
return f"Wrote {p.relative_to(self.base_dir)}"
|
pygent/tools.py
CHANGED
@@ -35,6 +35,14 @@ TOOL_SCHEMAS = [
|
|
35
35
|
},
|
36
36
|
},
|
37
37
|
},
|
38
|
+
{
|
39
|
+
"type": "function",
|
40
|
+
"function": {
|
41
|
+
"name": "stop",
|
42
|
+
"description": "Stop the autonomous loop.",
|
43
|
+
"parameters": {"type": "object", "properties": {}},
|
44
|
+
},
|
45
|
+
},
|
38
46
|
]
|
39
47
|
|
40
48
|
# --------------- dispatcher ---------------
|
@@ -47,4 +55,6 @@ def execute_tool(call: Any, rt: Runtime) -> str: # pragma: no cover, Any→open
|
|
47
55
|
return rt.bash(**args)
|
48
56
|
if name == "write_file":
|
49
57
|
return rt.write_file(**args)
|
58
|
+
if name == "stop":
|
59
|
+
return "Stopping."
|
50
60
|
return f"⚠️ unknown tool {name}"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pygent
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.7
|
4
4
|
Summary: Pygent is a minimalist coding assistant that runs commands in a Docker container when available and falls back to local execution. See https://marianochaves.github.io/pygent for documentation and https://github.com/marianochaves/pygent for the source code.
|
5
5
|
Author-email: Mariano Chaves <mchaves.software@gmail.com>
|
6
6
|
Project-URL: Documentation, https://marianochaves.github.io/pygent
|
@@ -8,8 +8,7 @@ Project-URL: Repository, https://github.com/marianochaves/pygent
|
|
8
8
|
Requires-Python: >=3.9
|
9
9
|
License-File: LICENSE
|
10
10
|
Requires-Dist: rich>=13.7.0
|
11
|
-
|
12
|
-
Requires-Dist: openai>=1.0.0; extra == "llm"
|
11
|
+
Requires-Dist: openai>=1.0.0
|
13
12
|
Provides-Extra: test
|
14
13
|
Requires-Dist: pytest; extra == "test"
|
15
14
|
Provides-Extra: docs
|
@@ -1,16 +1,16 @@
|
|
1
1
|
pygent/__init__.py,sha256=_YO8FYMUMAWlRYCa6OBsfmJ9P4mCiYoOqFBLrQDP8qQ,442
|
2
2
|
pygent/__main__.py,sha256=MSmt_5Xg84uHqzTN38JwgseJK8rsJn_11A8WD99VtEo,61
|
3
|
-
pygent/agent.py,sha256=
|
3
|
+
pygent/agent.py,sha256=vmTNM1SOCR8e3CV4zBT9Uyzj3LdDglZekaYupjlpl0I,2487
|
4
4
|
pygent/cli.py,sha256=Hz2FZeNMVhxoT5DjCqphXla3TisGJtPEz921LEcpxrA,527
|
5
5
|
pygent/models.py,sha256=_3Y1Z5wL6FUqzC-EOjZe3Vkcq4SzbPdGz6TbshcEB98,992
|
6
6
|
pygent/openai_compat.py,sha256=mS6ntl70jpVH3JzfNYEDhg-z7QIQcMqQTuEV5ja7VOo,2173
|
7
7
|
pygent/py.typed,sha256=0Wh72UpGSn4lSGW-u3xMV9kxcBHMdwE15IGUqiJTwqo,52
|
8
|
-
pygent/runtime.py,sha256=
|
9
|
-
pygent/tools.py,sha256=
|
8
|
+
pygent/runtime.py,sha256=MxuYTIzVqXOLGuM-2J8TtJRjud1Z-LYHt5dtCVpW27E,3165
|
9
|
+
pygent/tools.py,sha256=8-jvqYeiJOlZ2ku1MTnBnK2O1m90hkrboq9aZrMORr0,1732
|
10
10
|
pygent/ui.py,sha256=xqPAvweghPOBBvoD72HzhN6zlXew_3inb8AN7Ck2zpQ,1328
|
11
|
-
pygent-0.1.
|
12
|
-
pygent-0.1.
|
13
|
-
pygent-0.1.
|
14
|
-
pygent-0.1.
|
15
|
-
pygent-0.1.
|
16
|
-
pygent-0.1.
|
11
|
+
pygent-0.1.7.dist-info/licenses/LICENSE,sha256=rIktBU2VR4kHzsWul64cbom2zHIgGqYmABoZwSur6T8,1071
|
12
|
+
pygent-0.1.7.dist-info/METADATA,sha256=E-A18f6OmzOQiRBF2tb0a0SZgj2q2Y4EY9UA4BRr3FI,877
|
13
|
+
pygent-0.1.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
14
|
+
pygent-0.1.7.dist-info/entry_points.txt,sha256=b9j216E5UpuMrQWRZrwyEmacNEAYvw1tCKkZqdIVIOc,70
|
15
|
+
pygent-0.1.7.dist-info/top_level.txt,sha256=P26IYsb-ThK5IkGP_bRuGJQ0Q_Y8JCcbYqVpvULdxDw,7
|
16
|
+
pygent-0.1.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|