nineth 0.0.4__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.
- nineth-0.0.4/.gitignore +211 -0
- nineth-0.0.4/PKG-INFO +195 -0
- nineth-0.0.4/pyproject.toml +41 -0
- nineth-0.0.4/rooster-sdk/about.md +181 -0
- nineth-0.0.4/rooster-sdk/requirements.txt +1 -0
- nineth-0.0.4/rooster-sdk/roosted/__init__.py +18 -0
- nineth-0.0.4/rooster-sdk/roosted/client.py +239 -0
nineth-0.0.4/.gitignore
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
.env
|
|
9
|
+
|
|
10
|
+
# Distribution / packaging
|
|
11
|
+
.Python
|
|
12
|
+
.venv/
|
|
13
|
+
.env/
|
|
14
|
+
venv/
|
|
15
|
+
build/
|
|
16
|
+
develop-eggs/
|
|
17
|
+
dist/
|
|
18
|
+
downloads/
|
|
19
|
+
eggs/
|
|
20
|
+
.eggs/
|
|
21
|
+
lib/
|
|
22
|
+
lib64/
|
|
23
|
+
parts/
|
|
24
|
+
sdist/
|
|
25
|
+
var/
|
|
26
|
+
wheels/
|
|
27
|
+
share/python-wheels/
|
|
28
|
+
*.egg-info/
|
|
29
|
+
.installed.cfg
|
|
30
|
+
*.egg
|
|
31
|
+
MANIFEST
|
|
32
|
+
|
|
33
|
+
# PyInstaller
|
|
34
|
+
# Usually these files are written by a python script from a template
|
|
35
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
36
|
+
*.manifest
|
|
37
|
+
*.spec
|
|
38
|
+
|
|
39
|
+
# Installer logs
|
|
40
|
+
pip-log.txt
|
|
41
|
+
pip-delete-this-directory.txt
|
|
42
|
+
|
|
43
|
+
# Unit test / coverage reports
|
|
44
|
+
htmlcov/
|
|
45
|
+
.tox/
|
|
46
|
+
.nox/
|
|
47
|
+
.coverage
|
|
48
|
+
.coverage.*
|
|
49
|
+
.cache
|
|
50
|
+
nosetests.xml
|
|
51
|
+
coverage.xml
|
|
52
|
+
*.cover
|
|
53
|
+
*.py.cover
|
|
54
|
+
.hypothesis/
|
|
55
|
+
.pytest_cache/
|
|
56
|
+
cover/
|
|
57
|
+
|
|
58
|
+
# Translations
|
|
59
|
+
*.mo
|
|
60
|
+
*.pot
|
|
61
|
+
|
|
62
|
+
# Django stuff:
|
|
63
|
+
*.log
|
|
64
|
+
local_settings.py
|
|
65
|
+
db.sqlite3
|
|
66
|
+
db.sqlite3-journal
|
|
67
|
+
|
|
68
|
+
# Flask stuff:
|
|
69
|
+
instance/
|
|
70
|
+
.webassets-cache
|
|
71
|
+
|
|
72
|
+
# Scrapy stuff:
|
|
73
|
+
.scrapy
|
|
74
|
+
|
|
75
|
+
# Sphinx documentation
|
|
76
|
+
docs/_build/
|
|
77
|
+
|
|
78
|
+
# PyBuilder
|
|
79
|
+
.pybuilder/
|
|
80
|
+
target/
|
|
81
|
+
|
|
82
|
+
# Jupyter Notebook
|
|
83
|
+
.ipynb_checkpoints
|
|
84
|
+
|
|
85
|
+
# IPython
|
|
86
|
+
profile_default/
|
|
87
|
+
ipython_config.py
|
|
88
|
+
|
|
89
|
+
# pyenv
|
|
90
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
91
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
92
|
+
# .python-version
|
|
93
|
+
|
|
94
|
+
# pipenv
|
|
95
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
96
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
97
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
98
|
+
# install all needed dependencies.
|
|
99
|
+
#Pipfile.lock
|
|
100
|
+
|
|
101
|
+
# UV
|
|
102
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
103
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
104
|
+
# commonly ignored for libraries.
|
|
105
|
+
#uv.lock
|
|
106
|
+
|
|
107
|
+
# poetry
|
|
108
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
109
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
110
|
+
# commonly ignored for libraries.
|
|
111
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
112
|
+
#poetry.lock
|
|
113
|
+
#poetry.toml
|
|
114
|
+
|
|
115
|
+
# pdm
|
|
116
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
117
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
118
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
119
|
+
#pdm.lock
|
|
120
|
+
#pdm.toml
|
|
121
|
+
.pdm-python
|
|
122
|
+
.pdm-build/
|
|
123
|
+
|
|
124
|
+
# pixi
|
|
125
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
126
|
+
#pixi.lock
|
|
127
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
128
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
129
|
+
.pixi
|
|
130
|
+
|
|
131
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
132
|
+
__pypackages__/
|
|
133
|
+
|
|
134
|
+
# Celery stuff
|
|
135
|
+
celerybeat-schedule
|
|
136
|
+
celerybeat.pid
|
|
137
|
+
|
|
138
|
+
# SageMath parsed files
|
|
139
|
+
*.sage.py
|
|
140
|
+
|
|
141
|
+
# Environments
|
|
142
|
+
.env
|
|
143
|
+
.envrc
|
|
144
|
+
.venv
|
|
145
|
+
env/
|
|
146
|
+
venv/
|
|
147
|
+
ENV/
|
|
148
|
+
env.bak/
|
|
149
|
+
venv.bak/
|
|
150
|
+
|
|
151
|
+
# Spyder project settings
|
|
152
|
+
.spyderproject
|
|
153
|
+
.spyproject
|
|
154
|
+
|
|
155
|
+
# Rope project settings
|
|
156
|
+
.ropeproject
|
|
157
|
+
|
|
158
|
+
# mkdocs documentation
|
|
159
|
+
/site
|
|
160
|
+
|
|
161
|
+
# mypy
|
|
162
|
+
.mypy_cache/
|
|
163
|
+
.dmypy.json
|
|
164
|
+
dmypy.json
|
|
165
|
+
|
|
166
|
+
# Pyre type checker
|
|
167
|
+
.pyre/
|
|
168
|
+
|
|
169
|
+
# pytype static type analyzer
|
|
170
|
+
.pytype/
|
|
171
|
+
|
|
172
|
+
# Cython debug symbols
|
|
173
|
+
cython_debug/
|
|
174
|
+
|
|
175
|
+
# PyCharm
|
|
176
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
177
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
178
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
179
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
180
|
+
#.idea/
|
|
181
|
+
|
|
182
|
+
# Abstra
|
|
183
|
+
# Abstra is an AI-powered process automation framework.
|
|
184
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
185
|
+
# Learn more at https://abstra.io/docs
|
|
186
|
+
.abstra/
|
|
187
|
+
|
|
188
|
+
# Visual Studio Code
|
|
189
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
190
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
191
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
192
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
193
|
+
# .vscode/
|
|
194
|
+
|
|
195
|
+
# Ruff stuff:
|
|
196
|
+
.ruff_cache/
|
|
197
|
+
|
|
198
|
+
# PyPI configuration file
|
|
199
|
+
.pypirc
|
|
200
|
+
|
|
201
|
+
# Cursor
|
|
202
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
203
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
204
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
205
|
+
.cursorignore
|
|
206
|
+
.cursorindexingignore
|
|
207
|
+
|
|
208
|
+
# Marimo
|
|
209
|
+
marimo/_static/
|
|
210
|
+
marimo/_lsp/
|
|
211
|
+
__marimo__/
|
nineth-0.0.4/PKG-INFO
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nineth
|
|
3
|
+
Version: 0.0.4
|
|
4
|
+
Summary: model sdk built by the 9th ditrict at tooig
|
|
5
|
+
Project-URL: Homepage, https://github.com/districtt/rooster
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/districtt/rooster/issues
|
|
7
|
+
Author-email: "Tooig, Inc" <tooighq@gmail.com>, Oyebamijo <boy@oyebamijo.com>
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Requires-Dist: httpx<1.0,>=0.27.2
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# nineth-sdk
|
|
16
|
+
|
|
17
|
+
`nineth-sdk` is the lightweight Python SDK for the Rooster agent API.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install nineth
|
|
23
|
+
export NINETH_API_KEY="your-shared-api-key"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 60-Second Start
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from nineth import NinethClient
|
|
30
|
+
|
|
31
|
+
with NinethClient() as client:
|
|
32
|
+
result = client.invoke(
|
|
33
|
+
"Give me a tight market update on BTC.",
|
|
34
|
+
services=False,
|
|
35
|
+
cache=False,
|
|
36
|
+
)
|
|
37
|
+
print(result["final_response"])
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
That works because:
|
|
41
|
+
|
|
42
|
+
- the SDK defaults to `https://weirdpablo--rooster-api.modal.run`
|
|
43
|
+
- the SDK reads `NINETH_API_KEY` automatically
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
import os
|
|
49
|
+
from nineth import NinethClient
|
|
50
|
+
|
|
51
|
+
client = NinethClient(api_key=os.environ["NINETH_API_KEY"])
|
|
52
|
+
|
|
53
|
+
response = client.invoke(
|
|
54
|
+
"Give me a terse overview of crude oil today.",
|
|
55
|
+
model_name="district/1984-m3-0317",
|
|
56
|
+
services=False,
|
|
57
|
+
cache=False,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
print(response["final_response"])
|
|
61
|
+
client.close()
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Streaming
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
import os
|
|
68
|
+
from nineth import NinethClient
|
|
69
|
+
|
|
70
|
+
with NinethClient(api_key=os.environ["NINETH_API_KEY"]) as client:
|
|
71
|
+
for event in client.stream(
|
|
72
|
+
"Research Nvidia's latest earnings and summarize the key points.",
|
|
73
|
+
services=True,
|
|
74
|
+
service_names=["search_web", "read"],
|
|
75
|
+
cache=True,
|
|
76
|
+
max_iterations=6,
|
|
77
|
+
):
|
|
78
|
+
print(event["type"], event["data"])
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Health Check
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from nineth import NinethClient
|
|
85
|
+
|
|
86
|
+
with NinethClient() as client:
|
|
87
|
+
print(client.health())
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`health()` does not require authentication.
|
|
91
|
+
|
|
92
|
+
The SDK yields parsed SSE payloads as dictionaries. Typical event types are:
|
|
93
|
+
|
|
94
|
+
- `accepted`
|
|
95
|
+
- `run_started`
|
|
96
|
+
- `model_start`
|
|
97
|
+
- `model_delta`
|
|
98
|
+
- `model_response`
|
|
99
|
+
- `service_call`
|
|
100
|
+
- `service_response`
|
|
101
|
+
- `result`
|
|
102
|
+
- `completed`
|
|
103
|
+
- `error`
|
|
104
|
+
|
|
105
|
+
## Async Client
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
import asyncio
|
|
109
|
+
import os
|
|
110
|
+
from nineth import AsyncNinethClient
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
async def main():
|
|
114
|
+
async with AsyncNinethClient(api_key=os.environ["NINETH_API_KEY"]) as client:
|
|
115
|
+
response = await client.invoke(
|
|
116
|
+
"Tell me whether gold is trending or ranging.",
|
|
117
|
+
services=False,
|
|
118
|
+
cache=False,
|
|
119
|
+
)
|
|
120
|
+
print(response["final_response"])
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
asyncio.run(main())
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Payload Options
|
|
127
|
+
|
|
128
|
+
The SDK maps directly to the API request body. The most important options are:
|
|
129
|
+
|
|
130
|
+
- `task_input`
|
|
131
|
+
- `model_name`
|
|
132
|
+
- `services`
|
|
133
|
+
- `service_names`
|
|
134
|
+
- `cache`
|
|
135
|
+
- `max_iterations`
|
|
136
|
+
- `reasoning_effort`
|
|
137
|
+
- `continuous`
|
|
138
|
+
- `images`
|
|
139
|
+
- `system_prompt`
|
|
140
|
+
|
|
141
|
+
Unknown request keys can be passed through with `extra={...}` in `build_payload(...)`.
|
|
142
|
+
|
|
143
|
+
## What You Get Back
|
|
144
|
+
|
|
145
|
+
`invoke()` returns a dictionary like:
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
{
|
|
149
|
+
"process_id": "...",
|
|
150
|
+
"model_name": "district/1984-m3-0317",
|
|
151
|
+
"final_response": "...",
|
|
152
|
+
"usage": {...},
|
|
153
|
+
"thinking": [...],
|
|
154
|
+
"service_calls": [...],
|
|
155
|
+
"service_responses": [...],
|
|
156
|
+
"iterations": 2,
|
|
157
|
+
"events": [...],
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
`stream()` yields one dictionary per SSE event, for example:
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
{
|
|
165
|
+
"type": "model_response",
|
|
166
|
+
"timestamp": "2026-04-03T00:00:00+00:00",
|
|
167
|
+
"process_id": "...",
|
|
168
|
+
"iteration": 1,
|
|
169
|
+
"data": {
|
|
170
|
+
"visible_response": "..."
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Authentication
|
|
176
|
+
|
|
177
|
+
Execution requests send the shared key in the `X-API-Key` header. The SDK reads it from:
|
|
178
|
+
|
|
179
|
+
- the `api_key=` constructor argument
|
|
180
|
+
- or the `NINETH_API_KEY` environment variable
|
|
181
|
+
|
|
182
|
+
`health()` does not require authentication, but `invoke()` and `stream()` do.
|
|
183
|
+
|
|
184
|
+
## Overriding The Endpoint
|
|
185
|
+
|
|
186
|
+
Use a different deployment like this:
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
from nineth import NinethClient
|
|
190
|
+
|
|
191
|
+
client = NinethClient(
|
|
192
|
+
base_url="https://your-other-deployment.modal.run",
|
|
193
|
+
api_key="your-shared-api-key",
|
|
194
|
+
)
|
|
195
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "nineth"
|
|
7
|
+
version = "0.0.4"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="Tooig, Inc", email="tooighq@gmail.com" },
|
|
10
|
+
{ name="Oyebamijo", email="boy@oyebamijo.com" }
|
|
11
|
+
]
|
|
12
|
+
description = " model sdk built by the 9th ditrict at tooig"
|
|
13
|
+
readme = "rooster-sdk/about.md"
|
|
14
|
+
requires-python = ">=3.10"
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
]
|
|
20
|
+
dependencies = [
|
|
21
|
+
"httpx>=0.27.2,<1.0"
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
"Homepage" = "https://github.com/districtt/rooster"
|
|
27
|
+
"Bug Tracker" = "https://github.com/districtt/rooster/issues"
|
|
28
|
+
|
|
29
|
+
[tool.pytest.ini_options]
|
|
30
|
+
addopts = "-q"
|
|
31
|
+
|
|
32
|
+
[tool.hatch.build.targets.wheel]
|
|
33
|
+
packages = ["rooster-sdk/roosted"]
|
|
34
|
+
|
|
35
|
+
[tool.hatch.build.targets.sdist]
|
|
36
|
+
include = [
|
|
37
|
+
"rooster-sdk/roosted",
|
|
38
|
+
"rooster-sdk/about.md",
|
|
39
|
+
"rooster-sdk/requirements.txt",
|
|
40
|
+
"pyproject.toml",
|
|
41
|
+
]
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# nineth-sdk
|
|
2
|
+
|
|
3
|
+
`nineth-sdk` is the lightweight Python SDK for the Rooster agent API.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install nineth
|
|
9
|
+
export NINETH_API_KEY="your-shared-api-key"
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 60-Second Start
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
from nineth import NinethClient
|
|
16
|
+
|
|
17
|
+
with NinethClient() as client:
|
|
18
|
+
result = client.invoke(
|
|
19
|
+
"Give me a tight market update on BTC.",
|
|
20
|
+
services=False,
|
|
21
|
+
cache=False,
|
|
22
|
+
)
|
|
23
|
+
print(result["final_response"])
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
That works because:
|
|
27
|
+
|
|
28
|
+
- the SDK defaults to `https://weirdpablo--rooster-api.modal.run`
|
|
29
|
+
- the SDK reads `NINETH_API_KEY` automatically
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
import os
|
|
35
|
+
from nineth import NinethClient
|
|
36
|
+
|
|
37
|
+
client = NinethClient(api_key=os.environ["NINETH_API_KEY"])
|
|
38
|
+
|
|
39
|
+
response = client.invoke(
|
|
40
|
+
"Give me a terse overview of crude oil today.",
|
|
41
|
+
model_name="district/1984-m3-0317",
|
|
42
|
+
services=False,
|
|
43
|
+
cache=False,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
print(response["final_response"])
|
|
47
|
+
client.close()
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Streaming
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
import os
|
|
54
|
+
from nineth import NinethClient
|
|
55
|
+
|
|
56
|
+
with NinethClient(api_key=os.environ["NINETH_API_KEY"]) as client:
|
|
57
|
+
for event in client.stream(
|
|
58
|
+
"Research Nvidia's latest earnings and summarize the key points.",
|
|
59
|
+
services=True,
|
|
60
|
+
service_names=["search_web", "read"],
|
|
61
|
+
cache=True,
|
|
62
|
+
max_iterations=6,
|
|
63
|
+
):
|
|
64
|
+
print(event["type"], event["data"])
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Health Check
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from nineth import NinethClient
|
|
71
|
+
|
|
72
|
+
with NinethClient() as client:
|
|
73
|
+
print(client.health())
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`health()` does not require authentication.
|
|
77
|
+
|
|
78
|
+
The SDK yields parsed SSE payloads as dictionaries. Typical event types are:
|
|
79
|
+
|
|
80
|
+
- `accepted`
|
|
81
|
+
- `run_started`
|
|
82
|
+
- `model_start`
|
|
83
|
+
- `model_delta`
|
|
84
|
+
- `model_response`
|
|
85
|
+
- `service_call`
|
|
86
|
+
- `service_response`
|
|
87
|
+
- `result`
|
|
88
|
+
- `completed`
|
|
89
|
+
- `error`
|
|
90
|
+
|
|
91
|
+
## Async Client
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
import asyncio
|
|
95
|
+
import os
|
|
96
|
+
from nineth import AsyncNinethClient
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
async def main():
|
|
100
|
+
async with AsyncNinethClient(api_key=os.environ["NINETH_API_KEY"]) as client:
|
|
101
|
+
response = await client.invoke(
|
|
102
|
+
"Tell me whether gold is trending or ranging.",
|
|
103
|
+
services=False,
|
|
104
|
+
cache=False,
|
|
105
|
+
)
|
|
106
|
+
print(response["final_response"])
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
asyncio.run(main())
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Payload Options
|
|
113
|
+
|
|
114
|
+
The SDK maps directly to the API request body. The most important options are:
|
|
115
|
+
|
|
116
|
+
- `task_input`
|
|
117
|
+
- `model_name`
|
|
118
|
+
- `services`
|
|
119
|
+
- `service_names`
|
|
120
|
+
- `cache`
|
|
121
|
+
- `max_iterations`
|
|
122
|
+
- `reasoning_effort`
|
|
123
|
+
- `continuous`
|
|
124
|
+
- `images`
|
|
125
|
+
- `system_prompt`
|
|
126
|
+
|
|
127
|
+
Unknown request keys can be passed through with `extra={...}` in `build_payload(...)`.
|
|
128
|
+
|
|
129
|
+
## What You Get Back
|
|
130
|
+
|
|
131
|
+
`invoke()` returns a dictionary like:
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
{
|
|
135
|
+
"process_id": "...",
|
|
136
|
+
"model_name": "district/1984-m3-0317",
|
|
137
|
+
"final_response": "...",
|
|
138
|
+
"usage": {...},
|
|
139
|
+
"thinking": [...],
|
|
140
|
+
"service_calls": [...],
|
|
141
|
+
"service_responses": [...],
|
|
142
|
+
"iterations": 2,
|
|
143
|
+
"events": [...],
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
`stream()` yields one dictionary per SSE event, for example:
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
{
|
|
151
|
+
"type": "model_response",
|
|
152
|
+
"timestamp": "2026-04-03T00:00:00+00:00",
|
|
153
|
+
"process_id": "...",
|
|
154
|
+
"iteration": 1,
|
|
155
|
+
"data": {
|
|
156
|
+
"visible_response": "..."
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Authentication
|
|
162
|
+
|
|
163
|
+
Execution requests send the shared key in the `X-API-Key` header. The SDK reads it from:
|
|
164
|
+
|
|
165
|
+
- the `api_key=` constructor argument
|
|
166
|
+
- or the `NINETH_API_KEY` environment variable
|
|
167
|
+
|
|
168
|
+
`health()` does not require authentication, but `invoke()` and `stream()` do.
|
|
169
|
+
|
|
170
|
+
## Overriding The Endpoint
|
|
171
|
+
|
|
172
|
+
Use a different deployment like this:
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
from nineth import NinethClient
|
|
176
|
+
|
|
177
|
+
client = NinethClient(
|
|
178
|
+
base_url="https://your-other-deployment.modal.run",
|
|
179
|
+
api_key="your-shared-api-key",
|
|
180
|
+
)
|
|
181
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
httpx>=0.27.2,<1.0
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from .client import AsyncRoosterClient, RoosterAPIError, RoosterClient, build_payload
|
|
2
|
+
|
|
3
|
+
try:
|
|
4
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
5
|
+
except ImportError:
|
|
6
|
+
from importlib_metadata import PackageNotFoundError, version
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"AsyncRoosterClient",
|
|
10
|
+
"RoosterAPIError",
|
|
11
|
+
"RoosterClient",
|
|
12
|
+
"build_payload",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
__version__ = version("roosted")
|
|
17
|
+
except PackageNotFoundError:
|
|
18
|
+
__version__ = "0.0.0"
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"""Python client for the Rooster agent API."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
from typing import Any, AsyncIterator, Dict, Iterator, Optional
|
|
8
|
+
|
|
9
|
+
import httpx
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
DEFAULT_TIMEOUT = 60.0
|
|
13
|
+
DEFAULT_BASE_URL = "https://weirdpablo--rooster-api.modal.run"
|
|
14
|
+
API_KEY_HEADER = "X-API-Key"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class RoosterAPIError(RuntimeError):
|
|
18
|
+
"""Raised when the Rooster API returns an unexpected response."""
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def build_payload(
|
|
22
|
+
task_input: str,
|
|
23
|
+
*,
|
|
24
|
+
model_name: Optional[str] = None,
|
|
25
|
+
services: bool = True,
|
|
26
|
+
service_names: Optional[list[str]] = None,
|
|
27
|
+
cache: bool = True,
|
|
28
|
+
max_iterations: int = 50,
|
|
29
|
+
reasoning_effort: str = "low",
|
|
30
|
+
process_id: Optional[str] = None,
|
|
31
|
+
user_id: Optional[str] = None,
|
|
32
|
+
debug: bool = False,
|
|
33
|
+
continuous: bool = False,
|
|
34
|
+
images: Optional[list[str]] = None,
|
|
35
|
+
system_prompt: Optional[str] = None,
|
|
36
|
+
extra: Optional[Dict[str, Any]] = None,
|
|
37
|
+
) -> Dict[str, Any]:
|
|
38
|
+
payload: Dict[str, Any] = {
|
|
39
|
+
"task_input": task_input,
|
|
40
|
+
"model_name": model_name,
|
|
41
|
+
"services": services,
|
|
42
|
+
"service_names": service_names,
|
|
43
|
+
"cache": cache,
|
|
44
|
+
"max_iterations": max_iterations,
|
|
45
|
+
"reasoning_effort": reasoning_effort,
|
|
46
|
+
"process_id": process_id,
|
|
47
|
+
"user_id": user_id,
|
|
48
|
+
"debug": debug,
|
|
49
|
+
"continuous": continuous,
|
|
50
|
+
"images": images,
|
|
51
|
+
"system_prompt": system_prompt,
|
|
52
|
+
}
|
|
53
|
+
if extra:
|
|
54
|
+
payload.update(extra)
|
|
55
|
+
return {key: value for key, value in payload.items() if value is not None}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _raise_for_status(response: httpx.Response) -> None:
|
|
59
|
+
try:
|
|
60
|
+
response.raise_for_status()
|
|
61
|
+
except httpx.HTTPStatusError as exc:
|
|
62
|
+
message = response.text.strip() or str(exc)
|
|
63
|
+
raise RoosterAPIError(message) from exc
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _parse_sse_lines(lines: Iterator[str]) -> Iterator[Dict[str, Any]]:
|
|
67
|
+
event_type = "message"
|
|
68
|
+
data_lines: list[str] = []
|
|
69
|
+
|
|
70
|
+
for raw_line in lines:
|
|
71
|
+
line = raw_line.rstrip("\r")
|
|
72
|
+
if not line:
|
|
73
|
+
if data_lines:
|
|
74
|
+
payload = json.loads("\n".join(data_lines))
|
|
75
|
+
payload.setdefault("type", event_type)
|
|
76
|
+
yield payload
|
|
77
|
+
event_type = "message"
|
|
78
|
+
data_lines = []
|
|
79
|
+
continue
|
|
80
|
+
|
|
81
|
+
if line.startswith(":"):
|
|
82
|
+
continue
|
|
83
|
+
if line.startswith("event:"):
|
|
84
|
+
event_type = line.split(":", 1)[1].strip()
|
|
85
|
+
continue
|
|
86
|
+
if line.startswith("data:"):
|
|
87
|
+
data_lines.append(line.split(":", 1)[1].strip())
|
|
88
|
+
|
|
89
|
+
if data_lines:
|
|
90
|
+
payload = json.loads("\n".join(data_lines))
|
|
91
|
+
payload.setdefault("type", event_type)
|
|
92
|
+
yield payload
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class NinethClient:
|
|
96
|
+
"""Synchronous client for the Nineth API."""
|
|
97
|
+
|
|
98
|
+
def __init__(
|
|
99
|
+
self,
|
|
100
|
+
base_url: Optional[str] = None,
|
|
101
|
+
api_key: Optional[str] = None,
|
|
102
|
+
*,
|
|
103
|
+
timeout: float = DEFAULT_TIMEOUT,
|
|
104
|
+
headers: Optional[Dict[str, str]] = None,
|
|
105
|
+
):
|
|
106
|
+
resolved_base_url = (base_url or os.getenv("ROOSTER_BASE_URL") or DEFAULT_BASE_URL).rstrip("/")
|
|
107
|
+
if not resolved_base_url:
|
|
108
|
+
raise ValueError("A base_url or ROOSTER_BASE_URL environment variable is required.")
|
|
109
|
+
|
|
110
|
+
resolved_api_key = api_key or os.getenv("ROOSTER_API_KEY")
|
|
111
|
+
request_headers = dict(headers or {})
|
|
112
|
+
if resolved_api_key:
|
|
113
|
+
request_headers.setdefault(API_KEY_HEADER, resolved_api_key)
|
|
114
|
+
|
|
115
|
+
self.base_url = resolved_base_url
|
|
116
|
+
self.api_key = resolved_api_key
|
|
117
|
+
self._client = httpx.Client(
|
|
118
|
+
base_url=self.base_url,
|
|
119
|
+
timeout=timeout,
|
|
120
|
+
headers=request_headers or None,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
def _ensure_api_key(self) -> None:
|
|
124
|
+
if not self.api_key and API_KEY_HEADER not in self._client.headers:
|
|
125
|
+
raise ValueError("An api_key or ROOSTER_API_KEY environment variable is required.")
|
|
126
|
+
|
|
127
|
+
def close(self) -> None:
|
|
128
|
+
self._client.close()
|
|
129
|
+
|
|
130
|
+
def __enter__(self) -> "NinethClient":
|
|
131
|
+
return self
|
|
132
|
+
|
|
133
|
+
def __exit__(self, exc_type, exc, tb) -> None:
|
|
134
|
+
self.close()
|
|
135
|
+
|
|
136
|
+
def health(self) -> Dict[str, Any]:
|
|
137
|
+
response = self._client.get("/health")
|
|
138
|
+
_raise_for_status(response)
|
|
139
|
+
return response.json()
|
|
140
|
+
|
|
141
|
+
def invoke(self, task_input: str, **kwargs: Any) -> Dict[str, Any]:
|
|
142
|
+
self._ensure_api_key()
|
|
143
|
+
payload = build_payload(task_input, **kwargs)
|
|
144
|
+
response = self._client.post("/agent", json=payload)
|
|
145
|
+
_raise_for_status(response)
|
|
146
|
+
return response.json()
|
|
147
|
+
|
|
148
|
+
def stream(self, task_input: str, **kwargs: Any) -> Iterator[Dict[str, Any]]:
|
|
149
|
+
self._ensure_api_key()
|
|
150
|
+
payload = build_payload(task_input, **kwargs)
|
|
151
|
+
with self._client.stream("POST", "/agent/stream", json=payload) as response:
|
|
152
|
+
_raise_for_status(response)
|
|
153
|
+
yield from _parse_sse_lines(response.iter_lines())
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
class AsyncNinethClient:
|
|
157
|
+
"""Asynchronous client for the Nineth API."""
|
|
158
|
+
|
|
159
|
+
def __init__(
|
|
160
|
+
self,
|
|
161
|
+
base_url: Optional[str] = None,
|
|
162
|
+
api_key: Optional[str] = None,
|
|
163
|
+
*,
|
|
164
|
+
timeout: float = DEFAULT_TIMEOUT,
|
|
165
|
+
headers: Optional[Dict[str, str]] = None,
|
|
166
|
+
):
|
|
167
|
+
resolved_base_url = (base_url or os.getenv("ROOSTER_BASE_URL") or DEFAULT_BASE_URL).rstrip("/")
|
|
168
|
+
if not resolved_base_url:
|
|
169
|
+
raise ValueError("A base_url or ROOSTER_BASE_URL environment variable is required.")
|
|
170
|
+
|
|
171
|
+
resolved_api_key = api_key or os.getenv("ROOSTER_API_KEY")
|
|
172
|
+
request_headers = dict(headers or {})
|
|
173
|
+
if resolved_api_key:
|
|
174
|
+
request_headers.setdefault(API_KEY_HEADER, resolved_api_key)
|
|
175
|
+
|
|
176
|
+
self.base_url = resolved_base_url
|
|
177
|
+
self.api_key = resolved_api_key
|
|
178
|
+
self._client = httpx.AsyncClient(
|
|
179
|
+
base_url=self.base_url,
|
|
180
|
+
timeout=timeout,
|
|
181
|
+
headers=request_headers or None,
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
def _ensure_api_key(self) -> None:
|
|
185
|
+
if not self.api_key and API_KEY_HEADER not in self._client.headers:
|
|
186
|
+
raise ValueError("An api_key or ROOSTER_API_KEY environment variable is required.")
|
|
187
|
+
|
|
188
|
+
async def aclose(self) -> None:
|
|
189
|
+
await self._client.aclose()
|
|
190
|
+
|
|
191
|
+
async def __aenter__(self) -> "AsyncNinethClient":
|
|
192
|
+
return self
|
|
193
|
+
|
|
194
|
+
async def __aexit__(self, exc_type, exc, tb) -> None:
|
|
195
|
+
await self.aclose()
|
|
196
|
+
|
|
197
|
+
async def health(self) -> Dict[str, Any]:
|
|
198
|
+
response = await self._client.get("/health")
|
|
199
|
+
_raise_for_status(response)
|
|
200
|
+
return response.json()
|
|
201
|
+
|
|
202
|
+
async def invoke(self, task_input: str, **kwargs: Any) -> Dict[str, Any]:
|
|
203
|
+
self._ensure_api_key()
|
|
204
|
+
payload = build_payload(task_input, **kwargs)
|
|
205
|
+
response = await self._client.post("/agent", json=payload)
|
|
206
|
+
_raise_for_status(response)
|
|
207
|
+
return response.json()
|
|
208
|
+
|
|
209
|
+
async def stream(self, task_input: str, **kwargs: Any) -> AsyncIterator[Dict[str, Any]]:
|
|
210
|
+
self._ensure_api_key()
|
|
211
|
+
payload = build_payload(task_input, **kwargs)
|
|
212
|
+
async with self._client.stream("POST", "/agent/stream", json=payload) as response:
|
|
213
|
+
_raise_for_status(response)
|
|
214
|
+
event_type = "message"
|
|
215
|
+
data_lines: list[str] = []
|
|
216
|
+
|
|
217
|
+
async for raw_line in response.aiter_lines():
|
|
218
|
+
line = raw_line.rstrip("\r")
|
|
219
|
+
if not line:
|
|
220
|
+
if data_lines:
|
|
221
|
+
payload = json.loads("\n".join(data_lines))
|
|
222
|
+
payload.setdefault("type", event_type)
|
|
223
|
+
yield payload
|
|
224
|
+
event_type = "message"
|
|
225
|
+
data_lines = []
|
|
226
|
+
continue
|
|
227
|
+
|
|
228
|
+
if line.startswith(":"):
|
|
229
|
+
continue
|
|
230
|
+
if line.startswith("event:"):
|
|
231
|
+
event_type = line.split(":", 1)[1].strip()
|
|
232
|
+
continue
|
|
233
|
+
if line.startswith("data:"):
|
|
234
|
+
data_lines.append(line.split(":", 1)[1].strip())
|
|
235
|
+
|
|
236
|
+
if data_lines:
|
|
237
|
+
payload = json.loads("\n".join(data_lines))
|
|
238
|
+
payload.setdefault("type", event_type)
|
|
239
|
+
yield payload
|