pyagentprolog-fona 0.1.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Andrey Vorfolomeev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,141 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyagentprolog-fona
3
+ Version: 0.1.0
4
+ Summary: Decorator-based framework for background AI agents on PyAgentProlog
5
+ Author-email: Andrey Vorfolomeev <binom0x@proton.me>
6
+ License: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: fastapi>=0.110
11
+ Requires-Dist: uvicorn[standard]>=0.29
12
+ Requires-Dist: httpx>=0.27
13
+ Requires-Dist: pydantic>=2.6
14
+ Requires-Dist: transformers>=4.40
15
+ Requires-Dist: huggingface_hub>=0.23
16
+ Requires-Dist: pyagentprolog>=1.0.1
17
+ Requires-Dist: pyagentprolog-hf>=1.0.2
18
+ Provides-Extra: torch
19
+ Requires-Dist: torch>=2.0; extra == "torch"
20
+ Provides-Extra: semantic
21
+ Requires-Dist: sentence-transformers>=3.0; extra == "semantic"
22
+ Provides-Extra: all
23
+ Requires-Dist: torch>=2.0; extra == "all"
24
+ Requires-Dist: sentence-transformers>=3.0; extra == "all"
25
+ Dynamic: license-file
26
+
27
+ # Fona
28
+
29
+ **Minimalist framework for background AI agents on PyAgentProlog.**
30
+
31
+ An agent is a Prolog program plus Python actions. It runs as an HTTP server with a chat UI and a REST API, can talk to users and to other agents, and can be launched from a dashboard.
32
+
33
+ ---
34
+
35
+ ## What it looks like
36
+
37
+ ```python
38
+ from fona import agent
39
+
40
+ @agent.action
41
+ def now_iso():
42
+ import time
43
+ return time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
44
+
45
+ @agent.program
46
+ PROGRAM = r"""
47
+ run :-
48
+ ui_print('Hello. Type "time" or "quit".'),
49
+ on_user_input.
50
+
51
+ on_user_input :-
52
+ ui_read(Input),
53
+ ( Input == quit -> ui_print('Bye.')
54
+ ; Input == time -> now_iso(T), ui_print(T), on_user_input
55
+ ; ui_print('Unknown.'), on_user_input
56
+ ).
57
+ """
58
+
59
+ if __name__ == '__main__':
60
+ agent.run(port=8000)
61
+ ```
62
+
63
+ ```bash
64
+ python hello.py
65
+ # open http://127.0.0.1:8000/
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Install
71
+
72
+ ```bash
73
+ pip install pyagentprolog-fona
74
+ ```
75
+
76
+ Python 3.10+. `torch` / `sentence-transformers` are optional (`[torch]`, `[semantic]`, `[all]`).
77
+
78
+ ---
79
+
80
+ ## What you get
81
+
82
+ - **`@agent.program`** — declare the agent's logic in Prolog.
83
+ - **`@agent.action` / `@agent.effect` / `@agent.generate`** — expose Python functions as Prolog predicates.
84
+ - **`agent.run()`** — serve a chat UI and a REST API (`/api/v1/query`, `/api/v1/ui/*`).
85
+ - **Prolog-only inter-agent protocol** — peers call `/api/v1/query` with Prolog text; errors are `"err:..."` atoms, not exceptions.
86
+ - **Declarative config** — `load_config(...)` reads env once, returns an immutable object.
87
+ - **HF models** — `Agent.from_hub("user/repo")`; the user's `PROGRAM` is prepended to the model's program.
88
+ - **Dashboard** — `python -m fona.dashboard`; a project is a folder holding `team.json`, `scripts/`, `logs/`.
89
+ - **Orchestrator UI** — `python -m fona.orchestrator_app`; three-column view of goal, plan, chat, subordinates.
90
+ - **Natural language ↔ Prolog** — optional `@agent.action` companions to the HITL loop, not part of the protocol.
91
+
92
+ ---
93
+
94
+ ## Documentation
95
+
96
+ The full guide — architecture, decorators, HITL, inter-agent protocol, `query_one`, REST contract, HF cache, dashboard, orchestrator, security, testing, releases, known limitations — lives in [docs/guide.md](https://github.com/binom0x/pyagentprolog-fona/blob/main/doc/guide.md)
97
+
98
+ Start there. This README intentionally does not duplicate it.
99
+
100
+ ---
101
+
102
+ ## Examples
103
+
104
+ | File | Shows |
105
+ |---|---|
106
+ | `examples/hello.py` | smallest agent: `run/0` + `ui_print` |
107
+ | `examples/server_agent.py` | facts server + `handle_request/2` (incoming) |
108
+ | `examples/client_agent.py` | `call_peer/3` (outgoing) |
109
+ | `examples/template_agent.py` | reference: HITL, peers, protocol, NL ↔ Prolog, `query_one` |
110
+ | `examples/with_hf.py` | `Agent.from_hub` + prepended `PROGRAM` |
111
+
112
+ ---
113
+
114
+ ## Protocol in one paragraph
115
+
116
+ Every agent can answer `POST /api/v1/query` with body `{"query": "<Prolog text>"}`. The response is `{"success": bool, "solutions": [{"Var": value}], "count": int}`. The recommended handler is `handle_request(Kind, Payload) -> str` with `Kind ∈ {ping, echo, status}`, extensible via `register_protocol(agent, extra={...})`. Outgoing calls use `call_peer(Peer, Query) -> "ok:<v>" | "err:<r>"`, registered by `register_peers(agent, CFG)`. Peers are configured via `FONA_PEERS="name=url,..."`. No special language, no special client — just Prolog over HTTP.
117
+
118
+ ---
119
+
120
+ ## Requirements
121
+
122
+ - Core: `fastapi`, `uvicorn`, `httpx`, `pydantic`, `transformers`, `huggingface_hub`, `pyagentprolog`, `pyagentprolog-hf`.
123
+ - Optional: `torch`, `sentence-transformers`.
124
+ - For private HF models: `FONA_HF_TOKEN`.
125
+ - For non-local bind: `FONA_TOKEN` (REST auth) — see §16 of the guide.
126
+
127
+ ---
128
+
129
+ ## Status
130
+
131
+ `0.1.0` — in development. The public API and the inter-agent protocol are stable; the dashboard and orchestrator UI may change. Semver applies to `Agent`, `agent`, the decorators, and `load_config` / `register_*`.
132
+
133
+ ---
134
+
135
+ ## License
136
+
137
+ See `LICENSE`.
138
+
139
+ ---
140
+
141
+ **One line:** Fona lets you write an agent as a Prolog program plus Python actions, serve it over HTTP with a chat UI, and let it talk to other agents — all through one Prolog-only protocol. For everything else, read [docs/guide.md](https://github.com/binom0x/pyagentprolog-fona/blob/main/doc/guide.md)
@@ -0,0 +1,115 @@
1
+ # Fona
2
+
3
+ **Minimalist framework for background AI agents on PyAgentProlog.**
4
+
5
+ An agent is a Prolog program plus Python actions. It runs as an HTTP server with a chat UI and a REST API, can talk to users and to other agents, and can be launched from a dashboard.
6
+
7
+ ---
8
+
9
+ ## What it looks like
10
+
11
+ ```python
12
+ from fona import agent
13
+
14
+ @agent.action
15
+ def now_iso():
16
+ import time
17
+ return time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
18
+
19
+ @agent.program
20
+ PROGRAM = r"""
21
+ run :-
22
+ ui_print('Hello. Type "time" or "quit".'),
23
+ on_user_input.
24
+
25
+ on_user_input :-
26
+ ui_read(Input),
27
+ ( Input == quit -> ui_print('Bye.')
28
+ ; Input == time -> now_iso(T), ui_print(T), on_user_input
29
+ ; ui_print('Unknown.'), on_user_input
30
+ ).
31
+ """
32
+
33
+ if __name__ == '__main__':
34
+ agent.run(port=8000)
35
+ ```
36
+
37
+ ```bash
38
+ python hello.py
39
+ # open http://127.0.0.1:8000/
40
+ ```
41
+
42
+ ---
43
+
44
+ ## Install
45
+
46
+ ```bash
47
+ pip install pyagentprolog-fona
48
+ ```
49
+
50
+ Python 3.10+. `torch` / `sentence-transformers` are optional (`[torch]`, `[semantic]`, `[all]`).
51
+
52
+ ---
53
+
54
+ ## What you get
55
+
56
+ - **`@agent.program`** — declare the agent's logic in Prolog.
57
+ - **`@agent.action` / `@agent.effect` / `@agent.generate`** — expose Python functions as Prolog predicates.
58
+ - **`agent.run()`** — serve a chat UI and a REST API (`/api/v1/query`, `/api/v1/ui/*`).
59
+ - **Prolog-only inter-agent protocol** — peers call `/api/v1/query` with Prolog text; errors are `"err:..."` atoms, not exceptions.
60
+ - **Declarative config** — `load_config(...)` reads env once, returns an immutable object.
61
+ - **HF models** — `Agent.from_hub("user/repo")`; the user's `PROGRAM` is prepended to the model's program.
62
+ - **Dashboard** — `python -m fona.dashboard`; a project is a folder holding `team.json`, `scripts/`, `logs/`.
63
+ - **Orchestrator UI** — `python -m fona.orchestrator_app`; three-column view of goal, plan, chat, subordinates.
64
+ - **Natural language ↔ Prolog** — optional `@agent.action` companions to the HITL loop, not part of the protocol.
65
+
66
+ ---
67
+
68
+ ## Documentation
69
+
70
+ The full guide — architecture, decorators, HITL, inter-agent protocol, `query_one`, REST contract, HF cache, dashboard, orchestrator, security, testing, releases, known limitations — lives in [docs/guide.md](https://github.com/binom0x/pyagentprolog-fona/blob/main/doc/guide.md)
71
+
72
+ Start there. This README intentionally does not duplicate it.
73
+
74
+ ---
75
+
76
+ ## Examples
77
+
78
+ | File | Shows |
79
+ |---|---|
80
+ | `examples/hello.py` | smallest agent: `run/0` + `ui_print` |
81
+ | `examples/server_agent.py` | facts server + `handle_request/2` (incoming) |
82
+ | `examples/client_agent.py` | `call_peer/3` (outgoing) |
83
+ | `examples/template_agent.py` | reference: HITL, peers, protocol, NL ↔ Prolog, `query_one` |
84
+ | `examples/with_hf.py` | `Agent.from_hub` + prepended `PROGRAM` |
85
+
86
+ ---
87
+
88
+ ## Protocol in one paragraph
89
+
90
+ Every agent can answer `POST /api/v1/query` with body `{"query": "<Prolog text>"}`. The response is `{"success": bool, "solutions": [{"Var": value}], "count": int}`. The recommended handler is `handle_request(Kind, Payload) -> str` with `Kind ∈ {ping, echo, status}`, extensible via `register_protocol(agent, extra={...})`. Outgoing calls use `call_peer(Peer, Query) -> "ok:<v>" | "err:<r>"`, registered by `register_peers(agent, CFG)`. Peers are configured via `FONA_PEERS="name=url,..."`. No special language, no special client — just Prolog over HTTP.
91
+
92
+ ---
93
+
94
+ ## Requirements
95
+
96
+ - Core: `fastapi`, `uvicorn`, `httpx`, `pydantic`, `transformers`, `huggingface_hub`, `pyagentprolog`, `pyagentprolog-hf`.
97
+ - Optional: `torch`, `sentence-transformers`.
98
+ - For private HF models: `FONA_HF_TOKEN`.
99
+ - For non-local bind: `FONA_TOKEN` (REST auth) — see §16 of the guide.
100
+
101
+ ---
102
+
103
+ ## Status
104
+
105
+ `0.1.0` — in development. The public API and the inter-agent protocol are stable; the dashboard and orchestrator UI may change. Semver applies to `Agent`, `agent`, the decorators, and `load_config` / `register_*`.
106
+
107
+ ---
108
+
109
+ ## License
110
+
111
+ See `LICENSE`.
112
+
113
+ ---
114
+
115
+ **One line:** Fona lets you write an agent as a Prolog program plus Python actions, serve it over HTTP with a chat UI, and let it talk to other agents — all through one Prolog-only protocol. For everything else, read [docs/guide.md](https://github.com/binom0x/pyagentprolog-fona/blob/main/doc/guide.md)
@@ -0,0 +1,15 @@
1
+ """Fona — минималистичный фреймворк фоновых ИИ-агентов на PyAgentProlog."""
2
+ from .agent import Agent, agent
3
+ from .config import load_config, FonaConfig
4
+ from .peers import call_peer, register_peers
5
+ from .protocol import register_protocol
6
+ from .team import team_resolver
7
+
8
+ __all__ = [
9
+ 'Agent', 'agent',
10
+ 'load_config', 'FonaConfig',
11
+ 'call_peer', 'register_peers',
12
+ 'register_protocol',
13
+ 'team_resolver',
14
+ ]
15
+ __version__ = '0.1.0'