org.slashlib.py.agent 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,23 @@
1
+ [AI](AI.md) [CHANGELOG](CHANGELOG.md) [README](README.md)
2
+
3
+ MIT License
4
+
5
+ Copyright (c) 2019 Dirk Brenckmann, db-developer
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
@@ -0,0 +1,100 @@
1
+ Metadata-Version: 2.4
2
+ Name: org.slashlib.py.agent
3
+ Version: 0.1.0
4
+ Summary: python agent for inference handling
5
+ Author-email: Dirk Brenckmann <db.developer@gmx.de>
6
+ Project-URL: Homepage, https://github.com/org-slashlib/org.slashlib.py.agent
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE.md
13
+ Dynamic: license-file
14
+
15
+ [Bottom](#license) [AI](AI.md) [CHANGELOG](CHANGELOG.md) [LICENSE](LICENSE.md)
16
+ # org.slashlib.py.agent
17
+
18
+ A highly decoupled, asynchronous framework for building AI agents in Python.
19
+
20
+ [![PyPI version](https://img.shields.io/pypi/v/org.slashlib.py.agent.svg)](https://pypi.org/project/org.slashlib.py.agent/)
21
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
22
+
23
+ ## Core Concept
24
+
25
+ This package provides a robust infrastructure to connect AI models (Inference Engines) with functional tools. The focus lies on **Provider Agnosticism**: The agent does not need to know whether it is communicating with Ollama, OpenAI, or a local model—it uses standardized adapters to ensure seamless integration.
26
+
27
+ ### Key Features
28
+ - **Asynchronous Core**: Built on `asyncio` for non-blocking task execution.
29
+ - **Provider Agnostic**: Easily swap the AI engine using the Adapter pattern.
30
+ - **Automatic Tool Schemas**: Automatically transforms Python functions into JSON schemas for LLMs via decorators.
31
+ - **Multiton Pattern**: Ensures unique agent instances by identifier, preventing redundant resource allocation.
32
+ - **Robust Exception Hierarchy**: Clearly separates connection, configuration, and tool execution errors.
33
+
34
+ ---
35
+ ## Installation
36
+
37
+ Install the package via pip:
38
+
39
+ ```bash
40
+ pip install org.slashlib.py.agent
41
+ ```
42
+
43
+ ---
44
+ ## Quick Start
45
+
46
+ Setting up an agent with a tool and the Ollama adapter is straightforward:
47
+
48
+ ```python
49
+ import asyncio
50
+ from org.slashlib.py.agent import Agent, OllamaInferenceAdapter, tool
51
+
52
+ # 1. Define a tool
53
+ @tool(description="Adds two numbers.")
54
+ async def add_numbers(a: int, b: int) -> int:
55
+ return a + b
56
+
57
+ async def main():
58
+ # 2. Configure Adapter and Agent
59
+ adapter = OllamaInferenceAdapter()
60
+ my_agent = Agent(
61
+ identifier="MathExpert",
62
+ tools=[add_numbers],
63
+ adapter=adapter
64
+ )
65
+
66
+ # 3. Start task (non-blocking)
67
+ task = my_agent.run(user_prompt="What is 123 + 456?")
68
+
69
+ # 4. Retrieve result
70
+ response = await task
71
+ print(f"Response: {response.get_last_content()}")
72
+
73
+ if __name__ == "__main__":
74
+ asyncio.run(main())
75
+ ```
76
+
77
+ ---
78
+ ## Documentation & Obsidian
79
+
80
+ The project root is pre-configured as an **Obsidian Vault**. If you open this folder directly in Obsidian, all settings and documentation links will be available immediately via the included `.obsidian` directory.
81
+
82
+ The following community plugins are pre-configured in the vault to enhance the documentation experience:
83
+
84
+ * **[File Include](https://github.com/tillahoffmann/obsidian-file-include)**: Embed code files directly into your markdown documentation.
85
+ * **[Folder Notes](https://github.com/LostPaul/obsidian-folder-notes)**: Add descriptions at the folder level.
86
+ * **[Front Matter Title](https://github.com/snezhig/obsidian-front-matter-title)**: Use metadata for descriptive file titles.
87
+ * **[Hide Folders](https://github.com/JonasDoesThings/obsidian-hide-folders)**: Keeps the structure clean by hiding internal directories.
88
+ * **[Iconic](https://github.com/gfxholo/iconic)** & **[Icons](https://github.com/visini/obsidian-icons-plugin)**: Improved visual navigation.
89
+
90
+ [More docs](docs)
91
+
92
+ ---
93
+ ## License
94
+
95
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE.md) file for details.
96
+
97
+ ---
98
+ © 2026 org.slashlib
99
+
100
+ [TOP](#org-slashlib-py-agent) [AI](AI.md) [CHANGELOG](CHANGELOG.md) [LICENSE](LICENSE.md)
@@ -0,0 +1,86 @@
1
+ [Bottom](#license) [AI](AI.md) [CHANGELOG](CHANGELOG.md) [LICENSE](LICENSE.md)
2
+ # org.slashlib.py.agent
3
+
4
+ A highly decoupled, asynchronous framework for building AI agents in Python.
5
+
6
+ [![PyPI version](https://img.shields.io/pypi/v/org.slashlib.py.agent.svg)](https://pypi.org/project/org.slashlib.py.agent/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+
9
+ ## Core Concept
10
+
11
+ This package provides a robust infrastructure to connect AI models (Inference Engines) with functional tools. The focus lies on **Provider Agnosticism**: The agent does not need to know whether it is communicating with Ollama, OpenAI, or a local model—it uses standardized adapters to ensure seamless integration.
12
+
13
+ ### Key Features
14
+ - **Asynchronous Core**: Built on `asyncio` for non-blocking task execution.
15
+ - **Provider Agnostic**: Easily swap the AI engine using the Adapter pattern.
16
+ - **Automatic Tool Schemas**: Automatically transforms Python functions into JSON schemas for LLMs via decorators.
17
+ - **Multiton Pattern**: Ensures unique agent instances by identifier, preventing redundant resource allocation.
18
+ - **Robust Exception Hierarchy**: Clearly separates connection, configuration, and tool execution errors.
19
+
20
+ ---
21
+ ## Installation
22
+
23
+ Install the package via pip:
24
+
25
+ ```bash
26
+ pip install org.slashlib.py.agent
27
+ ```
28
+
29
+ ---
30
+ ## Quick Start
31
+
32
+ Setting up an agent with a tool and the Ollama adapter is straightforward:
33
+
34
+ ```python
35
+ import asyncio
36
+ from org.slashlib.py.agent import Agent, OllamaInferenceAdapter, tool
37
+
38
+ # 1. Define a tool
39
+ @tool(description="Adds two numbers.")
40
+ async def add_numbers(a: int, b: int) -> int:
41
+ return a + b
42
+
43
+ async def main():
44
+ # 2. Configure Adapter and Agent
45
+ adapter = OllamaInferenceAdapter()
46
+ my_agent = Agent(
47
+ identifier="MathExpert",
48
+ tools=[add_numbers],
49
+ adapter=adapter
50
+ )
51
+
52
+ # 3. Start task (non-blocking)
53
+ task = my_agent.run(user_prompt="What is 123 + 456?")
54
+
55
+ # 4. Retrieve result
56
+ response = await task
57
+ print(f"Response: {response.get_last_content()}")
58
+
59
+ if __name__ == "__main__":
60
+ asyncio.run(main())
61
+ ```
62
+
63
+ ---
64
+ ## Documentation & Obsidian
65
+
66
+ The project root is pre-configured as an **Obsidian Vault**. If you open this folder directly in Obsidian, all settings and documentation links will be available immediately via the included `.obsidian` directory.
67
+
68
+ The following community plugins are pre-configured in the vault to enhance the documentation experience:
69
+
70
+ * **[File Include](https://github.com/tillahoffmann/obsidian-file-include)**: Embed code files directly into your markdown documentation.
71
+ * **[Folder Notes](https://github.com/LostPaul/obsidian-folder-notes)**: Add descriptions at the folder level.
72
+ * **[Front Matter Title](https://github.com/snezhig/obsidian-front-matter-title)**: Use metadata for descriptive file titles.
73
+ * **[Hide Folders](https://github.com/JonasDoesThings/obsidian-hide-folders)**: Keeps the structure clean by hiding internal directories.
74
+ * **[Iconic](https://github.com/gfxholo/iconic)** & **[Icons](https://github.com/visini/obsidian-icons-plugin)**: Improved visual navigation.
75
+
76
+ [More docs](docs)
77
+
78
+ ---
79
+ ## License
80
+
81
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE.md) file for details.
82
+
83
+ ---
84
+ © 2026 org.slashlib
85
+
86
+ [TOP](#org-slashlib-py-agent) [AI](AI.md) [CHANGELOG](CHANGELOG.md) [LICENSE](LICENSE.md)
@@ -0,0 +1,46 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "org.slashlib.py.agent"
7
+ version = "0.1.0"
8
+ dependencies = [
9
+ ]
10
+ authors = [
11
+ { name="Dirk Brenckmann", email="db.developer@gmx.de" },
12
+ ]
13
+ description = "python agent for inference handling"
14
+ readme = "README.md"
15
+ requires-python = ">=3.10"
16
+ classifiers = [
17
+ "Programming Language :: Python :: 3",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ ]
21
+
22
+ [project.urls]
23
+ "Homepage" = "https://github.com/org-slashlib/org.slashlib.py.agent"
24
+
25
+ [tool.setuptools.packages.find]
26
+ where = ["src"]
27
+
28
+ [tool.pytest.ini_options]
29
+ pythonpath = ["."]
30
+ testpaths = ["tests"]
31
+ asyncio_mode = "auto"
32
+ addopts = """
33
+ -v
34
+ --cov
35
+ --cov=src/org/slashlib/py/agent
36
+ --cov-report=term-missing
37
+ --cov-report=xml:docs/reports/coverage/xml
38
+ --cov-report=html:docs/reports/coverage/html
39
+ """
40
+
41
+ [tool.coverage.run]
42
+ source = ["src/org/slashlib/py/agent"]
43
+ omit = ["src/org/slashlib/py/agent/__main__.py"]
44
+
45
+ [tool.coverage.report]
46
+ show_missing = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -0,0 +1,46 @@
1
+ # -*- coding: utf-8 -*-
2
+ # file src/org/slashlib/py/agent/__init__.py
3
+ # @AI:
4
+ # - INTEGRITY RULES:
5
+ # - STRICT PRESERVATION: Do not remove, move, or modify ANY existing lines of code or comments
6
+ # unless they are the explicit target of the requested change.
7
+ # - DEBUG MARKERS: Commented-out code (e.g., debug prints) MUST be kept exactly where they are.
8
+ # - WHITESPACE & STRUCTURE: Maintain all original empty lines and the existing file structure.
9
+ # Structural integrity takes precedence over "clean code" or "elegance".
10
+ # - LEAD-IN/OUT: The very first and last lines (and all comments in between) are immutable anchors.
11
+ # - MAINTENANCE:
12
+ # - Only update pydoc strings (args, returns, raises) if the function signature changes.
13
+ # - Do NOT delete existing examples or descriptions in pydoc.
14
+ # - LANGUAGE: en-US for all comments and documentation.
15
+
16
+ from src.org.slashlib.py.agent.agent import Agent
17
+ from src.org.slashlib.py.agent.tool import tool
18
+ from src.org.slashlib.py.agent.agent_response import AgentResponse
19
+ from src.org.slashlib.py.agent.inference_bases import (
20
+ InferenceAdapter,
21
+ InferenceResult,
22
+ InferenceError,
23
+ InferenceConnectionError,
24
+ InferenceConfigError,
25
+ InferencePayloadError
26
+ )
27
+ from src.org.slashlib.py.agent.inference_complements_for_ollama import (
28
+ OllamaInferenceAdapter,
29
+ OllamaInferenceResult
30
+ )
31
+
32
+ __all__ = [
33
+ "Agent",
34
+ "tool",
35
+ "AgentResponse",
36
+ "InferenceAdapter",
37
+ "InferenceResult",
38
+ "InferenceError",
39
+ "InferenceConnectionError",
40
+ "InferenceConfigError",
41
+ "InferencePayloadError",
42
+ "OllamaInferenceAdapter",
43
+ "OllamaInferenceResult"
44
+ ]
45
+
46
+ # end of file src/org/slashlib/py/agent/__init__.py
@@ -0,0 +1,91 @@
1
+ # -*- coding: utf-8 -*-
2
+ # file src/org/slashlib/py/agent/__main__.py
3
+ # @AI:
4
+ # - INTEGRITY RULES:
5
+ # - STRICT PRESERVATION: Do not remove, move, or modify ANY existing lines of code or comments
6
+ # unless they are the explicit target of the requested change.
7
+ # - DEBUG MARKERS: Commented-out code (e.g., debug prints) MUST be kept exactly where they are.
8
+ # - WHITESPACE & STRUCTURE: Maintain all original empty lines and the existing file structure.
9
+ # Structural integrity takes precedence over "clean code" or "elegance".
10
+ # - LEAD-IN/OUT: The very first and last lines (and all comments in between) are immutable anchors.
11
+ # - MAINTENANCE:
12
+ # - Only update pydoc strings (args, returns, raises) if the function signature changes.
13
+ # - Do NOT delete existing examples or descriptions in pydoc.
14
+ # - LANGUAGE: en-US for all comments and documentation.
15
+ #
16
+ # pragma: no cover
17
+ #
18
+ """
19
+ Entry point for the org.slashlib.py.agent package.
20
+ """
21
+
22
+ # Import python packages
23
+ import argparse
24
+ import logging
25
+ import pathlib
26
+ import sys
27
+ from importlib import metadata
28
+
29
+ # Compatibility layer for TOML (Python 3.11+ uses tomllib, older use tomli)
30
+ if sys.version_info >= (3, 11):
31
+ import tomllib
32
+ else:
33
+ try:
34
+ import tomli as tomllib
35
+ except ImportError:
36
+ tomllib = None
37
+
38
+ # Import thirdparty packages
39
+ import org.slashlib.py.configloader
40
+
41
+ # setup logging
42
+ org.slashlib.py.configloader.setup_logging()
43
+
44
+ log = logging.getLogger(f"org.slashlib.py.agent.{pathlib.Path(__file__).stem}")
45
+
46
+ def get_version() -> str:
47
+ """
48
+ Retrieve the version of the package from metadata or local pyproject.toml.
49
+ """
50
+ # 1. Try metadata (works if installed via pip)
51
+ try:
52
+ return metadata.version("org.slashlib.py.agent")
53
+ except metadata.PackageNotFoundError:
54
+ pass
55
+
56
+ # 2. Fallback: Parse pyproject.toml directly (works during development)
57
+ if tomllib is not None:
58
+ try:
59
+ # Search for pyproject.toml relative to this file's location
60
+ # Path: src/org/slashlib/py/agent/__main__.py -> root is 4 levels up
61
+ root_path = pathlib.Path(__file__).parents[5]
62
+ toml_path = root_path / "pyproject.toml"
63
+
64
+ if toml_path.exists():
65
+ with open(toml_path, "rb") as f:
66
+ data = tomllib.load(f)
67
+ return data.get("project", {}).get("version", "unknown (local)")
68
+ except Exception:
69
+ pass
70
+
71
+ return "unknown"
72
+
73
+ def start():
74
+ """
75
+ Bootstrap function to instantiate and run the bot.
76
+ """
77
+ parser = argparse.ArgumentParser(description="org.slashlib.py.agent CLI")
78
+ parser.add_argument("--version", action="store_true", help="Show the package version and exit")
79
+
80
+ args, unknown = parser.parse_known_args()
81
+
82
+ if args.version:
83
+ print(f"org.slashlib.py.agent version {get_version()}")
84
+ sys.exit(0)
85
+ else:
86
+ parser.print_help()
87
+
88
+ if __name__ == "__main__":
89
+ start()
90
+
91
+ # end of file src/org/slashlib/py/agent/__main__.py