Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
1f04b9e
chore(ci): upload sdks to package manager
stainless-app[bot] May 15, 2025
f191464
chore(ci): fix installation instructions
stainless-app[bot] May 16, 2025
01370fb
chore(docs): grammar improvements
stainless-app[bot] May 22, 2025
9fd7133
fix(docs/api): remove references to nonexistent types
stainless-app[bot] May 28, 2025
68f70a8
chore(docs): remove reference to rye shell
stainless-app[bot] Jun 3, 2025
f603dcd
chore(docs): remove unnecessary param examples
stainless-app[bot] Jun 3, 2025
35e7c78
feat(client): add follow_redirects request option
stainless-app[bot] Jun 3, 2025
f75c912
chore(tests): run tests in parallel
stainless-app[bot] Jun 13, 2025
518cbab
fix(client): correctly parse binary response | stream
stainless-app[bot] Jun 13, 2025
0c4973f
chore(tests): add tests for httpx client instantiation & proxies
stainless-app[bot] Jun 17, 2025
b324ed3
chore(internal): update conftest.py
stainless-app[bot] Jun 17, 2025
84fbba4
chore(ci): enable for pull requests
stainless-app[bot] Jun 17, 2025
b747f45
chore(readme): update badges
stainless-app[bot] Jun 18, 2025
d7920f1
fix(tests): fix: tests which call HTTP endpoints directly with the ex…
stainless-app[bot] Jun 18, 2025
3517a3d
docs(client): fix httpx.Timeout documentation reference
stainless-app[bot] Jun 19, 2025
d54f53c
feat(client): add support for aiohttp
stainless-app[bot] Jun 21, 2025
dd32830
chore(tests): skip some failing tests on the latest python versions
stainless-app[bot] Jun 24, 2025
ce0af3b
fix(ci): release-doctor — report correct token name
stainless-app[bot] Jun 27, 2025
b9520a0
chore(ci): only run for pushes and fork pull requests
stainless-app[bot] Jun 28, 2025
0e1ab57
fix(ci): correct conditional
stainless-app[bot] Jun 30, 2025
f72dfb7
chore(ci): change upload type
stainless-app[bot] Jul 2, 2025
0310d7c
chore(internal): codegen related update
stainless-app[bot] Jul 8, 2025
f0aca79
chore(internal): bump pinned h11 dep
stainless-app[bot] Jul 9, 2025
f37217f
chore(package): mark python 3.13 as supported
stainless-app[bot] Jul 9, 2025
130f4c1
fix(parsing): correctly handle nested discriminated unions
stainless-app[bot] Jul 10, 2025
5857ef3
chore(readme): fix version rendering on pypi
stainless-app[bot] Jul 11, 2025
1ba6bcc
fix(client): don't send Content-Type header on GET requests
stainless-app[bot] Jul 12, 2025
5aacfd7
feat: clean up environment call outs
stainless-app[bot] Jul 15, 2025
a81e190
fix(parsing): ignore empty metadata
stainless-app[bot] Jul 22, 2025
89f10b3
fix(parsing): parse extra field types
stainless-app[bot] Jul 23, 2025
77265c1
chore(project): add settings file for vscode
stainless-app[bot] Jul 25, 2025
44d064d
feat(client): support file upload requests
stainless-app[bot] Jul 31, 2025
40379a3
chore(internal): update examples
stainless-app[bot] Aug 1, 2025
465af9e
chore(internal): fix ruff target version
stainless-app[bot] Aug 6, 2025
82c8bc7
chore: update @stainless-api/prism-cli to v5.15.0
stainless-app[bot] Aug 26, 2025
01101c7
chore(internal): update comment in script
stainless-app[bot] Aug 26, 2025
2d36800
chore: update github action
stainless-app[bot] Aug 22, 2025
9e79111
chore(internal): change ci workflow machines
stainless-app[bot] Aug 26, 2025
feab9f8
feat(api): update via SDK Studio
stainless-app[bot] Aug 26, 2025
04fabfd
feat(api): update via SDK Studio
stainless-app[bot] Aug 26, 2025
afcfc1c
fix: resolve pydantic violation.
lingxi-at-contextual Aug 26, 2025
cd91b8a
release: 0.8.0
stainless-app[bot] Aug 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ on:
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
- 'stl-preview-base/**'

jobs:
lint:
timeout-minutes: 10
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/sunrise-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@v4

Expand All @@ -30,10 +35,51 @@ jobs:
- name: Run lints
run: ./scripts/lint

build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
timeout-minutes: 10
name: build
permissions:
contents: read
id-token: write
runs-on: ${{ github.repository == 'stainless-sdks/sunrise-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v4

- name: Install Rye
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'

- name: Install dependencies
run: rye sync --all-features

- name: Run build
run: rye build

- name: Get GitHub OIDC Token
if: github.repository == 'stainless-sdks/sunrise-python'
id: github-oidc
uses: actions/github-script@v6
with:
script: core.setOutput('github_token', await core.getIDToken());

- name: Upload tarball
if: github.repository == 'stainless-sdks/sunrise-python'
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
SHA: ${{ github.sha }}
run: ./scripts/utils/upload-artifact.sh

test:
timeout-minutes: 10
name: test
runs-on: ${{ github.repository == 'stainless-sdks/sunrise-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@v4

Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.prism.log
.vscode
_dev

__pycache__
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.7.0"
".": "0.8.0"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 52
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/contextual-ai%2Fsunrise-8d75c58c83d13f67b6a125c3eb4639d213c91aec7dbb6e06f0cd5bdfc074d54e.yml
openapi_spec_hash: 47795284631814d0f8eb42f6a0d5a3b3
config_hash: 1ecef0ff4fd125bbc00eec65e3dd4798
configured_endpoints: 34
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/contextual-ai%2Fsunrise-db7245c74772a8cd47c02886619fed0568fbb58b1fa8aba0dc77524b924a4fb6.yml
openapi_spec_hash: ca3de8d7b14b78683e39464fe7d4b1e1
config_hash: 410f8a2f86f605885911277be47c3c78
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.analysis.importFormat": "relative",
}
60 changes: 60 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,65 @@
# Changelog

## 0.8.0 (2025-08-26)

Full Changelog: [v0.7.0...v0.8.0](https://github.com/ContextualAI/contextual-client-python/compare/v0.7.0...v0.8.0)

### Features

* **api:** update via SDK Studio ([04fabfd](https://github.com/ContextualAI/contextual-client-python/commit/04fabfd2dd9bc21d5481bbea16148d9300e21196))
* **api:** update via SDK Studio ([feab9f8](https://github.com/ContextualAI/contextual-client-python/commit/feab9f82b627246dbc5592a7ba6bac5de7afd7e1))
* clean up environment call outs ([5aacfd7](https://github.com/ContextualAI/contextual-client-python/commit/5aacfd73cd62e9440b927c74e29bd4ee03766334))
* **client:** add follow_redirects request option ([35e7c78](https://github.com/ContextualAI/contextual-client-python/commit/35e7c78c7d1801a0afe4d73bbff3e7c695f5f19f))
* **client:** add support for aiohttp ([d54f53c](https://github.com/ContextualAI/contextual-client-python/commit/d54f53cfa0878acbad344622f7aae1b2e939ae1c))
* **client:** support file upload requests ([44d064d](https://github.com/ContextualAI/contextual-client-python/commit/44d064d3013ef31ec6cb709682ab5fef4d2ed531))


### Bug Fixes

* **ci:** correct conditional ([0e1ab57](https://github.com/ContextualAI/contextual-client-python/commit/0e1ab57132d5a038aac790b463166200ae436fc3))
* **ci:** release-doctor — report correct token name ([ce0af3b](https://github.com/ContextualAI/contextual-client-python/commit/ce0af3be8b2f90af2bc4e38979a801df1e98e989))
* **client:** correctly parse binary response | stream ([518cbab](https://github.com/ContextualAI/contextual-client-python/commit/518cbabda3ce7f53721c0fc916ae89706899a4ec))
* **client:** don't send Content-Type header on GET requests ([1ba6bcc](https://github.com/ContextualAI/contextual-client-python/commit/1ba6bcc49090112b3ec0dc9a0b1f5c2b487e378e))
* **docs/api:** remove references to nonexistent types ([9fd7133](https://github.com/ContextualAI/contextual-client-python/commit/9fd7133c6748ba1b1676a674da35d57f02f01a86))
* **parsing:** correctly handle nested discriminated unions ([130f4c1](https://github.com/ContextualAI/contextual-client-python/commit/130f4c17f8fbf89a42fa1709d6e4b4a8b36c4036))
* **parsing:** ignore empty metadata ([a81e190](https://github.com/ContextualAI/contextual-client-python/commit/a81e19084356382c7b709215b1462e099d56f2a6))
* **parsing:** parse extra field types ([89f10b3](https://github.com/ContextualAI/contextual-client-python/commit/89f10b3a97483b99e0ec06a346286619faec5c12))
* resolve pydantic violation. ([afcfc1c](https://github.com/ContextualAI/contextual-client-python/commit/afcfc1cb265aa3911164ea727af5de6d965d15a5))
* **tests:** fix: tests which call HTTP endpoints directly with the example parameters ([d7920f1](https://github.com/ContextualAI/contextual-client-python/commit/d7920f111d6175e6714482918e34992fb51739d9))


### Chores

* **ci:** change upload type ([f72dfb7](https://github.com/ContextualAI/contextual-client-python/commit/f72dfb77ff1fcae80efa5b286800ed77af6d0889))
* **ci:** enable for pull requests ([84fbba4](https://github.com/ContextualAI/contextual-client-python/commit/84fbba4c22dbbf8517841c7961a37dba246126dc))
* **ci:** fix installation instructions ([f191464](https://github.com/ContextualAI/contextual-client-python/commit/f191464e75f48395e76d6007712ae8548268b45f))
* **ci:** only run for pushes and fork pull requests ([b9520a0](https://github.com/ContextualAI/contextual-client-python/commit/b9520a0ad9c16d3ad0386ce70a15df4191751364))
* **ci:** upload sdks to package manager ([1f04b9e](https://github.com/ContextualAI/contextual-client-python/commit/1f04b9ecca3a4a3d2235c5cfa21bd9b36a358754))
* **docs:** grammar improvements ([01370fb](https://github.com/ContextualAI/contextual-client-python/commit/01370fb62278f1def879352910c2520102c89993))
* **docs:** remove reference to rye shell ([68f70a8](https://github.com/ContextualAI/contextual-client-python/commit/68f70a88e5b45773140c4b4a02c0506f3d078ad9))
* **docs:** remove unnecessary param examples ([f603dcd](https://github.com/ContextualAI/contextual-client-python/commit/f603dcdd966c77ce3e8b8dba8e878eb273ef1688))
* **internal:** bump pinned h11 dep ([f0aca79](https://github.com/ContextualAI/contextual-client-python/commit/f0aca79b109176c6a83b31434ccdbc30e58f059d))
* **internal:** change ci workflow machines ([9e79111](https://github.com/ContextualAI/contextual-client-python/commit/9e7911165b348e96ad55b6fd7faf8855c009c26f))
* **internal:** codegen related update ([0310d7c](https://github.com/ContextualAI/contextual-client-python/commit/0310d7ce2bca6a80cd3b0d53a1103b4dc1fa8c32))
* **internal:** fix ruff target version ([465af9e](https://github.com/ContextualAI/contextual-client-python/commit/465af9ec69d6456078fb4137b39d1dd33a3f60b2))
* **internal:** update comment in script ([01101c7](https://github.com/ContextualAI/contextual-client-python/commit/01101c7ff8496be98feb71c14eda4b6695cc7331))
* **internal:** update conftest.py ([b324ed3](https://github.com/ContextualAI/contextual-client-python/commit/b324ed373c9c174a44eb52dc6d2384e82c0af4b8))
* **internal:** update examples ([40379a3](https://github.com/ContextualAI/contextual-client-python/commit/40379a3d51aef12b1a0264e515ac145c91e41644))
* **package:** mark python 3.13 as supported ([f37217f](https://github.com/ContextualAI/contextual-client-python/commit/f37217ff20d84d47c9adaf89c14151075e329972))
* **project:** add settings file for vscode ([77265c1](https://github.com/ContextualAI/contextual-client-python/commit/77265c18261b46255146f4a0fd82e2aae41ae160))
* **readme:** fix version rendering on pypi ([5857ef3](https://github.com/ContextualAI/contextual-client-python/commit/5857ef3c8252e39ab66b1dea3e035580d0f2f006))
* **readme:** update badges ([b747f45](https://github.com/ContextualAI/contextual-client-python/commit/b747f452ab31df0805dd07a516fe63c460353c57))
* **tests:** add tests for httpx client instantiation & proxies ([0c4973f](https://github.com/ContextualAI/contextual-client-python/commit/0c4973fed123a77a16b189439b3f4976fcc91770))
* **tests:** run tests in parallel ([f75c912](https://github.com/ContextualAI/contextual-client-python/commit/f75c912ff643028317dde5fb0dfd08470b26ac29))
* **tests:** skip some failing tests on the latest python versions ([dd32830](https://github.com/ContextualAI/contextual-client-python/commit/dd32830a8266dbf736c85285ec611854659511e7))
* update @stainless-api/prism-cli to v5.15.0 ([82c8bc7](https://github.com/ContextualAI/contextual-client-python/commit/82c8bc7b281e624cff3606c46dea4a00ed99cc05))
* update github action ([2d36800](https://github.com/ContextualAI/contextual-client-python/commit/2d36800896a198d92225efa540eb4f0faff092aa))


### Documentation

* **client:** fix httpx.Timeout documentation reference ([3517a3d](https://github.com/ContextualAI/contextual-client-python/commit/3517a3d02c7447c027bc82baf3a83333eb3c9b55))

## 0.7.0 (2025-05-13)

Full Changelog: [v0.6.0...v0.7.0](https://github.com/ContextualAI/contextual-client-python/compare/v0.6.0...v0.7.0)
Expand Down
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ $ rye sync --all-features
You can then run scripts using `rye run python script.py` or by activating the virtual environment:

```sh
$ rye shell
# or manually activate - https://docs.python.org/3/library/venv.html#how-venvs-work
# Activate the virtual environment - https://docs.python.org/3/library/venv.html#how-venvs-work
$ source .venv/bin/activate

# now you can omit the `rye run` prefix
Expand Down
66 changes: 37 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Contextual AI Python API library

[![PyPI version](https://img.shields.io/pypi/v/contextual-client.svg)](https://pypi.org/project/contextual-client/)
<!-- prettier-ignore -->
[![PyPI version](https://img.shields.io/pypi/v/contextual-client.svg?label=pypi%20(stable))](https://pypi.org/project/contextual-client/)

The Contextual AI Python library provides convenient access to the Contextual AI REST API from any Python 3.8+
application. The library includes type definitions for all request params and response fields,
Expand Down Expand Up @@ -66,6 +67,39 @@ asyncio.run(main())

Functionality between the synchronous and asynchronous clients is otherwise identical.

### With aiohttp

By default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.

You can enable this by installing `aiohttp`:

```sh
# install from PyPI
pip install contextual-client[aiohttp]
```

Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:

```python
import asyncio
from contextual import DefaultAioHttpClient
from contextual import AsyncContextualAI


async def main() -> None:
async with AsyncContextualAI(
api_key="My API Key",
http_client=DefaultAioHttpClient(),
) as client:
create_agent_output = await client.agents.create(
name="Example",
)
print(create_agent_output.id)


asyncio.run(main())
```

## Using types

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:
Expand Down Expand Up @@ -149,33 +183,7 @@ client = ContextualAI()

create_agent_output = client.agents.create(
name="xxx",
agent_configs={
"filter_and_rerank_config": {
"rerank_instructions": "rerank_instructions",
"reranker_score_filter_threshold": 0,
"top_k_reranked_chunks": 0,
},
"generate_response_config": {
"avoid_commentary": True,
"calculate_groundedness": True,
"frequency_penalty": 0,
"max_new_tokens": 0,
"seed": 0,
"temperature": 0,
"top_p": 0,
},
"global_config": {
"enable_filter": True,
"enable_multi_turn": True,
"enable_rerank": True,
"should_check_retrieval_need": True,
},
"retrieval_config": {
"lexical_alpha": 0,
"semantic_alpha": 0,
"top_k_retrieved_chunks": 0,
},
},
agent_configs={},
)
print(create_agent_output.agent_configs)
```
Expand Down Expand Up @@ -267,7 +275,7 @@ client.with_options(max_retries=5).agents.create(
### Timeouts

By default requests time out after 1 minute. You can configure this with a `timeout` option,
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:

```python
from contextual import ContextualAI
Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ before making any information public.
## Reporting Non-SDK Related Security Issues

If you encounter security issues that are not directly related to SDKs but pertain to the services
or products provided by Contextual AI please follow the respective company's security reporting guidelines.
or products provided by Contextual AI, please follow the respective company's security reporting guidelines.

### Contextual AI Terms and Policies

Please contact [email protected] for any questions or concerns regarding security of our services.
Please contact [email protected] for any questions or concerns regarding the security of our services.

---

Expand Down
Loading