Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"cliVersion": "3.86.0",
"generatorName": "fernapi/fern-python-sdk",
"generatorVersion": "4.59.0",
"generatorVersion": "4.59.4",
"generatorConfig": {
"client_class_name": "Captain"
},
"sdkVersion": "0.0.0"
"sdkVersion": "0.0.16"
}
58 changes: 40 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The Runcaptain Python library provides convenient access to the Runcaptain APIs
- [Usage](#usage)
- [Async Client](#async-client)
- [Exception Handling](#exception-handling)
- [Streaming](#streaming)
- [Advanced](#advanced)
- [Access Raw Response Data](#access-raw-response-data)
- [Retries](#retries)
Expand All @@ -37,15 +38,11 @@ Instantiate and use the client with the following:
from runcaptain import Captain

client = Captain(
authorization="YOUR_AUTHORIZATION",
organization_id="YOUR_ORGANIZATION_ID",
key="YOUR_KEY",
)
client.query.collection_v2(
collection_name="my_documents",
query="What are the key terms in the contract?",
inference=True,
stream=True,
rerank=True,
client.post_v2collections_collection_name_documents_wipe(
collection_name="collection_name",
)
```

Expand All @@ -59,18 +56,14 @@ import asyncio
from runcaptain import AsyncCaptain

client = AsyncCaptain(
authorization="YOUR_AUTHORIZATION",
organization_id="YOUR_ORGANIZATION_ID",
key="YOUR_KEY",
)


async def main() -> None:
await client.query.collection_v2(
collection_name="my_documents",
query="What are the key terms in the contract?",
inference=True,
stream=True,
rerank=True,
await client.post_v2collections_collection_name_documents_wipe(
collection_name="collection_name",
)


Expand All @@ -86,12 +79,31 @@ will be thrown.
from runcaptain.core.api_error import ApiError

try:
client.query.collection_v2(...)
client.post_v2collections_collection_name_documents_wipe(...)
except ApiError as e:
print(e.status_code)
print(e.body)
```

## Streaming

The SDK supports streaming responses, as well, the response will be a generator that you can loop over.

```python
from runcaptain import Captain

client = Captain(
organization_id="YOUR_ORGANIZATION_ID",
key="YOUR_KEY",
)
response = client.query.collection_v2stream(
collection_name="collection_name",
query="query",
)
for chunk in response.data:
yield chunk
```

## Advanced

### Access Raw Response Data
Expand All @@ -105,10 +117,20 @@ from runcaptain import Captain
client = Captain(
...,
)
response = client.query.with_raw_response.collection_v2(...)
response = (
client.with_raw_response.post_v2collections_collection_name_documents_wipe(
...
)
)
print(response.headers) # access the response headers
print(response.status_code) # access the response status code
print(response.data) # access the underlying object
with client.query.with_raw_response.collection_v2stream(...) as response:
print(
response.headers
) # access the response headersprint(response.status_code) # access the response status code
for chunk in response.data:
print(chunk) # access the underlying object(s)
```

### Retries
Expand All @@ -126,7 +148,7 @@ A request is deemed retryable when any of the following HTTP status codes is ret
Use the `max_retries` request option to configure this behavior.

```python
client.query.collection_v2(..., request_options={
client.post_v2collections_collection_name_documents_wipe(..., request_options={
"max_retries": 1
})
```
Expand All @@ -146,7 +168,7 @@ client = Captain(


# Override timeout for a specific method
client.query.collection_v2(..., request_options={
client.post_v2collections_collection_name_documents_wipe(..., request_options={
"timeout_in_seconds": 1
})
```
Expand Down
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dynamic = ["version"]

[tool.poetry]
name = "captain-sdk"
version = "0.0.0"
version = "0.0.16"
description = ""
readme = "README.md"
authors = []
Expand Down
Loading