Skip to content

Commit a12b1cd

Browse files
authored
Merge pull request #2 from Not-Diamond/release-please--branches--main--changes--next
release: 0.2.0
2 parents d690171 + 03e562d commit a12b1cd

96 files changed

Lines changed: 269 additions & 10878 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.1.0"
2+
".": "0.2.0"
33
}

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 57
1+
configured_endpoints: 20
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/not-diamond-dragos199993%2Fnot-diamond-16cbc3880d2b786cefa8c80a6dd1129791483c0b487955104c68a5c13f00a69b.yml
33
openapi_spec_hash: 4c16e5753f4b9e0a20dd01706c5d07d7
4-
config_hash: 9677dbeed46c9972dd85705a35091068
4+
config_hash: 36de232224f15ed78970b28252ccf625

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 0.2.0 (2025-10-09)
4+
5+
Full Changelog: [v0.1.0...v0.2.0](https://github.com/Not-Diamond/not-diamond-python/compare/v0.1.0...v0.2.0)
6+
7+
### Features
8+
9+
* **api:** manual updates ([9ee8b3e](https://github.com/Not-Diamond/not-diamond-python/commit/9ee8b3e1220e45b00ce9c9078ab7f54bb1e34e19))
10+
311
## 0.1.0 (2025-10-09)
412

513
Full Changelog: [v0.0.1...v0.1.0](https://github.com/Not-Diamond/not-diamond-python/compare/v0.0.1...v0.1.0)

README.md

Lines changed: 89 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,19 @@ pip install git+ssh://git@github.com/Not-Diamond/not-diamond-python.git
2828
The full API of this library can be found in [api.md](api.md).
2929

3030
```python
31-
import os
3231
from not_diamond import NotDiamond
3332

34-
client = NotDiamond(
35-
api_key=os.environ.get("NOT_DIAMOND_API_KEY"), # This is the default and can be omitted
36-
)
33+
client = NotDiamond()
3734

38-
response = client.retrieve_root()
35+
response = client.model_router.select_model(
36+
llm_providers=[
37+
{
38+
"model": "model",
39+
"provider": "provider",
40+
}
41+
],
42+
messages=[{"foo": "string"}],
43+
)
3944
```
4045

4146
While you can provide an `api_key` keyword argument,
@@ -48,17 +53,22 @@ so that your API Key is not stored in source control.
4853
Simply import `AsyncNotDiamond` instead of `NotDiamond` and use `await` with each API call:
4954

5055
```python
51-
import os
5256
import asyncio
5357
from not_diamond import AsyncNotDiamond
5458

55-
client = AsyncNotDiamond(
56-
api_key=os.environ.get("NOT_DIAMOND_API_KEY"), # This is the default and can be omitted
57-
)
59+
client = AsyncNotDiamond()
5860

5961

6062
async def main() -> None:
61-
response = await client.retrieve_root()
63+
response = await client.model_router.select_model(
64+
llm_providers=[
65+
{
66+
"model": "model",
67+
"provider": "provider",
68+
}
69+
],
70+
messages=[{"foo": "string"}],
71+
)
6272

6373

6474
asyncio.run(main())
@@ -87,10 +97,17 @@ from not_diamond import AsyncNotDiamond
8797

8898
async def main() -> None:
8999
async with AsyncNotDiamond(
90-
api_key="My API Key",
91100
http_client=DefaultAioHttpClient(),
92101
) as client:
93-
response = await client.retrieve_root()
102+
response = await client.model_router.select_model(
103+
llm_providers=[
104+
{
105+
"model": "model",
106+
"provider": "provider",
107+
}
108+
],
109+
messages=[{"foo": "string"}],
110+
)
94111

95112

96113
asyncio.run(main())
@@ -114,16 +131,23 @@ from not_diamond import NotDiamond
114131

115132
client = NotDiamond()
116133

117-
response = client.report.evaluate_hallucination(
118-
context="context",
119-
prompt="prompt",
120-
provider={
134+
response = client.prompt.adapt(
135+
fields=["string"],
136+
goldens=[{"fields": {"foo": "string"}}],
137+
origin_model={
121138
"model": "model",
122139
"provider": "provider",
123140
},
124-
response="response",
141+
system_prompt="system_prompt",
142+
target_models=[
143+
{
144+
"model": "model",
145+
"provider": "provider",
146+
}
147+
],
148+
template="template",
125149
)
126-
print(response.provider)
150+
print(response.origin_model)
127151
```
128152

129153
## File uploads
@@ -165,7 +189,15 @@ from not_diamond import NotDiamond
165189
client = NotDiamond()
166190

167191
try:
168-
client.retrieve_root()
192+
client.model_router.select_model(
193+
llm_providers=[
194+
{
195+
"model": "model",
196+
"provider": "provider",
197+
}
198+
],
199+
messages=[{"foo": "string"}],
200+
)
169201
except not_diamond.APIConnectionError as e:
170202
print("The server could not be reached")
171203
print(e.__cause__) # an underlying Exception, likely raised within httpx.
@@ -208,7 +240,15 @@ client = NotDiamond(
208240
)
209241

210242
# Or, configure per-request:
211-
client.with_options(max_retries=5).retrieve_root()
243+
client.with_options(max_retries=5).model_router.select_model(
244+
llm_providers=[
245+
{
246+
"model": "model",
247+
"provider": "provider",
248+
}
249+
],
250+
messages=[{"foo": "string"}],
251+
)
212252
```
213253

214254
### Timeouts
@@ -231,7 +271,15 @@ client = NotDiamond(
231271
)
232272

233273
# Override per-request:
234-
client.with_options(timeout=5.0).retrieve_root()
274+
client.with_options(timeout=5.0).model_router.select_model(
275+
llm_providers=[
276+
{
277+
"model": "model",
278+
"provider": "provider",
279+
}
280+
],
281+
messages=[{"foo": "string"}],
282+
)
235283
```
236284

237285
On timeout, an `APITimeoutError` is thrown.
@@ -272,11 +320,19 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
272320
from not_diamond import NotDiamond
273321

274322
client = NotDiamond()
275-
response = client.with_raw_response.retrieve_root()
323+
response = client.model_router.with_raw_response.select_model(
324+
llm_providers=[{
325+
"model": "model",
326+
"provider": "provider",
327+
}],
328+
messages=[{
329+
"foo": "string"
330+
}],
331+
)
276332
print(response.headers.get('X-My-Header'))
277333

278-
client = response.parse() # get the object that `retrieve_root()` would have returned
279-
print(client)
334+
model_router = response.parse() # get the object that `model_router.select_model()` would have returned
335+
print(model_router)
280336
```
281337

282338
These methods return an [`APIResponse`](https://github.com/Not-Diamond/not-diamond-python/tree/main/src/not_diamond/_response.py) object.
@@ -290,7 +346,15 @@ The above interface eagerly reads the full response body when you make the reque
290346
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
291347

292348
```python
293-
with client.with_streaming_response.retrieve_root() as response:
349+
with client.model_router.with_streaming_response.select_model(
350+
llm_providers=[
351+
{
352+
"model": "model",
353+
"provider": "provider",
354+
}
355+
],
356+
messages=[{"foo": "string"}],
357+
) as response:
294358
print(response.headers.get("X-My-Header"))
295359

296360
for line in response.iter_lines():

0 commit comments

Comments
 (0)