asterinis 0.0.1__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.
- asterinis-0.0.1/LICENSE +21 -0
- asterinis-0.0.1/PKG-INFO +187 -0
- asterinis-0.0.1/README.md +155 -0
- asterinis-0.0.1/pyproject.toml +71 -0
- asterinis-0.0.1/setup.cfg +4 -0
- asterinis-0.0.1/src/asterinis/__init__.py +33 -0
- asterinis-0.0.1/src/asterinis/config.py +10 -0
- asterinis-0.0.1/src/asterinis/connectors.py +27 -0
- asterinis-0.0.1/src/asterinis/context.py +15 -0
- asterinis-0.0.1/src/asterinis/exceptions.py +14 -0
- asterinis-0.0.1/src/asterinis/hooks.py +18 -0
- asterinis-0.0.1/src/asterinis/integrations/__init__.py +3 -0
- asterinis-0.0.1/src/asterinis/integrations/flair.py +49 -0
- asterinis-0.0.1/src/asterinis/middleware.py +23 -0
- asterinis-0.0.1/src/asterinis/nexus.py +76 -0
- asterinis-0.0.1/src/asterinis/pipeline.py +33 -0
- asterinis-0.0.1/src/asterinis/registry.py +31 -0
- asterinis-0.0.1/src/asterinis/result.py +9 -0
- asterinis-0.0.1/src/asterinis/router.py +76 -0
- asterinis-0.0.1/src/asterinis.egg-info/PKG-INFO +187 -0
- asterinis-0.0.1/src/asterinis.egg-info/SOURCES.txt +23 -0
- asterinis-0.0.1/src/asterinis.egg-info/dependency_links.txt +1 -0
- asterinis-0.0.1/src/asterinis.egg-info/requires.txt +8 -0
- asterinis-0.0.1/src/asterinis.egg-info/top_level.txt +1 -0
- asterinis-0.0.1/tests/test_nexus.py +50 -0
asterinis-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Irena Popova
|
|
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.
|
asterinis-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: asterinis
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Python framework for AI orchestration, RAG, NLP integration, agent routing, and explainable AI.
|
|
5
|
+
Author: Irena Popova
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/irenapopova/asterinis
|
|
8
|
+
Project-URL: Repository, https://github.com/irenapopova/asterinis
|
|
9
|
+
Project-URL: Issues, https://github.com/irenapopova/asterinis/issues
|
|
10
|
+
Keywords: ai,rag,nlp,agents,llm,orchestration,flair,machine-learning,python
|
|
11
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Provides-Extra: flair
|
|
26
|
+
Requires-Dist: flair>=0.15; extra == "flair"
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
29
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
30
|
+
Requires-Dist: twine>=5.0; extra == "dev"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# asterinis
|
|
34
|
+
# Asterinis
|
|
35
|
+
|
|
36
|
+
**Asterinis** is an early-stage Python framework for connecting NLP, retrieval-augmented generation (RAG), AI agents, routing logic, explainability, and LLM services through a unified backend nexus.
|
|
37
|
+
|
|
38
|
+
The project is designed as a lightweight orchestration layer that can connect different AI and NLP components without locking an application to a single model provider or framework.
|
|
39
|
+
|
|
40
|
+
## Current Status
|
|
41
|
+
|
|
42
|
+
Asterinis is currently in an early development stage.
|
|
43
|
+
|
|
44
|
+
The first public release focuses on the core framework structure, including:
|
|
45
|
+
|
|
46
|
+
* Nexus orchestration
|
|
47
|
+
* Rule-based routing
|
|
48
|
+
* Connector interfaces
|
|
49
|
+
* Processing context
|
|
50
|
+
* Pipelines
|
|
51
|
+
* Hooks
|
|
52
|
+
* Result objects
|
|
53
|
+
* Optional NLP integrations
|
|
54
|
+
|
|
55
|
+
More advanced RAG, agent orchestration, adaptive routing, evaluation, and explainability features are planned for future releases.
|
|
56
|
+
|
|
57
|
+
## Installation
|
|
58
|
+
|
|
59
|
+
The package will be installable from PyPI:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install asterinis
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
For optional Flair NLP support:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install "asterinis[flair]"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Basic Usage
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from asterinis import Nexus
|
|
75
|
+
|
|
76
|
+
nexus = Nexus()
|
|
77
|
+
|
|
78
|
+
result = nexus.process(
|
|
79
|
+
"Search documents about multilingual NLP."
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
print(result.route)
|
|
83
|
+
print(result.payload)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Asterinis can route requests toward different processing paths such as:
|
|
87
|
+
|
|
88
|
+
```text
|
|
89
|
+
rag
|
|
90
|
+
nlp
|
|
91
|
+
agent
|
|
92
|
+
llm
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Flair Integration
|
|
96
|
+
|
|
97
|
+
Asterinis supports Flair as an optional NLP connector.
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from asterinis import Nexus
|
|
101
|
+
from asterinis.integrations import FlairConnector
|
|
102
|
+
|
|
103
|
+
nexus = Nexus()
|
|
104
|
+
|
|
105
|
+
nexus.register_connector(
|
|
106
|
+
"nlp",
|
|
107
|
+
FlairConnector("ner")
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
result = nexus.process(
|
|
111
|
+
"Deutsche Bank is based in Frankfurt."
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
print(result.to_dict())
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Flair is an independent open-source NLP framework and is not part of Asterinis. Asterinis provides an integration layer that allows Flair models to participate in a broader orchestration pipeline.
|
|
118
|
+
|
|
119
|
+
## Architecture
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
Application
|
|
123
|
+
↓
|
|
124
|
+
Asterinis Nexus
|
|
125
|
+
↓
|
|
126
|
+
Router
|
|
127
|
+
↓
|
|
128
|
+
┌──────────┬──────────┬──────────┬──────────┐
|
|
129
|
+
│ NLP │ RAG │ Agents │ LLM │
|
|
130
|
+
└──────────┴──────────┴──────────┴──────────┘
|
|
131
|
+
↓
|
|
132
|
+
Connectors / Integrations
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The goal is to allow developers to plug different AI systems into a consistent interface.
|
|
136
|
+
|
|
137
|
+
## Project Structure
|
|
138
|
+
|
|
139
|
+
```text
|
|
140
|
+
src/
|
|
141
|
+
└── asterinis/
|
|
142
|
+
├── __init__.py
|
|
143
|
+
├── nexus.py
|
|
144
|
+
├── router.py
|
|
145
|
+
├── connectors.py
|
|
146
|
+
├── context.py
|
|
147
|
+
├── pipeline.py
|
|
148
|
+
├── hooks.py
|
|
149
|
+
├── result.py
|
|
150
|
+
├── config.py
|
|
151
|
+
├── exceptions.py
|
|
152
|
+
└── integrations/
|
|
153
|
+
├── __init__.py
|
|
154
|
+
└── flair.py
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Roadmap
|
|
158
|
+
|
|
159
|
+
Future development may include:
|
|
160
|
+
|
|
161
|
+
* advanced RAG routing
|
|
162
|
+
* retrieval quality evaluation
|
|
163
|
+
* agent orchestration
|
|
164
|
+
* adaptive routing policies
|
|
165
|
+
* explainability
|
|
166
|
+
* confidence-aware decision logic
|
|
167
|
+
* additional NLP integrations
|
|
168
|
+
* LLM provider connectors
|
|
169
|
+
* evaluation tools
|
|
170
|
+
* persistent context and memory
|
|
171
|
+
* asynchronous pipelines
|
|
172
|
+
|
|
173
|
+
## Version
|
|
174
|
+
|
|
175
|
+
Current development version:
|
|
176
|
+
|
|
177
|
+
```text
|
|
178
|
+
0.0.1
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
Asterinis is released under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
184
|
+
|
|
185
|
+
## Author
|
|
186
|
+
|
|
187
|
+
Created and maintained by **Irena Popova**, Full-Stack Developer and AI/NLP, RAG, and adaptive systems researcher.
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# asterinis
|
|
2
|
+
# Asterinis
|
|
3
|
+
|
|
4
|
+
**Asterinis** is an early-stage Python framework for connecting NLP, retrieval-augmented generation (RAG), AI agents, routing logic, explainability, and LLM services through a unified backend nexus.
|
|
5
|
+
|
|
6
|
+
The project is designed as a lightweight orchestration layer that can connect different AI and NLP components without locking an application to a single model provider or framework.
|
|
7
|
+
|
|
8
|
+
## Current Status
|
|
9
|
+
|
|
10
|
+
Asterinis is currently in an early development stage.
|
|
11
|
+
|
|
12
|
+
The first public release focuses on the core framework structure, including:
|
|
13
|
+
|
|
14
|
+
* Nexus orchestration
|
|
15
|
+
* Rule-based routing
|
|
16
|
+
* Connector interfaces
|
|
17
|
+
* Processing context
|
|
18
|
+
* Pipelines
|
|
19
|
+
* Hooks
|
|
20
|
+
* Result objects
|
|
21
|
+
* Optional NLP integrations
|
|
22
|
+
|
|
23
|
+
More advanced RAG, agent orchestration, adaptive routing, evaluation, and explainability features are planned for future releases.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
The package will be installable from PyPI:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install asterinis
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
For optional Flair NLP support:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install "asterinis[flair]"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Basic Usage
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from asterinis import Nexus
|
|
43
|
+
|
|
44
|
+
nexus = Nexus()
|
|
45
|
+
|
|
46
|
+
result = nexus.process(
|
|
47
|
+
"Search documents about multilingual NLP."
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
print(result.route)
|
|
51
|
+
print(result.payload)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Asterinis can route requests toward different processing paths such as:
|
|
55
|
+
|
|
56
|
+
```text
|
|
57
|
+
rag
|
|
58
|
+
nlp
|
|
59
|
+
agent
|
|
60
|
+
llm
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Flair Integration
|
|
64
|
+
|
|
65
|
+
Asterinis supports Flair as an optional NLP connector.
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from asterinis import Nexus
|
|
69
|
+
from asterinis.integrations import FlairConnector
|
|
70
|
+
|
|
71
|
+
nexus = Nexus()
|
|
72
|
+
|
|
73
|
+
nexus.register_connector(
|
|
74
|
+
"nlp",
|
|
75
|
+
FlairConnector("ner")
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
result = nexus.process(
|
|
79
|
+
"Deutsche Bank is based in Frankfurt."
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
print(result.to_dict())
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Flair is an independent open-source NLP framework and is not part of Asterinis. Asterinis provides an integration layer that allows Flair models to participate in a broader orchestration pipeline.
|
|
86
|
+
|
|
87
|
+
## Architecture
|
|
88
|
+
|
|
89
|
+
```text
|
|
90
|
+
Application
|
|
91
|
+
↓
|
|
92
|
+
Asterinis Nexus
|
|
93
|
+
↓
|
|
94
|
+
Router
|
|
95
|
+
↓
|
|
96
|
+
┌──────────┬──────────┬──────────┬──────────┐
|
|
97
|
+
│ NLP │ RAG │ Agents │ LLM │
|
|
98
|
+
└──────────┴──────────┴──────────┴──────────┘
|
|
99
|
+
↓
|
|
100
|
+
Connectors / Integrations
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The goal is to allow developers to plug different AI systems into a consistent interface.
|
|
104
|
+
|
|
105
|
+
## Project Structure
|
|
106
|
+
|
|
107
|
+
```text
|
|
108
|
+
src/
|
|
109
|
+
└── asterinis/
|
|
110
|
+
├── __init__.py
|
|
111
|
+
├── nexus.py
|
|
112
|
+
├── router.py
|
|
113
|
+
├── connectors.py
|
|
114
|
+
├── context.py
|
|
115
|
+
├── pipeline.py
|
|
116
|
+
├── hooks.py
|
|
117
|
+
├── result.py
|
|
118
|
+
├── config.py
|
|
119
|
+
├── exceptions.py
|
|
120
|
+
└── integrations/
|
|
121
|
+
├── __init__.py
|
|
122
|
+
└── flair.py
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Roadmap
|
|
126
|
+
|
|
127
|
+
Future development may include:
|
|
128
|
+
|
|
129
|
+
* advanced RAG routing
|
|
130
|
+
* retrieval quality evaluation
|
|
131
|
+
* agent orchestration
|
|
132
|
+
* adaptive routing policies
|
|
133
|
+
* explainability
|
|
134
|
+
* confidence-aware decision logic
|
|
135
|
+
* additional NLP integrations
|
|
136
|
+
* LLM provider connectors
|
|
137
|
+
* evaluation tools
|
|
138
|
+
* persistent context and memory
|
|
139
|
+
* asynchronous pipelines
|
|
140
|
+
|
|
141
|
+
## Version
|
|
142
|
+
|
|
143
|
+
Current development version:
|
|
144
|
+
|
|
145
|
+
```text
|
|
146
|
+
0.0.1
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
Asterinis is released under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
152
|
+
|
|
153
|
+
## Author
|
|
154
|
+
|
|
155
|
+
Created and maintained by **Irena Popova**, Full-Stack Developer and AI/NLP, RAG, and adaptive systems researcher.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
[project]
|
|
7
|
+
name = "asterinis"
|
|
8
|
+
version = "0.0.1"
|
|
9
|
+
description = "Python framework for AI orchestration, RAG, NLP integration, agent routing, and explainable AI."
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
license = { text = "MIT" }
|
|
13
|
+
|
|
14
|
+
authors = [
|
|
15
|
+
{ name = "Irena Popova" }
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
keywords = [
|
|
19
|
+
"ai",
|
|
20
|
+
"rag",
|
|
21
|
+
"nlp",
|
|
22
|
+
"agents",
|
|
23
|
+
"llm",
|
|
24
|
+
"orchestration",
|
|
25
|
+
"flair",
|
|
26
|
+
"machine-learning",
|
|
27
|
+
"python"
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
classifiers = [
|
|
31
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
32
|
+
"Intended Audience :: Developers",
|
|
33
|
+
"Intended Audience :: Science/Research",
|
|
34
|
+
"License :: OSI Approved :: MIT License",
|
|
35
|
+
"Programming Language :: Python",
|
|
36
|
+
"Programming Language :: Python :: 3",
|
|
37
|
+
"Programming Language :: Python :: 3.10",
|
|
38
|
+
"Programming Language :: Python :: 3.11",
|
|
39
|
+
"Programming Language :: Python :: 3.12",
|
|
40
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
41
|
+
"Topic :: Software Development :: Libraries :: Python Modules"
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
dependencies = []
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
[project.optional-dependencies]
|
|
48
|
+
flair = [
|
|
49
|
+
"flair>=0.15"
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
dev = [
|
|
53
|
+
"pytest>=8.0",
|
|
54
|
+
"build>=1.2",
|
|
55
|
+
"twine>=5.0"
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
[project.urls]
|
|
60
|
+
Homepage = "https://github.com/irenapopova/asterinis"
|
|
61
|
+
Repository = "https://github.com/irenapopova/asterinis"
|
|
62
|
+
Issues = "https://github.com/irenapopova/asterinis/issues"
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
[tool.setuptools.packages.find]
|
|
66
|
+
where = ["src"]
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
[tool.pytest.ini_options]
|
|
70
|
+
pythonpath = ["src"]
|
|
71
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from .config import AsterinisConfig
|
|
2
|
+
from .connectors import Connector, EchoConnector
|
|
3
|
+
from .context import NexusContext
|
|
4
|
+
from .exceptions import (
|
|
5
|
+
AsterinisError,
|
|
6
|
+
ConnectorError,
|
|
7
|
+
PipelineError,
|
|
8
|
+
RoutingError,
|
|
9
|
+
)
|
|
10
|
+
from .hooks import HookManager
|
|
11
|
+
from .nexus import Nexus
|
|
12
|
+
from .pipeline import Pipeline
|
|
13
|
+
from .result import NexusResult
|
|
14
|
+
from .router import Router
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
__version__ = "0.0.1"
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"AsterinisConfig",
|
|
21
|
+
"AsterinisError",
|
|
22
|
+
"Connector",
|
|
23
|
+
"ConnectorError",
|
|
24
|
+
"EchoConnector",
|
|
25
|
+
"HookManager",
|
|
26
|
+
"Nexus",
|
|
27
|
+
"NexusContext",
|
|
28
|
+
"NexusResult",
|
|
29
|
+
"Pipeline",
|
|
30
|
+
"PipelineError",
|
|
31
|
+
"Router",
|
|
32
|
+
"RoutingError",
|
|
33
|
+
]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Connector(ABC):
|
|
6
|
+
"""
|
|
7
|
+
Base connector interface.
|
|
8
|
+
|
|
9
|
+
Connectors allow Asterinis to communicate with
|
|
10
|
+
external NLP, RAG, agent, or LLM systems.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
name: str = "connector"
|
|
14
|
+
|
|
15
|
+
@abstractmethod
|
|
16
|
+
def execute(self, payload: Any) -> Any:
|
|
17
|
+
raise NotImplementedError
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class EchoConnector(Connector):
|
|
21
|
+
name = "echo"
|
|
22
|
+
|
|
23
|
+
def execute(self, payload: Any) -> Any:
|
|
24
|
+
return {
|
|
25
|
+
"connector": self.name,
|
|
26
|
+
"payload": payload,
|
|
27
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class NexusContext:
|
|
7
|
+
input_text: str
|
|
8
|
+
metadata: dict[str, Any] = field(default_factory=dict)
|
|
9
|
+
state: dict[str, Any] = field(default_factory=dict)
|
|
10
|
+
|
|
11
|
+
def set(self, key: str, value: Any) -> None:
|
|
12
|
+
self.state[key] = value
|
|
13
|
+
|
|
14
|
+
def get(self, key: str, default: Any = None) -> Any:
|
|
15
|
+
return self.state.get(key, default)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class AsterinisError(Exception):
|
|
2
|
+
"""Base exception for Asterinis."""
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class RoutingError(AsterinisError):
|
|
6
|
+
"""Raised when routing cannot be completed."""
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ConnectorError(AsterinisError):
|
|
10
|
+
"""Raised when a connector fails."""
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class PipelineError(AsterinisError):
|
|
14
|
+
"""Raised when a pipeline step fails."""
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from collections import defaultdict
|
|
2
|
+
from collections.abc import Callable
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
Hook = Callable[..., Any]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class HookManager:
|
|
10
|
+
def __init__(self):
|
|
11
|
+
self._hooks: dict[str, list[Hook]] = defaultdict(list)
|
|
12
|
+
|
|
13
|
+
def register(self, event: str, callback: Hook) -> None:
|
|
14
|
+
self._hooks[event].append(callback)
|
|
15
|
+
|
|
16
|
+
def emit(self, event: str, **kwargs: Any) -> None:
|
|
17
|
+
for callback in self._hooks.get(event, []):
|
|
18
|
+
callback(**kwargs)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# src/asterinis/integrations/flair.py
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from asterinis.connectors import Connector
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class FlairConnector(Connector):
|
|
9
|
+
name = "flair"
|
|
10
|
+
|
|
11
|
+
def __init__(self, model_name: str = "ner"):
|
|
12
|
+
try:
|
|
13
|
+
from flair.nn import Classifier
|
|
14
|
+
except ImportError as exc:
|
|
15
|
+
raise ImportError(
|
|
16
|
+
"Flair is not installed. "
|
|
17
|
+
'Install it with: pip install "asterinis[flair]"'
|
|
18
|
+
) from exc
|
|
19
|
+
|
|
20
|
+
self.model_name = model_name
|
|
21
|
+
self.model = Classifier.load(model_name)
|
|
22
|
+
|
|
23
|
+
def execute(self, payload: Any) -> Any:
|
|
24
|
+
from flair.data import Sentence
|
|
25
|
+
|
|
26
|
+
text = payload["text"]
|
|
27
|
+
|
|
28
|
+
sentence = Sentence(text)
|
|
29
|
+
self.model.predict(sentence)
|
|
30
|
+
|
|
31
|
+
entities = []
|
|
32
|
+
|
|
33
|
+
for entity in sentence.get_spans("ner"):
|
|
34
|
+
label = entity.get_label("ner")
|
|
35
|
+
|
|
36
|
+
entities.append(
|
|
37
|
+
{
|
|
38
|
+
"text": entity.text,
|
|
39
|
+
"label": label.value,
|
|
40
|
+
"confidence": label.score,
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
"provider": "flair",
|
|
46
|
+
"model": self.model_name,
|
|
47
|
+
"text": text,
|
|
48
|
+
"entities": entities,
|
|
49
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Middleware(ABC):
|
|
6
|
+
|
|
7
|
+
def before(self, context: Any) -> Any:
|
|
8
|
+
return context
|
|
9
|
+
|
|
10
|
+
def after(self, result: Any) -> Any:
|
|
11
|
+
return result
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TimingMiddleware(Middleware):
|
|
15
|
+
|
|
16
|
+
def before(self, context):
|
|
17
|
+
import time
|
|
18
|
+
|
|
19
|
+
context.set("_start_time", time.perf_counter())
|
|
20
|
+
return context
|
|
21
|
+
|
|
22
|
+
def after(self, result):
|
|
23
|
+
return result
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
RouteRule = Callable[[str], bool]
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Router:
|
|
8
|
+
def __init__(self, default_route: str = "llm"):
|
|
9
|
+
self.default_route = default_route
|
|
10
|
+
self._rules: list[tuple[str, RouteRule]] = []
|
|
11
|
+
|
|
12
|
+
self._register_default_rules()
|
|
13
|
+
|
|
14
|
+
def _register_default_rules(self) -> None:
|
|
15
|
+
self.add_route(
|
|
16
|
+
"rag",
|
|
17
|
+
lambda text: any(
|
|
18
|
+
word in text.lower()
|
|
19
|
+
for word in (
|
|
20
|
+
"document",
|
|
21
|
+
"source",
|
|
22
|
+
"retrieve",
|
|
23
|
+
"search",
|
|
24
|
+
)
|
|
25
|
+
),
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
self.add_route(
|
|
29
|
+
"nlp",
|
|
30
|
+
lambda text: any(
|
|
31
|
+
word in text.lower()
|
|
32
|
+
for word in (
|
|
33
|
+
"entity",
|
|
34
|
+
"ner",
|
|
35
|
+
"language",
|
|
36
|
+
"nlp",
|
|
37
|
+
)
|
|
38
|
+
),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
self.add_route(
|
|
42
|
+
"agent",
|
|
43
|
+
lambda text: any(
|
|
44
|
+
word in text.lower()
|
|
45
|
+
for word in (
|
|
46
|
+
"agent",
|
|
47
|
+
"tool",
|
|
48
|
+
"workflow",
|
|
49
|
+
)
|
|
50
|
+
),
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
def add_route(
|
|
54
|
+
self,
|
|
55
|
+
name: str,
|
|
56
|
+
rule: RouteRule,
|
|
57
|
+
*,
|
|
58
|
+
first: bool = False,
|
|
59
|
+
) -> None:
|
|
60
|
+
route = (name, rule)
|
|
61
|
+
|
|
62
|
+
if first:
|
|
63
|
+
self._rules.insert(0, route)
|
|
64
|
+
else:
|
|
65
|
+
self._rules.append(route)
|
|
66
|
+
|
|
67
|
+
def route(self, text: str) -> str:
|
|
68
|
+
for name, rule in self._rules:
|
|
69
|
+
if rule(text):
|
|
70
|
+
return name
|
|
71
|
+
|
|
72
|
+
return self.default_route
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def routes(self) -> list[str]:
|
|
76
|
+
return [name for name, _ in self._rules]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
from .context import NexusContext
|
|
5
|
+
from .exceptions import PipelineError
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
PipelineStep = Callable[[NexusContext], NexusContext]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Pipeline:
|
|
12
|
+
def __init__(self, name: str):
|
|
13
|
+
self.name = name
|
|
14
|
+
self._steps: list[PipelineStep] = []
|
|
15
|
+
|
|
16
|
+
def add(self, step: PipelineStep) -> "Pipeline":
|
|
17
|
+
self._steps.append(step)
|
|
18
|
+
return self
|
|
19
|
+
|
|
20
|
+
def run(self, context: NexusContext) -> NexusContext:
|
|
21
|
+
try:
|
|
22
|
+
for step in self._steps:
|
|
23
|
+
context = step(context)
|
|
24
|
+
|
|
25
|
+
return context
|
|
26
|
+
|
|
27
|
+
except Exception as exc:
|
|
28
|
+
raise PipelineError(
|
|
29
|
+
f"Pipeline '{self.name}' failed."
|
|
30
|
+
) from exc
|
|
31
|
+
|
|
32
|
+
def __len__(self) -> int:
|
|
33
|
+
return len(self._steps)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from typing import Dict
|
|
2
|
+
|
|
3
|
+
from .connectors import Connector
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ConnectorRegistry:
|
|
7
|
+
def __init__(self):
|
|
8
|
+
self._connectors: Dict[str, Connector] = {}
|
|
9
|
+
|
|
10
|
+
def register(self, name: str, connector: Connector) -> None:
|
|
11
|
+
if not name:
|
|
12
|
+
raise ValueError("Connector name cannot be empty.")
|
|
13
|
+
|
|
14
|
+
self._connectors[name] = connector
|
|
15
|
+
|
|
16
|
+
def get(self, name: str) -> Connector:
|
|
17
|
+
if name not in self._connectors:
|
|
18
|
+
raise KeyError(
|
|
19
|
+
f"Connector '{name}' is not registered."
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
return self._connectors[name]
|
|
23
|
+
|
|
24
|
+
def remove(self, name: str) -> None:
|
|
25
|
+
self._connectors.pop(name, None)
|
|
26
|
+
|
|
27
|
+
def exists(self, name: str) -> bool:
|
|
28
|
+
return name in self._connectors
|
|
29
|
+
|
|
30
|
+
def list(self) -> list[str]:
|
|
31
|
+
return list(self._connectors.keys())
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
RouteRule = Callable[[str], bool]
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Router:
|
|
8
|
+
def __init__(self, default_route: str = "llm"):
|
|
9
|
+
self.default_route = default_route
|
|
10
|
+
self._rules: list[tuple[str, RouteRule]] = []
|
|
11
|
+
|
|
12
|
+
self._register_default_rules()
|
|
13
|
+
|
|
14
|
+
def _register_default_rules(self) -> None:
|
|
15
|
+
self.add_route(
|
|
16
|
+
"rag",
|
|
17
|
+
lambda text: any(
|
|
18
|
+
word in text.lower()
|
|
19
|
+
for word in (
|
|
20
|
+
"document",
|
|
21
|
+
"source",
|
|
22
|
+
"retrieve",
|
|
23
|
+
"search",
|
|
24
|
+
)
|
|
25
|
+
),
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
self.add_route(
|
|
29
|
+
"nlp",
|
|
30
|
+
lambda text: any(
|
|
31
|
+
word in text.lower()
|
|
32
|
+
for word in (
|
|
33
|
+
"entity",
|
|
34
|
+
"ner",
|
|
35
|
+
"language",
|
|
36
|
+
"nlp",
|
|
37
|
+
)
|
|
38
|
+
),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
self.add_route(
|
|
42
|
+
"agent",
|
|
43
|
+
lambda text: any(
|
|
44
|
+
word in text.lower()
|
|
45
|
+
for word in (
|
|
46
|
+
"agent",
|
|
47
|
+
"tool",
|
|
48
|
+
"workflow",
|
|
49
|
+
)
|
|
50
|
+
),
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
def add_route(
|
|
54
|
+
self,
|
|
55
|
+
name: str,
|
|
56
|
+
rule: RouteRule,
|
|
57
|
+
*,
|
|
58
|
+
first: bool = False,
|
|
59
|
+
) -> None:
|
|
60
|
+
route = (name, rule)
|
|
61
|
+
|
|
62
|
+
if first:
|
|
63
|
+
self._rules.insert(0, route)
|
|
64
|
+
else:
|
|
65
|
+
self._rules.append(route)
|
|
66
|
+
|
|
67
|
+
def route(self, text: str) -> str:
|
|
68
|
+
for name, rule in self._rules:
|
|
69
|
+
if rule(text):
|
|
70
|
+
return name
|
|
71
|
+
|
|
72
|
+
return self.default_route
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def routes(self) -> list[str]:
|
|
76
|
+
return [name for name, _ in self._rules]
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: asterinis
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Python framework for AI orchestration, RAG, NLP integration, agent routing, and explainable AI.
|
|
5
|
+
Author: Irena Popova
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/irenapopova/asterinis
|
|
8
|
+
Project-URL: Repository, https://github.com/irenapopova/asterinis
|
|
9
|
+
Project-URL: Issues, https://github.com/irenapopova/asterinis/issues
|
|
10
|
+
Keywords: ai,rag,nlp,agents,llm,orchestration,flair,machine-learning,python
|
|
11
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Provides-Extra: flair
|
|
26
|
+
Requires-Dist: flair>=0.15; extra == "flair"
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
29
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
30
|
+
Requires-Dist: twine>=5.0; extra == "dev"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# asterinis
|
|
34
|
+
# Asterinis
|
|
35
|
+
|
|
36
|
+
**Asterinis** is an early-stage Python framework for connecting NLP, retrieval-augmented generation (RAG), AI agents, routing logic, explainability, and LLM services through a unified backend nexus.
|
|
37
|
+
|
|
38
|
+
The project is designed as a lightweight orchestration layer that can connect different AI and NLP components without locking an application to a single model provider or framework.
|
|
39
|
+
|
|
40
|
+
## Current Status
|
|
41
|
+
|
|
42
|
+
Asterinis is currently in an early development stage.
|
|
43
|
+
|
|
44
|
+
The first public release focuses on the core framework structure, including:
|
|
45
|
+
|
|
46
|
+
* Nexus orchestration
|
|
47
|
+
* Rule-based routing
|
|
48
|
+
* Connector interfaces
|
|
49
|
+
* Processing context
|
|
50
|
+
* Pipelines
|
|
51
|
+
* Hooks
|
|
52
|
+
* Result objects
|
|
53
|
+
* Optional NLP integrations
|
|
54
|
+
|
|
55
|
+
More advanced RAG, agent orchestration, adaptive routing, evaluation, and explainability features are planned for future releases.
|
|
56
|
+
|
|
57
|
+
## Installation
|
|
58
|
+
|
|
59
|
+
The package will be installable from PyPI:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install asterinis
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
For optional Flair NLP support:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install "asterinis[flair]"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Basic Usage
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from asterinis import Nexus
|
|
75
|
+
|
|
76
|
+
nexus = Nexus()
|
|
77
|
+
|
|
78
|
+
result = nexus.process(
|
|
79
|
+
"Search documents about multilingual NLP."
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
print(result.route)
|
|
83
|
+
print(result.payload)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Asterinis can route requests toward different processing paths such as:
|
|
87
|
+
|
|
88
|
+
```text
|
|
89
|
+
rag
|
|
90
|
+
nlp
|
|
91
|
+
agent
|
|
92
|
+
llm
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Flair Integration
|
|
96
|
+
|
|
97
|
+
Asterinis supports Flair as an optional NLP connector.
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from asterinis import Nexus
|
|
101
|
+
from asterinis.integrations import FlairConnector
|
|
102
|
+
|
|
103
|
+
nexus = Nexus()
|
|
104
|
+
|
|
105
|
+
nexus.register_connector(
|
|
106
|
+
"nlp",
|
|
107
|
+
FlairConnector("ner")
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
result = nexus.process(
|
|
111
|
+
"Deutsche Bank is based in Frankfurt."
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
print(result.to_dict())
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Flair is an independent open-source NLP framework and is not part of Asterinis. Asterinis provides an integration layer that allows Flair models to participate in a broader orchestration pipeline.
|
|
118
|
+
|
|
119
|
+
## Architecture
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
Application
|
|
123
|
+
↓
|
|
124
|
+
Asterinis Nexus
|
|
125
|
+
↓
|
|
126
|
+
Router
|
|
127
|
+
↓
|
|
128
|
+
┌──────────┬──────────┬──────────┬──────────┐
|
|
129
|
+
│ NLP │ RAG │ Agents │ LLM │
|
|
130
|
+
└──────────┴──────────┴──────────┴──────────┘
|
|
131
|
+
↓
|
|
132
|
+
Connectors / Integrations
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The goal is to allow developers to plug different AI systems into a consistent interface.
|
|
136
|
+
|
|
137
|
+
## Project Structure
|
|
138
|
+
|
|
139
|
+
```text
|
|
140
|
+
src/
|
|
141
|
+
└── asterinis/
|
|
142
|
+
├── __init__.py
|
|
143
|
+
├── nexus.py
|
|
144
|
+
├── router.py
|
|
145
|
+
├── connectors.py
|
|
146
|
+
├── context.py
|
|
147
|
+
├── pipeline.py
|
|
148
|
+
├── hooks.py
|
|
149
|
+
├── result.py
|
|
150
|
+
├── config.py
|
|
151
|
+
├── exceptions.py
|
|
152
|
+
└── integrations/
|
|
153
|
+
├── __init__.py
|
|
154
|
+
└── flair.py
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Roadmap
|
|
158
|
+
|
|
159
|
+
Future development may include:
|
|
160
|
+
|
|
161
|
+
* advanced RAG routing
|
|
162
|
+
* retrieval quality evaluation
|
|
163
|
+
* agent orchestration
|
|
164
|
+
* adaptive routing policies
|
|
165
|
+
* explainability
|
|
166
|
+
* confidence-aware decision logic
|
|
167
|
+
* additional NLP integrations
|
|
168
|
+
* LLM provider connectors
|
|
169
|
+
* evaluation tools
|
|
170
|
+
* persistent context and memory
|
|
171
|
+
* asynchronous pipelines
|
|
172
|
+
|
|
173
|
+
## Version
|
|
174
|
+
|
|
175
|
+
Current development version:
|
|
176
|
+
|
|
177
|
+
```text
|
|
178
|
+
0.0.1
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
Asterinis is released under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
184
|
+
|
|
185
|
+
## Author
|
|
186
|
+
|
|
187
|
+
Created and maintained by **Irena Popova**, Full-Stack Developer and AI/NLP, RAG, and adaptive systems researcher.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/asterinis/__init__.py
|
|
5
|
+
src/asterinis/config.py
|
|
6
|
+
src/asterinis/connectors.py
|
|
7
|
+
src/asterinis/context.py
|
|
8
|
+
src/asterinis/exceptions.py
|
|
9
|
+
src/asterinis/hooks.py
|
|
10
|
+
src/asterinis/middleware.py
|
|
11
|
+
src/asterinis/nexus.py
|
|
12
|
+
src/asterinis/pipeline.py
|
|
13
|
+
src/asterinis/registry.py
|
|
14
|
+
src/asterinis/result.py
|
|
15
|
+
src/asterinis/router.py
|
|
16
|
+
src/asterinis.egg-info/PKG-INFO
|
|
17
|
+
src/asterinis.egg-info/SOURCES.txt
|
|
18
|
+
src/asterinis.egg-info/dependency_links.txt
|
|
19
|
+
src/asterinis.egg-info/requires.txt
|
|
20
|
+
src/asterinis.egg-info/top_level.txt
|
|
21
|
+
src/asterinis/integrations/__init__.py
|
|
22
|
+
src/asterinis/integrations/flair.py
|
|
23
|
+
tests/test_nexus.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
asterinis
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from asterinis import Nexus
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_info():
|
|
7
|
+
nexus = Nexus()
|
|
8
|
+
|
|
9
|
+
info = nexus.info()
|
|
10
|
+
|
|
11
|
+
assert info["name"] == "Asterinis"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def test_rag_route():
|
|
15
|
+
nexus = Nexus()
|
|
16
|
+
|
|
17
|
+
result = nexus.process("Search documents about RAG.")
|
|
18
|
+
|
|
19
|
+
assert result.route == "rag"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_nlp_route():
|
|
23
|
+
nexus = Nexus()
|
|
24
|
+
|
|
25
|
+
result = nexus.process("Analyze this entity using NLP.")
|
|
26
|
+
|
|
27
|
+
assert result.route == "nlp"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_agent_route():
|
|
31
|
+
nexus = Nexus()
|
|
32
|
+
|
|
33
|
+
result = nexus.process("Use an agent workflow.")
|
|
34
|
+
|
|
35
|
+
assert result.route == "agent"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_default_route():
|
|
39
|
+
nexus = Nexus()
|
|
40
|
+
|
|
41
|
+
result = nexus.process("Explain recursion.")
|
|
42
|
+
|
|
43
|
+
assert result.route == "llm"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def test_empty_input():
|
|
47
|
+
nexus = Nexus()
|
|
48
|
+
|
|
49
|
+
with pytest.raises(ValueError):
|
|
50
|
+
nexus.process("")
|