osmosis-ai 0.2.1__py3-none-any.whl → 0.2.3__py3-none-any.whl
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.
Potentially problematic release.
This version of osmosis-ai might be problematic. Click here for more details.
- osmosis_ai/__init__.py +13 -4
- osmosis_ai/cli.py +50 -0
- osmosis_ai/cli_commands.py +181 -0
- osmosis_ai/cli_services/__init__.py +67 -0
- osmosis_ai/cli_services/config.py +407 -0
- osmosis_ai/cli_services/dataset.py +229 -0
- osmosis_ai/cli_services/engine.py +251 -0
- osmosis_ai/cli_services/errors.py +7 -0
- osmosis_ai/cli_services/reporting.py +307 -0
- osmosis_ai/cli_services/session.py +174 -0
- osmosis_ai/cli_services/shared.py +209 -0
- osmosis_ai/consts.py +1 -1
- osmosis_ai/providers/__init__.py +36 -0
- osmosis_ai/providers/anthropic_provider.py +85 -0
- osmosis_ai/providers/base.py +60 -0
- osmosis_ai/providers/gemini_provider.py +314 -0
- osmosis_ai/providers/openai_family.py +607 -0
- osmosis_ai/providers/shared.py +92 -0
- osmosis_ai/rubric_eval.py +498 -0
- osmosis_ai/rubric_types.py +49 -0
- osmosis_ai/utils.py +392 -5
- osmosis_ai-0.2.3.dist-info/METADATA +303 -0
- osmosis_ai-0.2.3.dist-info/RECORD +27 -0
- osmosis_ai-0.2.3.dist-info/entry_points.txt +4 -0
- osmosis_ai-0.2.1.dist-info/METADATA +0 -143
- osmosis_ai-0.2.1.dist-info/RECORD +0 -8
- {osmosis_ai-0.2.1.dist-info → osmosis_ai-0.2.3.dist-info}/WHEEL +0 -0
- {osmosis_ai-0.2.1.dist-info → osmosis_ai-0.2.3.dist-info}/licenses/LICENSE +0 -0
- {osmosis_ai-0.2.1.dist-info → osmosis_ai-0.2.3.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: osmosis-ai
|
|
3
|
+
Version: 0.2.3
|
|
4
|
+
Summary: A Python library for reward function validation with strict type enforcement.
|
|
5
|
+
Author-email: Osmosis AI <jake@osmosis.ai>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2025 Gulp AI
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
Project-URL: Homepage, https://github.com/Osmosis-AI/osmosis-sdk-python
|
|
28
|
+
Project-URL: Issues, https://github.com/Osmosis-AI/osmosis-sdk-python/issues
|
|
29
|
+
Classifier: Programming Language :: Python :: 3
|
|
30
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
31
|
+
Classifier: Operating System :: OS Independent
|
|
32
|
+
Requires-Python: >=3.9
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
License-File: LICENSE
|
|
35
|
+
Requires-Dist: PyYAML<7.0,>=6.0
|
|
36
|
+
Requires-Dist: python-dotenv<2.0.0,>=0.1.0
|
|
37
|
+
Requires-Dist: requests<3.0.0,>=2.0.0
|
|
38
|
+
Requires-Dist: xxhash<4.0.0,>=3.0.0
|
|
39
|
+
Requires-Dist: anthropic<0.50.0,>=0.36.0
|
|
40
|
+
Requires-Dist: openai>=2.0.0
|
|
41
|
+
Requires-Dist: google-genai>=1.0.0
|
|
42
|
+
Requires-Dist: xai-sdk>=1.2.0
|
|
43
|
+
Requires-Dist: tqdm<5.0.0,>=4.0.0
|
|
44
|
+
Dynamic: license-file
|
|
45
|
+
|
|
46
|
+
# osmosis-ai
|
|
47
|
+
|
|
48
|
+
A Python library that provides reward and rubric validation helpers for LLM applications with strict type enforcement.
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install osmosis-ai
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Requires Python 3.9 or newer.
|
|
57
|
+
|
|
58
|
+
This installs the Osmosis CLI and pulls in the required provider SDKs (`openai`, `anthropic`, `google-genai`, `xai-sdk`) along with supporting utilities such as `PyYAML`, `python-dotenv`, `requests`, and `xxhash`.
|
|
59
|
+
|
|
60
|
+
For development:
|
|
61
|
+
```bash
|
|
62
|
+
git clone https://github.com/Osmosis-AI/osmosis-sdk-python
|
|
63
|
+
cd osmosis-sdk-python
|
|
64
|
+
pip install -e .
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Quick Start
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from osmosis_ai import osmosis_reward
|
|
71
|
+
|
|
72
|
+
@osmosis_reward
|
|
73
|
+
def simple_reward(solution_str: str, ground_truth: str, extra_info: dict = None) -> float:
|
|
74
|
+
"""Basic exact match reward function."""
|
|
75
|
+
return 1.0 if solution_str.strip() == ground_truth.strip() else 0.0
|
|
76
|
+
|
|
77
|
+
# Use the reward function
|
|
78
|
+
score = simple_reward("hello world", "hello world") # Returns 1.0
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from osmosis_ai import evaluate_rubric
|
|
83
|
+
|
|
84
|
+
messages = [
|
|
85
|
+
{
|
|
86
|
+
"type": "message",
|
|
87
|
+
"role": "user",
|
|
88
|
+
"content": [{"type": "input_text", "text": "What is the capital of France?"}],
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"type": "message",
|
|
92
|
+
"role": "assistant",
|
|
93
|
+
"content": [{"type": "output_text", "text": "The capital of France is Paris."}],
|
|
94
|
+
},
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
# Export OPENAI_API_KEY in your shell before running this snippet.
|
|
98
|
+
rubric_score = evaluate_rubric(
|
|
99
|
+
rubric="Assistant must mention the verified capital city.",
|
|
100
|
+
messages=messages,
|
|
101
|
+
model_info={
|
|
102
|
+
"provider": "openai",
|
|
103
|
+
"model": "gpt-5",
|
|
104
|
+
"api_key_env": "OPENAI_API_KEY",
|
|
105
|
+
},
|
|
106
|
+
ground_truth="Paris",
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
print(rubric_score) # -> 1.0 (full payload available via return_details=True)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Remote Rubric Evaluation
|
|
113
|
+
|
|
114
|
+
`evaluate_rubric` talks to each provider through its official Python SDK while enforcing the same JSON schema everywhere:
|
|
115
|
+
|
|
116
|
+
- **OpenAI / xAI** – Uses `OpenAI(...).responses.create` (or `chat.completions.create`) with `response_format={"type": "json_schema"}` and falls back to `json_object` when needed.
|
|
117
|
+
- **Anthropic** – Forces a tool call with a JSON schema via `Anthropic(...).messages.create`, extracting the returned tool arguments.
|
|
118
|
+
- **Google Gemini** – Invokes `google.genai.Client(...).models.generate_content` with `response_mime_type="application/json"` and `response_schema`.
|
|
119
|
+
|
|
120
|
+
Every provider therefore returns a strict JSON object with `{"score": number, "explanation": string}`. The helper clamps the score into your configured range, validates the structure, and exposes the raw payload when `return_details=True`.
|
|
121
|
+
|
|
122
|
+
Credentials are resolved from environment variables by default:
|
|
123
|
+
|
|
124
|
+
- `OPENAI_API_KEY` for OpenAI
|
|
125
|
+
- `ANTHROPIC_API_KEY` for Anthropic
|
|
126
|
+
- `GOOGLE_API_KEY` for Google Gemini
|
|
127
|
+
- `XAI_API_KEY` for xAI
|
|
128
|
+
|
|
129
|
+
Override the environment variable name with `model_info={"api_key_env": "CUSTOM_ENV_NAME"}` when needed, or supply an inline secret with `model_info={"api_key": "sk-..."}` for ephemeral credentials. Missing API keys raise a `MissingAPIKeyError` that explains how to export the secret before trying again.
|
|
130
|
+
|
|
131
|
+
`model_info` accepts additional rubric-specific knobs:
|
|
132
|
+
|
|
133
|
+
- `score_min` / `score_max` – change the default `[0.0, 1.0]` scoring bounds.
|
|
134
|
+
- `system_prompt` / `original_input` – override the helper’s transcript inference when those entries are absent.
|
|
135
|
+
- `timeout` – customise the provider timeout in seconds.
|
|
136
|
+
|
|
137
|
+
Pass `extra_info={...}` to `evaluate_rubric` when you need structured context quoted in the judge prompt, and set `return_details=True` to receive the full `RewardRubricRunResult` payload (including the provider’s raw response).
|
|
138
|
+
|
|
139
|
+
Remote failures surface as `ProviderRequestError` instances, with `ModelNotFoundError` reserved for missing model identifiers so you can retry with a new snapshot.
|
|
140
|
+
|
|
141
|
+
> Older SDK versions that lack schema parameters automatically fall back to instruction-only JSON; the helper still validates the response payload before returning.
|
|
142
|
+
> Provider model snapshot names change frequently. Check each vendor's dashboard for the latest identifier if you encounter a “model not found” error.
|
|
143
|
+
|
|
144
|
+
### Provider Architecture
|
|
145
|
+
|
|
146
|
+
All remote integrations live in `osmosis_ai/providers/` and implement the `RubricProvider` interface. At import time the default registry registers OpenAI, xAI, Anthropic, and Google Gemini so `evaluate_rubric` can route requests without additional configuration. The request/response plumbing is encapsulated in each provider module, keeping `evaluate_rubric` focused on prompt construction, payload validation, and credential resolution.
|
|
147
|
+
|
|
148
|
+
Add your own provider by subclassing `RubricProvider`, implementing `run()` with the vendor SDK, and calling `register_provider()` during start-up. A step-by-step guide is available in [`osmosis_ai/providers/README.md`](osmosis_ai/providers/README.md).
|
|
149
|
+
|
|
150
|
+
## Required Function Signature
|
|
151
|
+
|
|
152
|
+
All functions decorated with `@osmosis_reward` must have exactly this signature:
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
@osmosis_reward
|
|
156
|
+
def your_function(solution_str: str, ground_truth: str, extra_info: dict = None) -> float:
|
|
157
|
+
# Your reward logic here
|
|
158
|
+
return float_score
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Parameters
|
|
162
|
+
|
|
163
|
+
- **`solution_str: str`** - The solution string to evaluate (required)
|
|
164
|
+
- **`ground_truth: str`** - The correct/expected answer (required)
|
|
165
|
+
- **`extra_info: dict = None`** - Optional dictionary for additional configuration
|
|
166
|
+
|
|
167
|
+
### Return Value
|
|
168
|
+
|
|
169
|
+
- **`-> float`** - Must return a float value representing the reward score
|
|
170
|
+
|
|
171
|
+
The decorator will raise a `TypeError` if the function doesn't match this exact signature or doesn't return a float.
|
|
172
|
+
|
|
173
|
+
## Rubric Function Signature
|
|
174
|
+
|
|
175
|
+
Rubric functions decorated with `@osmosis_rubric` must accept the parameters:
|
|
176
|
+
|
|
177
|
+
- `model_info: dict`
|
|
178
|
+
- `rubric: str`
|
|
179
|
+
- `messages: list`
|
|
180
|
+
- `ground_truth: Optional[str] = None`
|
|
181
|
+
- `system_message: Optional[str] = None`
|
|
182
|
+
- `extra_info: dict = None`
|
|
183
|
+
- `score_min: float = 0.0` *(optional lower bound; must default to 0.0 and stay below `score_max`)*
|
|
184
|
+
- `score_max: float = 1.0` *(optional upper bound; must default to 1.0 and stay above `score_min`)*
|
|
185
|
+
|
|
186
|
+
and must return a `float`. The decorator validates the signature and runtime payload (including message role validation and return type) before delegating to your custom logic.
|
|
187
|
+
|
|
188
|
+
> Required fields: `model_info` must contain non-empty `provider` and `model` string entries.
|
|
189
|
+
|
|
190
|
+
> Annotation quirk: `extra_info` must be annotated as a plain `dict` with a default of `None` to satisfy the validator.
|
|
191
|
+
|
|
192
|
+
> Tip: You can call `evaluate_rubric` from inside a rubric function (or any other orchestrator) to outsource judging to a hosted model while still benefiting from the decorator’s validation.
|
|
193
|
+
|
|
194
|
+
## Examples
|
|
195
|
+
|
|
196
|
+
See the [`examples/`](examples/) directory for complete examples:
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
@osmosis_reward
|
|
200
|
+
def case_insensitive_match(solution_str: str, ground_truth: str, extra_info: dict = None) -> float:
|
|
201
|
+
"""Case-insensitive string matching with partial credit."""
|
|
202
|
+
match = solution_str.lower().strip() == ground_truth.lower().strip()
|
|
203
|
+
|
|
204
|
+
if extra_info and 'partial_credit' in extra_info:
|
|
205
|
+
if not match and extra_info['partial_credit']:
|
|
206
|
+
len_diff = abs(len(solution_str) - len(ground_truth))
|
|
207
|
+
if len_diff <= 2:
|
|
208
|
+
return 0.5
|
|
209
|
+
|
|
210
|
+
return 1.0 if match else 0.0
|
|
211
|
+
|
|
212
|
+
@osmosis_reward
|
|
213
|
+
def numeric_tolerance(solution_str: str, ground_truth: str, extra_info: dict = None) -> float:
|
|
214
|
+
"""Numeric comparison with configurable tolerance."""
|
|
215
|
+
try:
|
|
216
|
+
solution_num = float(solution_str.strip())
|
|
217
|
+
truth_num = float(ground_truth.strip())
|
|
218
|
+
|
|
219
|
+
tolerance = extra_info.get('tolerance', 0.01) if extra_info else 0.01
|
|
220
|
+
return 1.0 if abs(solution_num - truth_num) <= tolerance else 0.0
|
|
221
|
+
except ValueError:
|
|
222
|
+
return 0.0
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
- `examples/rubric_functions.py` demonstrates `evaluate_rubric` with OpenAI, Anthropic, Gemini, and xAI using the schema-enforced SDK integrations.
|
|
226
|
+
- `examples/reward_functions.py` keeps local reward helpers that showcase the decorator contract without external calls.
|
|
227
|
+
- `examples/rubric_configs.yaml` bundles two rubric definitions, each with its own provider configuration and extra prompt context.
|
|
228
|
+
- `examples/sample_data.jsonl` contains two conversation payloads mapped to those rubrics so you can trial dataset validation.
|
|
229
|
+
|
|
230
|
+
```yaml
|
|
231
|
+
# examples/rubric_configs.yaml (excerpt)
|
|
232
|
+
version: 1
|
|
233
|
+
rubrics:
|
|
234
|
+
- id: support_followup
|
|
235
|
+
model_info:
|
|
236
|
+
provider: openai
|
|
237
|
+
model: gpt-5-mini
|
|
238
|
+
api_key_env: OPENAI_API_KEY
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
```jsonl
|
|
242
|
+
{"conversation_id": "ticket-001", "rubric_id": "support_followup", "...": "..."}
|
|
243
|
+
{"conversation_id": "ticket-047", "rubric_id": "policy_grounding", "...": "..."}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## CLI Tools
|
|
247
|
+
|
|
248
|
+
Installing the SDK also provides a lightweight CLI available as `osmosis` (aliases: `osmosis_ai`, `osmosis-ai`) for inspecting rubric YAML files and JSONL test payloads.
|
|
249
|
+
|
|
250
|
+
Preview a rubric file and print every configuration discovered, including nested entries:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
osmosis preview --path path/to/rubric.yaml
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Preview a dataset of chat transcripts stored as JSONL:
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
osmosis preview --path path/to/data.jsonl
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Evaluate a dataset against a hosted rubric configuration and print the returned scores:
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
osmosis eval --rubric support_followup --data examples/sample_data.jsonl
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
- Supply the dataset with `-d`/`--data path/to/data.jsonl`; the path is resolved relative to the current working directory.
|
|
269
|
+
- Use `--config path/to/rubric_configs.yaml` when the rubric definitions are not located alongside the dataset.
|
|
270
|
+
- Pass `-n`/`--number` to sample the provider multiple times per record; the CLI prints every run along with aggregate statistics (average, variance, standard deviation, and min/max).
|
|
271
|
+
- Provide `--output path/to/dir` to create the directory (if needed) and emit `rubric_eval_result_<unix_timestamp>.json`, or supply a full file path (any extension) to control the filename; each file captures every run, provider payloads, timestamps, and aggregate statistics for downstream analysis.
|
|
272
|
+
- Skip `--output` to collect results under `~/.cache/osmosis/eval_result/<rubric_id>/rubric_eval_result_<identifier>.json`; the CLI writes this JSON whether the evaluation finishes cleanly or hits provider/runtime errors so you can inspect failures later (only a manual Ctrl+C interrupt leaves no file behind).
|
|
273
|
+
- Dataset rows whose `rubric_id` does not match the requested rubric are skipped automatically.
|
|
274
|
+
|
|
275
|
+
Both commands validate the file, echo a short summary (`Loaded <n> ...`), and pretty-print the parsed records so you can confirm that new rubrics or test fixtures look correct before committing them. Invalid files raise a descriptive error and exit with a non-zero status code.
|
|
276
|
+
|
|
277
|
+
## Running Examples
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
PYTHONPATH=. python examples/reward_functions.py
|
|
281
|
+
PYTHONPATH=. python examples/rubric_functions.py # Uncomment the provider you need before running
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
## Testing
|
|
285
|
+
|
|
286
|
+
Run `python -m pytest tests/test_rubric_eval.py` to exercise the guards that ensure rubric prompts ignore message metadata (for example `tests/test_rubric_eval.py::test_collect_text_skips_metadata_fields`) while still preserving nested tool output. Add additional tests under `tests/` as you extend the library.
|
|
287
|
+
|
|
288
|
+
## License
|
|
289
|
+
|
|
290
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
291
|
+
|
|
292
|
+
## Contributing
|
|
293
|
+
|
|
294
|
+
1. Fork the repository
|
|
295
|
+
2. Create a feature branch
|
|
296
|
+
3. Make your changes
|
|
297
|
+
4. Run tests and examples
|
|
298
|
+
5. Submit a pull request
|
|
299
|
+
|
|
300
|
+
## Links
|
|
301
|
+
|
|
302
|
+
- [Homepage](https://github.com/Osmosis-AI/osmosis-sdk-python)
|
|
303
|
+
- [Issues](https://github.com/Osmosis-AI/osmosis-sdk-python/issues)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
osmosis_ai/__init__.py,sha256=2_qXxu18Yc7UicqxFZds8PjR4q0mTY1Xt17iR38OFbw,725
|
|
2
|
+
osmosis_ai/cli.py,sha256=EPCttBnj1TEqQuO2gmS9iHadYcudiizVM38jACztRFE,1320
|
|
3
|
+
osmosis_ai/cli_commands.py,sha256=CmTcb5N3delW7z3fwucss89xw5MHgIrJJ2Z5xdAuIeU,6165
|
|
4
|
+
osmosis_ai/consts.py,sha256=-NDo9FaqBTebkCnhiFDxne6BY0W7BL3oM8HnGQDDgSE,73
|
|
5
|
+
osmosis_ai/rubric_eval.py,sha256=PE2MvJygMbxelsJSTRzlW0bf-YUrtc8lCh6iTpHkjnU,17029
|
|
6
|
+
osmosis_ai/rubric_types.py,sha256=kJvNAjLd3Y-1Q-_Re9HLTprLAUO3qtwR-IWOBeMkFI8,1279
|
|
7
|
+
osmosis_ai/utils.py,sha256=IfTicRfa2Ybut4OzV4pHGSLBv-sGcmdT4eKIrIq4Pj8,19758
|
|
8
|
+
osmosis_ai/cli_services/__init__.py,sha256=QQBwlI4KXoXK1X_e7kwW5sAVSh1VqBVuPllCwUOGXDM,1534
|
|
9
|
+
osmosis_ai/cli_services/config.py,sha256=5hW2taAMhO9BkOfXvUCclnKLKtGTPaytS0oAgxCqymY,13965
|
|
10
|
+
osmosis_ai/cli_services/dataset.py,sha256=qA0WHuOlJZCZdDbFX7ltimaZ3ujZpVUah4pxMvd4lVk,9042
|
|
11
|
+
osmosis_ai/cli_services/engine.py,sha256=DbdJ24e5njk_lihe00cUgLO7yyJ6YgekFy6MAg_uq0k,9157
|
|
12
|
+
osmosis_ai/cli_services/errors.py,sha256=nI6jlICyA4MMNKmwDHQBwyJVah5PVwstmra1HpGkVLE,136
|
|
13
|
+
osmosis_ai/cli_services/reporting.py,sha256=H2g0BmEE2stVey4RmurQM713VowH8984a9r7oDstSkA,12499
|
|
14
|
+
osmosis_ai/cli_services/session.py,sha256=Ru3HA80eqRYZGD1e38N8yd96FiAY8cIYpJvEOHKakM0,6597
|
|
15
|
+
osmosis_ai/cli_services/shared.py,sha256=PilPfW5oDvNL5VG8oObSq2ZL35QPFmhBDf0V4gfd2Ro,5942
|
|
16
|
+
osmosis_ai/providers/__init__.py,sha256=yLSExLbJToZ8AUOVxt4LDplxtIuwv-etSJJyZOcOE2Q,927
|
|
17
|
+
osmosis_ai/providers/anthropic_provider.py,sha256=zrWCVP8co4v8xhcJDFLASwvwEADKN-1p34cY_GH4q5M,3758
|
|
18
|
+
osmosis_ai/providers/base.py,sha256=fN5cnWXYAHN53RR_x6ykbUkM4bictNPDj4U8yd4b2a0,1492
|
|
19
|
+
osmosis_ai/providers/gemini_provider.py,sha256=QANSCmkKungpkpDP2RClmKYnwNVrGv3MKxJwkh68IhY,12045
|
|
20
|
+
osmosis_ai/providers/openai_family.py,sha256=DeQWPMcafEvG4xcI97m3AADTKP2pYw9KwcQTcQg-h_4,26078
|
|
21
|
+
osmosis_ai/providers/shared.py,sha256=dmVe8JDgafPmo6HkP-Kl0aWfffhAT6u3ElV_wLlYD34,2957
|
|
22
|
+
osmosis_ai-0.2.3.dist-info/licenses/LICENSE,sha256=FV2ZmyhdCYinoLLvU_ci-7pZ3DeNYY9XqZjVjOd3h94,1064
|
|
23
|
+
osmosis_ai-0.2.3.dist-info/METADATA,sha256=tgRpinJ60KxX1OlT_9JMCFl2hY0A5I4rZLPRtXQ4p-U,13669
|
|
24
|
+
osmosis_ai-0.2.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
25
|
+
osmosis_ai-0.2.3.dist-info/entry_points.txt,sha256=aF1CR36a9I9_vcF7nlK9JnK1Iqu614vPy2_jh4QU26A,114
|
|
26
|
+
osmosis_ai-0.2.3.dist-info/top_level.txt,sha256=UPNRTKIBSrxsJVNxwXnLCqSoBS4bAiL_3jMtjvf5zEY,11
|
|
27
|
+
osmosis_ai-0.2.3.dist-info/RECORD,,
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: osmosis-ai
|
|
3
|
-
Version: 0.2.1
|
|
4
|
-
Summary: A Python library for reward function validation with strict type enforcement.
|
|
5
|
-
Author-email: Osmosis AI <jake@osmosis.ai>
|
|
6
|
-
License: MIT License
|
|
7
|
-
|
|
8
|
-
Copyright (c) 2025 Gulp AI
|
|
9
|
-
|
|
10
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
-
in the Software without restriction, including without limitation the rights
|
|
13
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
-
furnished to do so, subject to the following conditions:
|
|
16
|
-
|
|
17
|
-
The above copyright notice and this permission notice shall be included in all
|
|
18
|
-
copies or substantial portions of the Software.
|
|
19
|
-
|
|
20
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
-
SOFTWARE.
|
|
27
|
-
Project-URL: Homepage, https://github.com/Osmosis-AI/osmosis-sdk-python
|
|
28
|
-
Project-URL: Issues, https://github.com/Osmosis-AI/osmosis-sdk-python/issues
|
|
29
|
-
Classifier: Programming Language :: Python :: 3
|
|
30
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
31
|
-
Classifier: Operating System :: OS Independent
|
|
32
|
-
Requires-Python: >=3.6
|
|
33
|
-
Description-Content-Type: text/markdown
|
|
34
|
-
License-File: LICENSE
|
|
35
|
-
Dynamic: license-file
|
|
36
|
-
|
|
37
|
-
# osmosis-ai
|
|
38
|
-
|
|
39
|
-
A Python library that provides reward functionality for LLM applications with strict type enforcement.
|
|
40
|
-
|
|
41
|
-
## Installation
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
pip install osmosis-ai
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
For development:
|
|
48
|
-
```bash
|
|
49
|
-
git clone https://github.com/Osmosis-AI/osmosis-sdk-python
|
|
50
|
-
cd osmosis-sdk-python
|
|
51
|
-
pip install -e .
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Quick Start
|
|
55
|
-
|
|
56
|
-
```python
|
|
57
|
-
from osmosis_ai import osmosis_reward
|
|
58
|
-
|
|
59
|
-
@osmosis_reward
|
|
60
|
-
def simple_reward(solution_str: str, ground_truth: str, extra_info: dict = None) -> float:
|
|
61
|
-
"""Basic exact match reward function."""
|
|
62
|
-
return 1.0 if solution_str.strip() == ground_truth.strip() else 0.0
|
|
63
|
-
|
|
64
|
-
# Use the reward function
|
|
65
|
-
score = simple_reward("hello world", "hello world") # Returns 1.0
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Required Function Signature
|
|
69
|
-
|
|
70
|
-
All functions decorated with `@osmosis_reward` must have exactly this signature:
|
|
71
|
-
|
|
72
|
-
```python
|
|
73
|
-
@osmosis_reward
|
|
74
|
-
def your_function(solution_str: str, ground_truth: str, extra_info: dict = None) -> float:
|
|
75
|
-
# Your reward logic here
|
|
76
|
-
return float_score
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### Parameters
|
|
80
|
-
|
|
81
|
-
- **`solution_str: str`** - The solution string to evaluate (required)
|
|
82
|
-
- **`ground_truth: str`** - The correct/expected answer (required)
|
|
83
|
-
- **`extra_info: dict = None`** - Optional dictionary for additional configuration
|
|
84
|
-
|
|
85
|
-
### Return Value
|
|
86
|
-
|
|
87
|
-
- **`-> float`** - Must return a float value representing the reward score
|
|
88
|
-
|
|
89
|
-
The decorator will raise a `TypeError` if the function doesn't match this exact signature or doesn't return a float.
|
|
90
|
-
|
|
91
|
-
## Examples
|
|
92
|
-
|
|
93
|
-
See the [`examples/`](examples/) directory for complete examples:
|
|
94
|
-
|
|
95
|
-
```python
|
|
96
|
-
@osmosis_reward
|
|
97
|
-
def case_insensitive_match(solution_str: str, ground_truth: str, extra_info: dict = None) -> float:
|
|
98
|
-
"""Case-insensitive string matching with partial credit."""
|
|
99
|
-
match = solution_str.lower().strip() == ground_truth.lower().strip()
|
|
100
|
-
|
|
101
|
-
if extra_info and 'partial_credit' in extra_info:
|
|
102
|
-
if not match and extra_info['partial_credit']:
|
|
103
|
-
len_diff = abs(len(solution_str) - len(ground_truth))
|
|
104
|
-
if len_diff <= 2:
|
|
105
|
-
return 0.5
|
|
106
|
-
|
|
107
|
-
return 1.0 if match else 0.0
|
|
108
|
-
|
|
109
|
-
@osmosis_reward
|
|
110
|
-
def numeric_tolerance(solution_str: str, ground_truth: str, extra_info: dict = None) -> float:
|
|
111
|
-
"""Numeric comparison with configurable tolerance."""
|
|
112
|
-
try:
|
|
113
|
-
solution_num = float(solution_str.strip())
|
|
114
|
-
truth_num = float(ground_truth.strip())
|
|
115
|
-
|
|
116
|
-
tolerance = extra_info.get('tolerance', 0.01) if extra_info else 0.01
|
|
117
|
-
return 1.0 if abs(solution_num - truth_num) <= tolerance else 0.0
|
|
118
|
-
except ValueError:
|
|
119
|
-
return 0.0
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
## Running Examples
|
|
123
|
-
|
|
124
|
-
```bash
|
|
125
|
-
python examples/reward_functions.py
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
## License
|
|
129
|
-
|
|
130
|
-
MIT License - see [LICENSE](LICENSE) file for details.
|
|
131
|
-
|
|
132
|
-
## Contributing
|
|
133
|
-
|
|
134
|
-
1. Fork the repository
|
|
135
|
-
2. Create a feature branch
|
|
136
|
-
3. Make your changes
|
|
137
|
-
4. Run tests and examples
|
|
138
|
-
5. Submit a pull request
|
|
139
|
-
|
|
140
|
-
## Links
|
|
141
|
-
|
|
142
|
-
- [Homepage](https://github.com/Osmosis-AI/osmosis-sdk-python)
|
|
143
|
-
- [Issues](https://github.com/Osmosis-AI/osmosis-sdk-python/issues)
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
osmosis_ai/__init__.py,sha256=P1w65jE23XhFLW6BEOaiMat-EoANgKwSYBIQFPCS3Xc,445
|
|
2
|
-
osmosis_ai/consts.py,sha256=qnleJ6zIbS-AqX-pviqiNI5KV5w7dlmghvhbl75y048,73
|
|
3
|
-
osmosis_ai/utils.py,sha256=1UmSC2HXRhryoHJ5c016VitHsRH38XRsXhacv2kGLPM,2505
|
|
4
|
-
osmosis_ai-0.2.1.dist-info/licenses/LICENSE,sha256=FV2ZmyhdCYinoLLvU_ci-7pZ3DeNYY9XqZjVjOd3h94,1064
|
|
5
|
-
osmosis_ai-0.2.1.dist-info/METADATA,sha256=JDg33fTpMwdiTilgoswWF9nvCQiqvQsNWIYT_eL9omY,4753
|
|
6
|
-
osmosis_ai-0.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
7
|
-
osmosis_ai-0.2.1.dist-info/top_level.txt,sha256=UPNRTKIBSrxsJVNxwXnLCqSoBS4bAiL_3jMtjvf5zEY,11
|
|
8
|
-
osmosis_ai-0.2.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|