Skip to content

Commit f568f65

Browse files
feat(api): update via SDK Studio
1 parent a3a4573 commit f568f65

File tree

393 files changed

+24976
-14432
lines changed

Some content is hidden

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

393 files changed

+24976
-14432
lines changed

.github/workflows/publish-pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ jobs:
2828
run: |
2929
bash ./bin/publish-pypi
3030
env:
31-
PYPI_TOKEN: ${{ secrets.LLAMA_STACK_CLIENT_PYPI_TOKEN || secrets.PYPI_TOKEN }}
31+
PYPI_TOKEN: ${{ secrets.LLAMA_STACK_PYPI_TOKEN || secrets.PYPI_TOKEN }}

.github/workflows/release-doctor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ jobs:
1818
run: |
1919
bash ./bin/check-release-environment
2020
env:
21-
PYPI_TOKEN: ${{ secrets.LLAMA_STACK_CLIENT_PYPI_TOKEN || secrets.PYPI_TOKEN }}
21+
PYPI_TOKEN: ${{ secrets.LLAMA_STACK_PYPI_TOKEN || secrets.PYPI_TOKEN }}

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 91
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-0e756984d87c3fd1eb96d486947b3bc2086d5afcf299e8119b6b89bbd86dbe75.yml
3-
openapi_spec_hash: 7c519a25bb9a094d4b4bda17bb20dd88
4-
config_hash: d1f21dfdbf5d9925eecf56b6c1fab755
1+
configured_endpoints: 96
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-df7a19394e9124c18ec4e888e2856d22b5ebfd6fe6fe6e929ff6cfadb2ae7e2a.yml
3+
openapi_spec_hash: 9428682672fdd7e2afee7af9ef849dc9
4+
config_hash: c2377844063fe8b7c43d8b79522fa6fc

README.md

Lines changed: 124 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ It is generated with [Stainless](https://www.stainless.com/).
1010

1111
## Documentation
1212

13-
The full API of this library can be found in [api.md](api.md).
13+
The REST API documentation can be found on [llama-stack.readthedocs.io](https://llama-stack.readthedocs.io/en/latest/). The full API of this library can be found in [api.md](api.md).
1414

1515
## Installation
1616

@@ -27,43 +27,37 @@ pip install git+ssh://git@github.com/llamastack/llama-stack-client-python.git
2727
The full API of this library can be found in [api.md](api.md).
2828

2929
```python
30-
import os
3130
from llama_stack_client import LlamaStackClient
3231

33-
client = LlamaStackClient(
34-
api_key=os.environ.get("LLAMA_STACK_CLIENT_API_KEY"), # This is the default and can be omitted
35-
)
32+
client = LlamaStackClient()
3633

37-
client.datasetio.append_rows(
38-
dataset_id="REPLACE_ME",
39-
rows=[{"foo": True}],
34+
model = client.models.register(
35+
model_id="model_id",
4036
)
37+
print(model.identifier)
4138
```
4239

4340
While you can provide an `api_key` keyword argument,
4441
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
45-
to add `LLAMA_STACK_CLIENT_API_KEY="My API Key"` to your `.env` file
42+
to add `LLAMA_STACK_API_KEY="My API Key"` to your `.env` file
4643
so that your API Key is not stored in source control.
4744

4845
## Async usage
4946

5047
Simply import `AsyncLlamaStackClient` instead of `LlamaStackClient` and use `await` with each API call:
5148

5249
```python
53-
import os
5450
import asyncio
5551
from llama_stack_client import AsyncLlamaStackClient
5652

57-
client = AsyncLlamaStackClient(
58-
api_key=os.environ.get("LLAMA_STACK_CLIENT_API_KEY"), # This is the default and can be omitted
59-
)
53+
client = AsyncLlamaStackClient()
6054

6155

6256
async def main() -> None:
63-
await client.datasetio.append_rows(
64-
dataset_id="REPLACE_ME",
65-
rows=[{"foo": True}],
57+
model = await client.models.register(
58+
model_id="model_id",
6659
)
60+
print(model.identifier)
6761

6862

6963
asyncio.run(main())
@@ -85,28 +79,68 @@ pip install 'llama_stack_client[aiohttp] @ git+ssh://git@github.com/llamastack/l
8579
Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
8680

8781
```python
88-
import os
8982
import asyncio
9083
from llama_stack_client import DefaultAioHttpClient
9184
from llama_stack_client import AsyncLlamaStackClient
9285

9386

9487
async def main() -> None:
9588
async with AsyncLlamaStackClient(
96-
api_key=os.environ.get(
97-
"LLAMA_STACK_CLIENT_API_KEY"
98-
), # This is the default and can be omitted
9989
http_client=DefaultAioHttpClient(),
10090
) as client:
101-
await client.datasetio.append_rows(
102-
dataset_id="REPLACE_ME",
103-
rows=[{"foo": True}],
91+
model = await client.models.register(
92+
model_id="model_id",
10493
)
94+
print(model.identifier)
10595

10696

10797
asyncio.run(main())
10898
```
10999

100+
## Streaming responses
101+
102+
We provide support for streaming responses using Server Side Events (SSE).
103+
104+
```python
105+
from llama_stack_client import LlamaStackClient
106+
107+
client = LlamaStackClient()
108+
109+
stream = client.inference.chat_completion(
110+
messages=[
111+
{
112+
"content": "string",
113+
"role": "user",
114+
}
115+
],
116+
model_id="model_id",
117+
stream=True,
118+
)
119+
for chat_completion_response in stream:
120+
print(chat_completion_response.completion_message)
121+
```
122+
123+
The async client uses the exact same interface.
124+
125+
```python
126+
from llama_stack_client import AsyncLlamaStackClient
127+
128+
client = AsyncLlamaStackClient()
129+
130+
stream = await client.inference.chat_completion(
131+
messages=[
132+
{
133+
"content": "string",
134+
"role": "user",
135+
}
136+
],
137+
model_id="model_id",
138+
stream=True,
139+
)
140+
async for chat_completion_response in stream:
141+
print(chat_completion_response.completion_message)
142+
```
143+
110144
## Using types
111145

112146
Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:
@@ -125,21 +159,37 @@ from llama_stack_client import LlamaStackClient
125159

126160
client = LlamaStackClient()
127161

128-
response = client.inference.batch_chat_completion(
129-
messages_batch=[
130-
[
131-
{
132-
"content": "string",
133-
"role": "user",
134-
}
135-
]
162+
chat_completion_response = client.inference.chat_completion(
163+
messages=[
164+
{
165+
"content": "string",
166+
"role": "user",
167+
}
136168
],
137169
model_id="model_id",
138170
logprobs={},
139171
)
140-
print(response.logprobs)
172+
print(chat_completion_response.logprobs)
141173
```
142174

175+
## File uploads
176+
177+
Request parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.
178+
179+
```python
180+
from pathlib import Path
181+
from llama_stack_client import LlamaStackClient
182+
183+
client = LlamaStackClient()
184+
185+
client.files.create(
186+
file=Path("/path/to/file"),
187+
purpose="assistants",
188+
)
189+
```
190+
191+
The async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.
192+
143193
## Handling errors
144194

145195
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `llama_stack_client.APIConnectionError` is raised.
@@ -156,9 +206,14 @@ from llama_stack_client import LlamaStackClient
156206
client = LlamaStackClient()
157207

158208
try:
159-
client.datasetio.append_rows(
160-
dataset_id="REPLACE_ME",
161-
rows=[{"foo": True}],
209+
client.inference.chat_completion(
210+
messages=[
211+
{
212+
"content": "string",
213+
"role": "user",
214+
}
215+
],
216+
model_id="model_id",
162217
)
163218
except llama_stack_client.APIConnectionError as e:
164219
print("The server could not be reached")
@@ -202,9 +257,14 @@ client = LlamaStackClient(
202257
)
203258

204259
# Or, configure per-request:
205-
client.with_options(max_retries=5).datasetio.append_rows(
206-
dataset_id="REPLACE_ME",
207-
rows=[{"foo": True}],
260+
client.with_options(max_retries=5).inference.chat_completion(
261+
messages=[
262+
{
263+
"content": "string",
264+
"role": "user",
265+
}
266+
],
267+
model_id="model_id",
208268
)
209269
```
210270

@@ -228,9 +288,14 @@ client = LlamaStackClient(
228288
)
229289

230290
# Override per-request:
231-
client.with_options(timeout=5.0).datasetio.append_rows(
232-
dataset_id="REPLACE_ME",
233-
rows=[{"foo": True}],
291+
client.with_options(timeout=5.0).inference.chat_completion(
292+
messages=[
293+
{
294+
"content": "string",
295+
"role": "user",
296+
}
297+
],
298+
model_id="model_id",
234299
)
235300
```
236301

@@ -244,10 +309,10 @@ Note that requests that time out are [retried twice by default](#retries).
244309

245310
We use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.
246311

247-
You can enable logging by setting the environment variable `LLAMA_STACK_CLIENT_LOG` to `info`.
312+
You can enable logging by setting the environment variable `LLAMA_STACK_LOG` to `info`.
248313

249314
```shell
250-
$ export LLAMA_STACK_CLIENT_LOG=info
315+
$ export LLAMA_STACK_LOG=info
251316
```
252317

253318
Or to `debug` for more verbose logging.
@@ -272,16 +337,17 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
272337
from llama_stack_client import LlamaStackClient
273338

274339
client = LlamaStackClient()
275-
response = client.datasetio.with_raw_response.append_rows(
276-
dataset_id="REPLACE_ME",
277-
rows=[{
278-
"foo": True
340+
response = client.inference.with_raw_response.chat_completion(
341+
messages=[{
342+
"content": "string",
343+
"role": "user",
279344
}],
345+
model_id="model_id",
280346
)
281347
print(response.headers.get('X-My-Header'))
282348

283-
datasetio = response.parse() # get the object that `datasetio.append_rows()` would have returned
284-
print(datasetio)
349+
inference = response.parse() # get the object that `inference.chat_completion()` would have returned
350+
print(inference.completion_message)
285351
```
286352

287353
These methods return an [`APIResponse`](https://github.com/llamastack/llama-stack-client-python/tree/main/src/llama_stack_client/_response.py) object.
@@ -295,9 +361,14 @@ The above interface eagerly reads the full response body when you make the reque
295361
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.
296362

297363
```python
298-
with client.datasetio.with_streaming_response.append_rows(
299-
dataset_id="REPLACE_ME",
300-
rows=[{"foo": True}],
364+
with client.inference.with_streaming_response.chat_completion(
365+
messages=[
366+
{
367+
"content": "string",
368+
"role": "user",
369+
}
370+
],
371+
model_id="model_id",
301372
) as response:
302373
print(response.headers.get("X-My-Header"))
303374

@@ -354,7 +425,7 @@ import httpx
354425
from llama_stack_client import LlamaStackClient, DefaultHttpxClient
355426

356427
client = LlamaStackClient(
357-
# Or use the `LLAMA_STACK_CLIENT_BASE_URL` env var
428+
# Or use the `LLAMA_STACK_BASE_URL` env var
358429
base_url="http://my.test.server.example.com:8083",
359430
http_client=DefaultHttpxClient(
360431
proxy="http://my.test.proxy.example.com",

SECURITY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ before making any information public.
1818
If you encounter security issues that are not directly related to SDKs but pertain to the services
1919
or products provided by Llama Stack Client, please follow the respective company's security reporting guidelines.
2020

21+
### Llama Stack Client Terms and Policies
22+
23+
Please contact llamastack@meta.com for any questions or concerns regarding the security of our services.
24+
2125
---
2226

2327
Thank you for helping us keep the SDKs and systems they interact with secure.

0 commit comments

Comments
 (0)