Skip to content

Commit 18443a5

Browse files
feat(api): update via SDK Studio
1 parent e9f24af commit 18443a5

File tree

5 files changed

+75
-75
lines changed

5 files changed

+75
-75
lines changed

README.md

+34-34
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Contextual AI Python API library
22

3-
[![PyPI version](https://img.shields.io/pypi/v/contextual-sdk.svg)](https://pypi.org/project/contextual-sdk/)
3+
[![PyPI version](https://img.shields.io/pypi/v/contextual-client.svg)](https://pypi.org/project/contextual-client/)
44

55
The Contextual AI Python library provides convenient access to the Contextual AI REST API from any Python 3.8+
66
application. The library includes type definitions for all request params and response fields,
@@ -20,7 +20,7 @@ pip install git+ssh://git@github.com/stainless-sdks/sunrise-python.git
2020
```
2121

2222
> [!NOTE]
23-
> Once this package is [published to PyPI](https://app.stainlessapi.com/docs/guides/publish), this will become: `pip install --pre contextual-sdk`
23+
> Once this package is [published to PyPI](https://app.stainlessapi.com/docs/guides/publish), this will become: `pip install --pre contextual-client`
2424
2525
## Usage
2626

@@ -34,10 +34,10 @@ client = ContextualAI(
3434
api_key=os.environ.get("CONTEXTUAL_API_KEY"), # This is the default and can be omitted
3535
)
3636

37-
create_datastore_response = client.datastores.create(
38-
name="name",
37+
create_application_output = client.applications.create(
38+
name="xxx",
3939
)
40-
print(create_datastore_response.id)
40+
print(create_application_output.application_id)
4141
```
4242

4343
While you can provide an `api_key` keyword argument,
@@ -60,10 +60,10 @@ client = AsyncContextualAI(
6060

6161

6262
async def main() -> None:
63-
create_datastore_response = await client.datastores.create(
64-
name="name",
63+
create_application_output = await client.applications.create(
64+
name="xxx",
6565
)
66-
print(create_datastore_response.id)
66+
print(create_application_output.application_id)
6767

6868

6969
asyncio.run(main())
@@ -91,12 +91,12 @@ from contextual import ContextualAI
9191

9292
client = ContextualAI()
9393

94-
all_datastores = []
94+
all_applications = []
9595
# Automatically fetches more pages as needed.
96-
for datastore in client.datastores.list():
97-
# Do something with datastore here
98-
all_datastores.append(datastore)
99-
print(all_datastores)
96+
for application in client.applications.list():
97+
# Do something with application here
98+
all_applications.append(application)
99+
print(all_applications)
100100
```
101101

102102
Or, asynchronously:
@@ -109,11 +109,11 @@ client = AsyncContextualAI()
109109

110110

111111
async def main() -> None:
112-
all_datastores = []
112+
all_applications = []
113113
# Iterate through items across all pages, issuing requests as needed.
114-
async for datastore in client.datastores.list():
115-
all_datastores.append(datastore)
116-
print(all_datastores)
114+
async for application in client.applications.list():
115+
all_applications.append(application)
116+
print(all_applications)
117117

118118

119119
asyncio.run(main())
@@ -122,23 +122,23 @@ asyncio.run(main())
122122
Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:
123123

124124
```python
125-
first_page = await client.datastores.list()
125+
first_page = await client.applications.list()
126126
if first_page.has_next_page():
127127
print(f"will fetch next page using these details: {first_page.next_page_info()}")
128128
next_page = await first_page.get_next_page()
129-
print(f"number of items we just fetched: {len(next_page.datastores)}")
129+
print(f"number of items we just fetched: {len(next_page.applications)}")
130130

131131
# Remove `await` for non-async usage.
132132
```
133133

134134
Or just work directly with the returned data:
135135

136136
```python
137-
first_page = await client.datastores.list()
137+
first_page = await client.applications.list()
138138

139139
print(f"next page cursor: {first_page.next_cursor}") # => "next page cursor: ..."
140-
for datastore in first_page.datastores:
141-
print(datastore.id)
140+
for application in first_page.applications:
141+
print(application.id)
142142

143143
# Remove `await` for non-async usage.
144144
```
@@ -159,8 +159,8 @@ from contextual import ContextualAI
159159
client = ContextualAI()
160160

161161
try:
162-
client.datastores.create(
163-
name="name",
162+
client.applications.create(
163+
name="xxx",
164164
)
165165
except contextual.APIConnectionError as e:
166166
print("The server could not be reached")
@@ -204,8 +204,8 @@ client = ContextualAI(
204204
)
205205

206206
# Or, configure per-request:
207-
client.with_options(max_retries=5).datastores.create(
208-
name="name",
207+
client.with_options(max_retries=5).applications.create(
208+
name="xxx",
209209
)
210210
```
211211

@@ -229,8 +229,8 @@ client = ContextualAI(
229229
)
230230

231231
# Override per-request:
232-
client.with_options(timeout=5.0).datastores.create(
233-
name="name",
232+
client.with_options(timeout=5.0).applications.create(
233+
name="xxx",
234234
)
235235
```
236236

@@ -272,13 +272,13 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
272272
from contextual import ContextualAI
273273

274274
client = ContextualAI()
275-
response = client.datastores.with_raw_response.create(
276-
name="name",
275+
response = client.applications.with_raw_response.create(
276+
name="xxx",
277277
)
278278
print(response.headers.get('X-My-Header'))
279279

280-
datastore = response.parse() # get the object that `datastores.create()` would have returned
281-
print(datastore.id)
280+
application = response.parse() # get the object that `applications.create()` would have returned
281+
print(application.application_id)
282282
```
283283

284284
These methods return an [`APIResponse`](https://github.com/stainless-sdks/sunrise-python/tree/main/src/contextual/_response.py) object.
@@ -292,8 +292,8 @@ The above interface eagerly reads the full response body when you make the reque
292292
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.
293293

294294
```python
295-
with client.datastores.with_streaming_response.create(
296-
name="name",
295+
with client.applications.with_streaming_response.create(
296+
name="xxx",
297297
) as response:
298298
print(response.headers.get("X-My-Header"))
299299

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[project]
2-
name = "contextual-sdk"
2+
name = "contextual-client"
33
version = "0.0.1-alpha.0"
44
description = "The official Python library for the Contextual AI API"
55
dynamic = ["readme"]

requirements-dev.lock

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
annotated-types==0.6.0
1313
# via pydantic
1414
anyio==4.4.0
15-
# via contextual-sdk
15+
# via contextual-client
1616
# via httpx
1717
argcomplete==3.1.2
1818
# via nox
@@ -25,7 +25,7 @@ dirty-equals==0.6.0
2525
distlib==0.3.7
2626
# via virtualenv
2727
distro==1.8.0
28-
# via contextual-sdk
28+
# via contextual-client
2929
exceptiongroup==1.2.2
3030
# via anyio
3131
# via pytest
@@ -36,7 +36,7 @@ h11==0.14.0
3636
httpcore==1.0.2
3737
# via httpx
3838
httpx==0.28.1
39-
# via contextual-sdk
39+
# via contextual-client
4040
# via respx
4141
idna==3.4
4242
# via anyio
@@ -63,7 +63,7 @@ platformdirs==3.11.0
6363
pluggy==1.5.0
6464
# via pytest
6565
pydantic==2.10.3
66-
# via contextual-sdk
66+
# via contextual-client
6767
pydantic-core==2.27.1
6868
# via pydantic
6969
pygments==2.18.0
@@ -85,14 +85,14 @@ six==1.16.0
8585
# via python-dateutil
8686
sniffio==1.3.0
8787
# via anyio
88-
# via contextual-sdk
88+
# via contextual-client
8989
time-machine==2.9.0
9090
tomli==2.0.2
9191
# via mypy
9292
# via pytest
9393
typing-extensions==4.12.2
9494
# via anyio
95-
# via contextual-sdk
95+
# via contextual-client
9696
# via mypy
9797
# via pydantic
9898
# via pydantic-core

requirements.lock

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,33 @@
1212
annotated-types==0.6.0
1313
# via pydantic
1414
anyio==4.4.0
15-
# via contextual-sdk
15+
# via contextual-client
1616
# via httpx
1717
certifi==2023.7.22
1818
# via httpcore
1919
# via httpx
2020
distro==1.8.0
21-
# via contextual-sdk
21+
# via contextual-client
2222
exceptiongroup==1.2.2
2323
# via anyio
2424
h11==0.14.0
2525
# via httpcore
2626
httpcore==1.0.2
2727
# via httpx
2828
httpx==0.28.1
29-
# via contextual-sdk
29+
# via contextual-client
3030
idna==3.4
3131
# via anyio
3232
# via httpx
3333
pydantic==2.10.3
34-
# via contextual-sdk
34+
# via contextual-client
3535
pydantic-core==2.27.1
3636
# via pydantic
3737
sniffio==1.3.0
3838
# via anyio
39-
# via contextual-sdk
39+
# via contextual-client
4040
typing-extensions==4.12.2
4141
# via anyio
42-
# via contextual-sdk
42+
# via contextual-client
4343
# via pydantic
4444
# via pydantic-core

0 commit comments

Comments
 (0)