weflayr 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- weflayr-0.1.0/.gitignore +5 -0
- weflayr-0.1.0/LICENSE +91 -0
- weflayr-0.1.0/PKG-INFO +207 -0
- weflayr-0.1.0/README.md +175 -0
- weflayr-0.1.0/coverage/.gitignore +2 -0
- weflayr-0.1.0/coverage/class_index.html +241 -0
- weflayr-0.1.0/coverage/coverage_html_cb_dd2e7eb5.js +735 -0
- weflayr-0.1.0/coverage/favicon_32_cb_c827f16f.png +0 -0
- weflayr-0.1.0/coverage/function_index.html +391 -0
- weflayr-0.1.0/coverage/index.html +171 -0
- weflayr-0.1.0/coverage/keybd_closed_cb_900cfef5.png +0 -0
- weflayr-0.1.0/coverage/status.json +1 -0
- weflayr-0.1.0/coverage/style_cb_9ff733b0.css +389 -0
- weflayr-0.1.0/coverage/z_378eadcd697ff47a___init___py.html +97 -0
- weflayr-0.1.0/coverage/z_378eadcd697ff47a_helpers_py.html +315 -0
- weflayr-0.1.0/coverage/z_4d8a8bce17b09e15___init___py.html +97 -0
- weflayr-0.1.0/coverage/z_a74af646cfc3af57___init___py.html +97 -0
- weflayr-0.1.0/coverage/z_a74af646cfc3af57_client_py.html +260 -0
- weflayr-0.1.0/coverage/z_fac11a80d40dbed6___init___py.html +97 -0
- weflayr-0.1.0/coverage/z_fac11a80d40dbed6_client_py.html +313 -0
- weflayr-0.1.0/docs/index.html +7 -0
- weflayr-0.1.0/docs/search.js +46 -0
- weflayr-0.1.0/docs/weflayr/sdk/helpers.html +610 -0
- weflayr-0.1.0/docs/weflayr/sdk/mistralai/client.html +791 -0
- weflayr-0.1.0/docs/weflayr/sdk/mistralai.html +242 -0
- weflayr-0.1.0/docs/weflayr/sdk.html +243 -0
- weflayr-0.1.0/docs/weflayr.html +237 -0
- weflayr-0.1.0/publish.sh +100 -0
- weflayr-0.1.0/pyproject.toml +69 -0
- weflayr-0.1.0/python/weflayr/__init__.py +0 -0
- weflayr-0.1.0/python/weflayr/sdk/__init__.py +0 -0
- weflayr-0.1.0/python/weflayr/sdk/helpers.py +218 -0
- weflayr-0.1.0/python/weflayr/sdk/mistralai/__init__.py +0 -0
- weflayr-0.1.0/python/weflayr/sdk/mistralai/client.py +163 -0
- weflayr-0.1.0/python/weflayr/sdk/openai/__init__.py +0 -0
- weflayr-0.1.0/python/weflayr/sdk/openai/client.py +216 -0
- weflayr-0.1.0/tests/test_helpers.py +379 -0
- weflayr-0.1.0/tests/test_mistralai_client.py +193 -0
- weflayr-0.1.0/tests/test_openai_client.py +180 -0
- weflayr-0.1.0/uv.lock +1194 -0
weflayr-0.1.0/.gitignore
ADDED
weflayr-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Elastic License 2.0
|
|
2
|
+
|
|
3
|
+
URL: https://www.elastic.co/licensing/elastic-license
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
8
|
+
|
|
9
|
+
## Copyright License
|
|
10
|
+
|
|
11
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
12
|
+
non-sublicensable, non-transferable license to use, copy, distribute, make
|
|
13
|
+
available, and prepare derivative works of the software, in each case subject to
|
|
14
|
+
the limitations and conditions below.
|
|
15
|
+
|
|
16
|
+
## Limitations
|
|
17
|
+
|
|
18
|
+
You may not provide the software to third parties as a hosted or managed
|
|
19
|
+
service, where the service provides users with access to any substantial set of
|
|
20
|
+
the features or functionality of the software.
|
|
21
|
+
|
|
22
|
+
You may not move, change, disable, or circumvent the license key functionality
|
|
23
|
+
in the software, and you may not remove or obscure any functionality in the
|
|
24
|
+
software that is protected by the license key.
|
|
25
|
+
|
|
26
|
+
You may not alter, remove, or obscure any licensing, copyright, or other notices
|
|
27
|
+
of the licensor in the software. Any use of the licensor's trademarks is subject
|
|
28
|
+
to applicable law.
|
|
29
|
+
|
|
30
|
+
## Patents
|
|
31
|
+
|
|
32
|
+
The licensor grants you a license, under any patent claims the licensor can
|
|
33
|
+
license, or becomes able to license, to make, have made, use, sell, offer for
|
|
34
|
+
sale, import and have imported the software, in each case subject to the
|
|
35
|
+
limitations and conditions in this license. This license does not cover any
|
|
36
|
+
patent claims that you cause to be infringed by modifications or additions to
|
|
37
|
+
the software. If you or your company make any written claim that the software
|
|
38
|
+
infringes or contributes to infringement of any patent, your patent license for
|
|
39
|
+
the software granted under these terms ends immediately.
|
|
40
|
+
|
|
41
|
+
## Notices
|
|
42
|
+
|
|
43
|
+
You must ensure that anyone who gets a copy of any part of the software from you
|
|
44
|
+
also gets a copy of these terms.
|
|
45
|
+
|
|
46
|
+
If you modify the software, you must include in any modified copies of the
|
|
47
|
+
software prominent notices stating that you have modified the software.
|
|
48
|
+
|
|
49
|
+
## No Other Rights
|
|
50
|
+
|
|
51
|
+
These terms do not imply any licenses other than those expressly granted in
|
|
52
|
+
these terms.
|
|
53
|
+
|
|
54
|
+
## Termination
|
|
55
|
+
|
|
56
|
+
If you use the software in violation of these terms, such use is not licensed,
|
|
57
|
+
and your licenses will automatically terminate. If the licensor provides you
|
|
58
|
+
with a notice of your violation, and you cease all violation of this license no
|
|
59
|
+
later than 30 days after you receive that notice, your licenses will be
|
|
60
|
+
reinstated retroactively. However, if you violate these terms after such
|
|
61
|
+
reinstatement, any additional violation of these terms will cause your licenses
|
|
62
|
+
to terminate automatically and permanently.
|
|
63
|
+
|
|
64
|
+
## No Liability
|
|
65
|
+
|
|
66
|
+
*As far as the law allows, the software comes as is, without any warranty or
|
|
67
|
+
condition, and the licensor will not be liable to you for any damages arising
|
|
68
|
+
out of these terms or the use or nature of the software, under any kind of
|
|
69
|
+
legal claim.*
|
|
70
|
+
|
|
71
|
+
## Definitions
|
|
72
|
+
|
|
73
|
+
The **licensor** is the entity offering these terms, and the **software** is the
|
|
74
|
+
software the licensor makes available under these terms, including any portion
|
|
75
|
+
of it.
|
|
76
|
+
|
|
77
|
+
**you** refers to the individual or entity agreeing to these terms.
|
|
78
|
+
|
|
79
|
+
**your company** is any legal entity, sole proprietorship, or other kind of
|
|
80
|
+
organization that you work for, plus all organizations that have control over,
|
|
81
|
+
are under the control of, or are under common control with that organization.
|
|
82
|
+
**control** means ownership of substantially all the assets of an entity, or the
|
|
83
|
+
power to direct its management and policies by vote, contract, or otherwise.
|
|
84
|
+
Control can be direct or indirect.
|
|
85
|
+
|
|
86
|
+
**your licenses** are all the licenses granted to you for the software under
|
|
87
|
+
these terms.
|
|
88
|
+
|
|
89
|
+
**use** means anything you do with the software requiring one of your licenses.
|
|
90
|
+
|
|
91
|
+
**trademark** means trademarks, service marks, and similar rights.
|
weflayr-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: weflayr
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Drop-in instrumented wrappers for AI clients with zero-overhead telemetry
|
|
5
|
+
Project-URL: Homepage, https://weflayr.com
|
|
6
|
+
Project-URL: Documentation, https://weflayr.com/docs
|
|
7
|
+
Project-URL: Repository, https://github.com/weflayr/weflayr
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/weflayr/weflayr/issues
|
|
9
|
+
Author-email: Weflayr <contact@weflayr.com>
|
|
10
|
+
License: Elastic-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai,instrumentation,llm,mistral,observability,openai,telemetry,tracing
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: Other/Proprietary License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: System :: Monitoring
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.13
|
|
23
|
+
Requires-Dist: httpx>=0.27.0
|
|
24
|
+
Requires-Dist: mistralai>=2.0.5
|
|
25
|
+
Requires-Dist: openai>=2.29.0
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
29
|
+
Provides-Extra: docs
|
|
30
|
+
Requires-Dist: pdoc; extra == 'docs'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# Weflayr SDK
|
|
34
|
+
|
|
35
|
+
Drop-in instrumented wrappers for OpenAI and Mistral AI clients. Add telemetry to your LLM calls in one line - no changes to your existing code structure required.
|
|
36
|
+
|
|
37
|
+
## How it works
|
|
38
|
+
|
|
39
|
+
Weflayr wraps the official provider SDKs and automatically fires telemetry events to your Weflayr intake API before, after, and on error for every LLM call. Your application code stays identical.
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
your code → weflayr.sdk.openai.OpenAI → openai.OpenAI → OpenAI API
|
|
43
|
+
↓
|
|
44
|
+
Weflayr Intake API
|
|
45
|
+
(before / after / error events)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install weflayr
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Quickstart
|
|
55
|
+
|
|
56
|
+
### Configuration
|
|
57
|
+
|
|
58
|
+
Set the following environment variables:
|
|
59
|
+
|
|
60
|
+
| Variable | Description | Default |
|
|
61
|
+
|---|---|---|
|
|
62
|
+
| `WEFLAYR_INTAKE_URL` | Your Weflayr intake API base URL | `https://api.weflayr.com` |
|
|
63
|
+
| `WEFLAYR_CLIENT_ID` | Your client identifier | `unknown_client` |
|
|
64
|
+
| `WEFLAYR_CLIENT_SECRET` | Your bearer token | _(empty)_ |
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
export WEFLAYR_INTAKE_URL="https://api.weflayr.com"
|
|
68
|
+
export WEFLAYR_CLIENT_ID="my-app"
|
|
69
|
+
export WEFLAYR_CLIENT_SECRET="your-secret-token"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## OpenAI
|
|
75
|
+
|
|
76
|
+
Drop-in replacement for `openai.OpenAI` and `openai.AsyncOpenAI`.
|
|
77
|
+
|
|
78
|
+
### Sync
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from weflayr.sdk.openai.client import OpenAI
|
|
82
|
+
|
|
83
|
+
client = OpenAI(api_key="sk-...")
|
|
84
|
+
|
|
85
|
+
response = client.chat.completions.create(
|
|
86
|
+
model="gpt-4o-mini",
|
|
87
|
+
messages=[{"role": "user", "content": "Hello!"}],
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
print(response.choices[0].message.content)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Async
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
import asyncio
|
|
97
|
+
from weflayr.sdk.openai.client import AsyncOpenAI
|
|
98
|
+
|
|
99
|
+
client = AsyncOpenAI(api_key="sk-...")
|
|
100
|
+
|
|
101
|
+
async def main():
|
|
102
|
+
response = await client.chat.completions.create(
|
|
103
|
+
model="gpt-4o-mini",
|
|
104
|
+
messages=[{"role": "user", "content": "Hello!"}],
|
|
105
|
+
)
|
|
106
|
+
print(response.choices[0].message.content)
|
|
107
|
+
|
|
108
|
+
asyncio.run(main())
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Tagging calls
|
|
112
|
+
|
|
113
|
+
Pass a `tags` dict to attach arbitrary metadata to your telemetry events:
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
response = client.chat.completions.create(
|
|
117
|
+
model="gpt-4o-mini",
|
|
118
|
+
messages=[{"role": "user", "content": "Summarize this."}],
|
|
119
|
+
tags={"feature": "summarization", "user_id": "u_123"},
|
|
120
|
+
)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Mistral AI
|
|
126
|
+
|
|
127
|
+
Drop-in replacement for `mistralai.client.Mistral`.
|
|
128
|
+
|
|
129
|
+
### Sync
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from weflayr.sdk.mistralai.client import Mistral
|
|
133
|
+
|
|
134
|
+
client = Mistral(api_key="sk-...")
|
|
135
|
+
|
|
136
|
+
response = client.chat.complete(
|
|
137
|
+
model="mistral-small-latest",
|
|
138
|
+
messages=[{"role": "user", "content": "Hello!"}],
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
print(response.choices[0].message.content)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Async
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
import asyncio
|
|
148
|
+
from weflayr.sdk.mistralai.client import Mistral
|
|
149
|
+
|
|
150
|
+
client = Mistral(api_key="sk-...")
|
|
151
|
+
|
|
152
|
+
async def main():
|
|
153
|
+
response = await client.chat.complete_async(
|
|
154
|
+
model="mistral-small-latest",
|
|
155
|
+
messages=[{"role": "user", "content": "Hello!"}],
|
|
156
|
+
)
|
|
157
|
+
print(response.choices[0].message.content)
|
|
158
|
+
|
|
159
|
+
asyncio.run(main())
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Tagging calls
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
response = client.chat.complete(
|
|
166
|
+
model="mistral-small-latest",
|
|
167
|
+
messages=[{"role": "user", "content": "Translate this."}],
|
|
168
|
+
tags={"feature": "translation", "env": "production"},
|
|
169
|
+
)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Telemetry events
|
|
175
|
+
|
|
176
|
+
For every LLM call, Weflayr sends up to three events to your intake API:
|
|
177
|
+
|
|
178
|
+
| Event | When | Payload includes |
|
|
179
|
+
|---|---|---|
|
|
180
|
+
| `<call>.before` | Before the provider call | `model`, `message_count`, `tags` |
|
|
181
|
+
| `<call>.after` | On success | `model`, `elapsed_ms`, `prompt_tokens`, `completion_tokens` |
|
|
182
|
+
| `<call>.error` | On failure | `model`, `elapsed_ms`, `error_type`, `error_message`, `status_code` |
|
|
183
|
+
|
|
184
|
+
Events are sent **fire-and-forget** in background threads — they never block your application or raise exceptions.
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Advanced: per-client configuration
|
|
189
|
+
|
|
190
|
+
Override the intake URL, client ID, and bearer token directly on the client instead of using environment variables:
|
|
191
|
+
|
|
192
|
+
```python
|
|
193
|
+
from weflayr.sdk.openai.client import OpenAI
|
|
194
|
+
|
|
195
|
+
client = OpenAI(
|
|
196
|
+
api_key="sk-...",
|
|
197
|
+
intake_url="https://intake.weflayr.com",
|
|
198
|
+
client_id="my-service",
|
|
199
|
+
bearer_token="my-secret",
|
|
200
|
+
)
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## License
|
|
206
|
+
|
|
207
|
+
[Elastic License 2.0](LICENSE) — free to use, modifications and redistribution not permitted.
|
weflayr-0.1.0/README.md
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# Weflayr SDK
|
|
2
|
+
|
|
3
|
+
Drop-in instrumented wrappers for OpenAI and Mistral AI clients. Add telemetry to your LLM calls in one line - no changes to your existing code structure required.
|
|
4
|
+
|
|
5
|
+
## How it works
|
|
6
|
+
|
|
7
|
+
Weflayr wraps the official provider SDKs and automatically fires telemetry events to your Weflayr intake API before, after, and on error for every LLM call. Your application code stays identical.
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
your code → weflayr.sdk.openai.OpenAI → openai.OpenAI → OpenAI API
|
|
11
|
+
↓
|
|
12
|
+
Weflayr Intake API
|
|
13
|
+
(before / after / error events)
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install weflayr
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quickstart
|
|
23
|
+
|
|
24
|
+
### Configuration
|
|
25
|
+
|
|
26
|
+
Set the following environment variables:
|
|
27
|
+
|
|
28
|
+
| Variable | Description | Default |
|
|
29
|
+
|---|---|---|
|
|
30
|
+
| `WEFLAYR_INTAKE_URL` | Your Weflayr intake API base URL | `https://api.weflayr.com` |
|
|
31
|
+
| `WEFLAYR_CLIENT_ID` | Your client identifier | `unknown_client` |
|
|
32
|
+
| `WEFLAYR_CLIENT_SECRET` | Your bearer token | _(empty)_ |
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
export WEFLAYR_INTAKE_URL="https://api.weflayr.com"
|
|
36
|
+
export WEFLAYR_CLIENT_ID="my-app"
|
|
37
|
+
export WEFLAYR_CLIENT_SECRET="your-secret-token"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## OpenAI
|
|
43
|
+
|
|
44
|
+
Drop-in replacement for `openai.OpenAI` and `openai.AsyncOpenAI`.
|
|
45
|
+
|
|
46
|
+
### Sync
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from weflayr.sdk.openai.client import OpenAI
|
|
50
|
+
|
|
51
|
+
client = OpenAI(api_key="sk-...")
|
|
52
|
+
|
|
53
|
+
response = client.chat.completions.create(
|
|
54
|
+
model="gpt-4o-mini",
|
|
55
|
+
messages=[{"role": "user", "content": "Hello!"}],
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
print(response.choices[0].message.content)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Async
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
import asyncio
|
|
65
|
+
from weflayr.sdk.openai.client import AsyncOpenAI
|
|
66
|
+
|
|
67
|
+
client = AsyncOpenAI(api_key="sk-...")
|
|
68
|
+
|
|
69
|
+
async def main():
|
|
70
|
+
response = await client.chat.completions.create(
|
|
71
|
+
model="gpt-4o-mini",
|
|
72
|
+
messages=[{"role": "user", "content": "Hello!"}],
|
|
73
|
+
)
|
|
74
|
+
print(response.choices[0].message.content)
|
|
75
|
+
|
|
76
|
+
asyncio.run(main())
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Tagging calls
|
|
80
|
+
|
|
81
|
+
Pass a `tags` dict to attach arbitrary metadata to your telemetry events:
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
response = client.chat.completions.create(
|
|
85
|
+
model="gpt-4o-mini",
|
|
86
|
+
messages=[{"role": "user", "content": "Summarize this."}],
|
|
87
|
+
tags={"feature": "summarization", "user_id": "u_123"},
|
|
88
|
+
)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Mistral AI
|
|
94
|
+
|
|
95
|
+
Drop-in replacement for `mistralai.client.Mistral`.
|
|
96
|
+
|
|
97
|
+
### Sync
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from weflayr.sdk.mistralai.client import Mistral
|
|
101
|
+
|
|
102
|
+
client = Mistral(api_key="sk-...")
|
|
103
|
+
|
|
104
|
+
response = client.chat.complete(
|
|
105
|
+
model="mistral-small-latest",
|
|
106
|
+
messages=[{"role": "user", "content": "Hello!"}],
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
print(response.choices[0].message.content)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Async
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
import asyncio
|
|
116
|
+
from weflayr.sdk.mistralai.client import Mistral
|
|
117
|
+
|
|
118
|
+
client = Mistral(api_key="sk-...")
|
|
119
|
+
|
|
120
|
+
async def main():
|
|
121
|
+
response = await client.chat.complete_async(
|
|
122
|
+
model="mistral-small-latest",
|
|
123
|
+
messages=[{"role": "user", "content": "Hello!"}],
|
|
124
|
+
)
|
|
125
|
+
print(response.choices[0].message.content)
|
|
126
|
+
|
|
127
|
+
asyncio.run(main())
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Tagging calls
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
response = client.chat.complete(
|
|
134
|
+
model="mistral-small-latest",
|
|
135
|
+
messages=[{"role": "user", "content": "Translate this."}],
|
|
136
|
+
tags={"feature": "translation", "env": "production"},
|
|
137
|
+
)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Telemetry events
|
|
143
|
+
|
|
144
|
+
For every LLM call, Weflayr sends up to three events to your intake API:
|
|
145
|
+
|
|
146
|
+
| Event | When | Payload includes |
|
|
147
|
+
|---|---|---|
|
|
148
|
+
| `<call>.before` | Before the provider call | `model`, `message_count`, `tags` |
|
|
149
|
+
| `<call>.after` | On success | `model`, `elapsed_ms`, `prompt_tokens`, `completion_tokens` |
|
|
150
|
+
| `<call>.error` | On failure | `model`, `elapsed_ms`, `error_type`, `error_message`, `status_code` |
|
|
151
|
+
|
|
152
|
+
Events are sent **fire-and-forget** in background threads — they never block your application or raise exceptions.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Advanced: per-client configuration
|
|
157
|
+
|
|
158
|
+
Override the intake URL, client ID, and bearer token directly on the client instead of using environment variables:
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
from weflayr.sdk.openai.client import OpenAI
|
|
162
|
+
|
|
163
|
+
client = OpenAI(
|
|
164
|
+
api_key="sk-...",
|
|
165
|
+
intake_url="https://intake.weflayr.com",
|
|
166
|
+
client_id="my-service",
|
|
167
|
+
bearer_token="my-secret",
|
|
168
|
+
)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
[Elastic License 2.0](LICENSE) — free to use, modifications and redistribution not permitted.
|