pygent 0.1.2__tar.gz → 0.1.3__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygent
3
- Version: 0.1.2
3
+ Version: 0.1.3
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
@@ -16,4 +16,6 @@ Provides-Extra: docs
16
16
  Requires-Dist: mkdocs; extra == "docs"
17
17
  Provides-Extra: docker
18
18
  Requires-Dist: docker>=7.0.0; extra == "docker"
19
+ Provides-Extra: ui
20
+ Requires-Dist: gradio; extra == "ui"
19
21
  Dynamic: license-file
@@ -8,6 +8,7 @@ Pygent is a coding assistant that executes each request inside an isolated Docke
8
8
  * Integrates with OpenAI-compatible models to orchestrate each step.
9
9
  * Persists the conversation history during the session.
10
10
  * Provides a small Python API for use in other projects.
11
+ * Optional web interface via `pygent-ui`.
11
12
 
12
13
  ## Installation
13
14
 
@@ -26,7 +27,10 @@ To run commands in Docker containers also install `pygent[docker]`.
26
27
  Behaviour can be adjusted via environment variables:
27
28
 
28
29
  * `OPENAI_API_KEY` &ndash; key used to access the OpenAI API.
29
- * `PYGENT_MODEL` &ndash; model name used for requests (default `gpt-4o-mini-preview`).
30
+ Set this to your API key or a key from any compatible provider.
31
+ * `OPENAI_BASE_URL` &ndash; base URL for OpenAI-compatible APIs
32
+ (defaults to ``https://api.openai.com/v1``).
33
+ * `PYGENT_MODEL` &ndash; model name used for requests (default `gpt-4.1-mini`).
30
34
  * `PYGENT_IMAGE` &ndash; Docker image to create the container (default `python:3.12-slim`).
31
35
  * `PYGENT_USE_DOCKER` &ndash; set to `0` to disable Docker and run locally.
32
36
 
@@ -42,7 +46,10 @@ Use `--docker` to run commands inside a container (requires
42
46
  `pygent[docker]`). Use `--no-docker` or set `PYGENT_USE_DOCKER=0`
43
47
  to force local execution.
44
48
 
45
- Type messages normally; use `/exit` to end the session. Each command is executed in the container and the result shown in the terminal.
49
+ Type messages normally; use `/exit` to end the session. Each command is executed
50
+ in the container and the result shown in the terminal.
51
+ For a minimal web interface run `pygent-ui` instead (requires `pygent[ui]`).
52
+
46
53
 
47
54
  ## API usage
48
55
 
@@ -59,6 +66,22 @@ ag.runtime.cleanup()
59
66
 
60
67
  See the `examples/` folder for more complete scripts.
61
68
 
69
+ ### Using OpenAI and other providers
70
+
71
+ Set your OpenAI key:
72
+
73
+ ```bash
74
+ export OPENAI_API_KEY="sk-..."
75
+ ```
76
+
77
+ To use a different provider, set `OPENAI_BASE_URL` to the provider
78
+ endpoint and keep `OPENAI_API_KEY` pointing to the correct key:
79
+
80
+ ```bash
81
+ export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
82
+ export OPENAI_API_KEY="your-provider-key"
83
+ ```
84
+
62
85
  ## Development
63
86
 
64
87
  1. Install the test dependencies:
@@ -18,7 +18,7 @@ from rich.panel import Panel
18
18
  from .runtime import Runtime
19
19
  from .tools import TOOL_SCHEMAS, execute_tool
20
20
 
21
- MODEL = os.getenv("PYGENT_MODEL", "gpt-4o-mini-preview")
21
+ MODEL = os.getenv("PYGENT_MODEL", "gpt-4.1-mini")
22
22
  SYSTEM_MSG = (
23
23
  "You are Pygent, a sandboxed coding assistant.\n"
24
24
  "Respond with JSON when you need to use a tool."
@@ -0,0 +1,36 @@
1
+ from .agent import Agent, _chat
2
+ from .runtime import Runtime
3
+ from .tools import execute_tool
4
+
5
+
6
+ def run_gui(use_docker: bool | None = None) -> None:
7
+ """Launch a simple Gradio chat interface."""
8
+ try:
9
+ import gradio as gr
10
+ except ModuleNotFoundError as exc: # pragma: no cover - optional
11
+ raise SystemExit(
12
+ "Gradio is required for the GUI. Install with 'pip install pygent[ui]'"
13
+ ) from exc
14
+
15
+ agent = Agent(runtime=Runtime(use_docker=use_docker))
16
+
17
+ def _respond(message: str, history: list[tuple[str, str]] | None) -> str:
18
+ agent.history.append({"role": "user", "content": message})
19
+ assistant_msg = _chat(agent.history)
20
+ agent.history.append(assistant_msg)
21
+ reply = assistant_msg.content or ""
22
+ if assistant_msg.tool_calls:
23
+ for call in assistant_msg.tool_calls:
24
+ output = execute_tool(call, agent.runtime)
25
+ agent.history.append({"role": "tool", "content": output, "tool_call_id": call.id})
26
+ reply += f"\n\n[tool:{call.function.name}]\n{output}"
27
+ return reply
28
+
29
+ try:
30
+ gr.ChatInterface(_respond, title="Pygent").launch()
31
+ finally:
32
+ agent.runtime.cleanup()
33
+
34
+
35
+ def main() -> None: # pragma: no cover
36
+ run_gui()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygent
3
- Version: 0.1.2
3
+ Version: 0.1.3
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
@@ -16,4 +16,6 @@ Provides-Extra: docs
16
16
  Requires-Dist: mkdocs; extra == "docs"
17
17
  Provides-Extra: docker
18
18
  Requires-Dist: docker>=7.0.0; extra == "docker"
19
+ Provides-Extra: ui
20
+ Requires-Dist: gradio; extra == "ui"
19
21
  Dynamic: license-file
@@ -8,6 +8,7 @@ pygent/openai_compat.py
8
8
  pygent/py.typed
9
9
  pygent/runtime.py
10
10
  pygent/tools.py
11
+ pygent/ui.py
11
12
  pygent.egg-info/PKG-INFO
12
13
  pygent.egg-info/SOURCES.txt
13
14
  pygent.egg-info/dependency_links.txt
@@ -1,2 +1,3 @@
1
1
  [console_scripts]
2
2
  pygent = pygent.cli:main
3
+ pygent-ui = pygent.ui:main
@@ -11,3 +11,6 @@ openai>=1.0.0
11
11
 
12
12
  [test]
13
13
  pytest
14
+
15
+ [ui]
16
+ gradio
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pygent"
3
- version = "0.1.2"
3
+ version = "0.1.3"
4
4
  description = "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
  authors = [ { name = "Mariano Chaves", email = "mchaves.software@gmail.com" } ]
6
6
  requires-python = ">=3.9"
@@ -13,6 +13,7 @@ llm = ["openai>=1.0.0"] # OpenAI-compatible library (optional)
13
13
  test = ["pytest"]
14
14
  docs = ["mkdocs"]
15
15
  docker = ["docker>=7.0.0"]
16
+ ui = ["gradio"]
16
17
 
17
18
  [project.urls]
18
19
  Documentation = "https://marianochaves.github.io/pygent"
@@ -20,6 +21,7 @@ Repository = "https://github.com/marianochaves/pygent"
20
21
 
21
22
  [project.scripts]
22
23
  pygent = "pygent.cli:main"
24
+ pygent-ui = "pygent.ui:main"
23
25
 
24
26
 
25
27
  [tool.setuptools.package-data]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes