Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): update via SDK Studio #8

Merged
merged 1 commit into from
Mar 26, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:

- name: Ensure importable
run: |
rye run python -c 'import retell_sdk'
rye run python -c 'import retell'
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
run: |
bash ./bin/publish-pypi
env:
PYPI_TOKEN: ${{ secrets.RETELL_SDK_PYPI_TOKEN || secrets.PYPI_TOKEN }}
PYPI_TOKEN: ${{ secrets.RETELL_PYPI_TOKEN || secrets.PYPI_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
run: |
bash ./bin/check-release-environment
env:
PYPI_TOKEN: ${{ secrets.RETELL_SDK_PYPI_TOKEN || secrets.PYPI_TOKEN }}
PYPI_TOKEN: ${{ secrets.RETELL_PYPI_TOKEN || secrets.PYPI_TOKEN }}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ $ pip install -r requirements-dev.lock
## Modifying/Adding code

Most of the SDK is generated code, and any modified code will be overridden on the next generation. The
`src/retell_sdk/lib/` and `examples/` directories are exceptions and will never be overridden.
`src/retell/lib/` and `examples/` directories are exceptions and will never be overridden.

## Adding and running examples

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2024 Retell Sdk
Copyright 2024 Retell

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
60 changes: 30 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Retell Sdk Python API library
# Retell Python API library

[![PyPI version](https://img.shields.io/pypi/v/retell-sdk.svg)](https://pypi.org/project/retell-sdk/)

The Retell Sdk Python library provides convenient access to the Retell Sdk REST API from any Python 3.7+
The Retell Python library provides convenient access to the Retell REST API from any Python 3.7+
application. The library includes type definitions for all request params and response fields,
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).

Expand All @@ -25,9 +25,9 @@ The full API of this library can be found in [api.md](api.md).

```python
import os
from retell_sdk import RetellSdk
from retell import Retell

client = RetellSdk(
client = Retell(
# This is the default and can be omitted
api_key=os.environ.get("RETELL_API_KEY"),
)
Expand All @@ -46,14 +46,14 @@ so that your API Key is not stored in source control.

## Async usage

Simply import `AsyncRetellSdk` instead of `RetellSdk` and use `await` with each API call:
Simply import `AsyncRetell` instead of `Retell` and use `await` with each API call:

```python
import os
import asyncio
from retell_sdk import AsyncRetellSdk
from retell import AsyncRetell

client = AsyncRetellSdk(
client = AsyncRetell(
# This is the default and can be omitted
api_key=os.environ.get("RETELL_API_KEY"),
)
Expand Down Expand Up @@ -83,30 +83,30 @@ Typed requests and responses provide autocomplete and documentation within your

## Handling errors

When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `retell_sdk.APIConnectionError` is raised.
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `retell.APIConnectionError` is raised.

When the API returns a non-success status code (that is, 4xx or 5xx
response), a subclass of `retell_sdk.APIStatusError` is raised, containing `status_code` and `response` properties.
response), a subclass of `retell.APIStatusError` is raised, containing `status_code` and `response` properties.

All errors inherit from `retell_sdk.APIError`.
All errors inherit from `retell.APIError`.

```python
import retell_sdk
from retell_sdk import RetellSdk
import retell
from retell import Retell

client = RetellSdk()
client = Retell()

try:
client.agent.create(
llm_websocket_url="wss://your-websocket-endpoint",
voice_id="11labs-Adrian",
)
except retell_sdk.APIConnectionError as e:
except retell.APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
except retell_sdk.RateLimitError as e:
except retell.RateLimitError as e:
print("A 429 status code was received; we should back off a bit.")
except retell_sdk.APIStatusError as e:
except retell.APIStatusError as e:
print("Another non-200-range status code was received")
print(e.status_code)
print(e.response)
Expand Down Expand Up @@ -134,10 +134,10 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ
You can use the `max_retries` option to configure or disable retry settings:

```python
from retell_sdk import RetellSdk
from retell import Retell

# Configure the default for all requests:
client = RetellSdk(
client = Retell(
# default is 2
max_retries=0,
)
Expand All @@ -155,16 +155,16 @@ By default requests time out after 1 minute. You can configure this with a `time
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:

```python
from retell_sdk import RetellSdk
from retell import Retell

# Configure the default for all requests:
client = RetellSdk(
client = Retell(
# 20 seconds (default is 1 minute)
timeout=20.0,
)

# More granular control:
client = RetellSdk(
client = Retell(
timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),
)

Expand All @@ -185,10 +185,10 @@ Note that requests that time out are [retried twice by default](#retries).

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

You can enable logging by setting the environment variable `RETELL_SDK_LOG` to `debug`.
You can enable logging by setting the environment variable `RETELL_LOG` to `debug`.

```shell
$ export RETELL_SDK_LOG=debug
$ export RETELL_LOG=debug
```

### How to tell whether `None` means `null` or missing
Expand All @@ -208,9 +208,9 @@ if response.my_field is None:
The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,

```py
from retell_sdk import RetellSdk
from retell import Retell

client = RetellSdk()
client = Retell()
response = client.agent.with_raw_response.create(
llm_websocket_url="wss://your-websocket-endpoint",
voice_id="11labs-Adrian",
Expand All @@ -221,9 +221,9 @@ agent = response.parse() # get the object that `agent.create()` would have retu
print(agent.agent_id)
```

These methods return an [`APIResponse`](https://github.com/RetellAI/retell-python-sdk/tree/main/src/retell_sdk/_response.py) object.
These methods return an [`APIResponse`](https://github.com/RetellAI/retell-python-sdk/tree/main/src/retell/_response.py) object.

The async client returns an [`AsyncAPIResponse`](https://github.com/RetellAI/retell-python-sdk/tree/main/src/retell_sdk/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
The async client returns an [`AsyncAPIResponse`](https://github.com/RetellAI/retell-python-sdk/tree/main/src/retell/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.

#### `.with_streaming_response`

Expand Down Expand Up @@ -289,10 +289,10 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c

```python
import httpx
from retell_sdk import RetellSdk
from retell import Retell

client = RetellSdk(
# Or use the `RETELL_SDK_BASE_URL` env var
client = Retell(
# Or use the `RETELL_BASE_URL` env var
base_url="http://my.test.server.example.com:8083",
http_client=httpx.Client(
proxies="http://my.test.proxy.example.com",
Expand Down
46 changes: 23 additions & 23 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Types:

```python
from retell_sdk.types import (
from retell.types import (
CallDetailResponse,
CallCreateResponse,
CallListResponse,
Expand All @@ -13,55 +13,55 @@ from retell_sdk.types import (

Methods:

- <code title="post /create-phone-call">client.call.<a href="./src/retell_sdk/resources/call.py">create</a>(\*\*<a href="src/retell_sdk/types/call_create_params.py">params</a>) -> <a href="./src/retell_sdk/types/call_create_response.py">CallCreateResponse</a></code>
- <code title="get /get-call/{call_id}">client.call.<a href="./src/retell_sdk/resources/call.py">retrieve</a>(call_id) -> <a href="./src/retell_sdk/types/call_detail_response.py">CallDetailResponse</a></code>
- <code title="get /list-calls">client.call.<a href="./src/retell_sdk/resources/call.py">list</a>(\*\*<a href="src/retell_sdk/types/call_list_params.py">params</a>) -> <a href="./src/retell_sdk/types/call_list_response.py">CallListResponse</a></code>
- <code title="post /register-call">client.call.<a href="./src/retell_sdk/resources/call.py">register</a>(\*\*<a href="src/retell_sdk/types/call_register_params.py">params</a>) -> <a href="./src/retell_sdk/types/call_register_response.py">CallRegisterResponse</a></code>
- <code title="post /create-phone-call">client.call.<a href="./src/retell/resources/call.py">create</a>(\*\*<a href="src/retell/types/call_create_params.py">params</a>) -> <a href="./src/retell/types/call_create_response.py">CallCreateResponse</a></code>
- <code title="get /get-call/{call_id}">client.call.<a href="./src/retell/resources/call.py">retrieve</a>(call_id) -> <a href="./src/retell/types/call_detail_response.py">CallDetailResponse</a></code>
- <code title="get /list-calls">client.call.<a href="./src/retell/resources/call.py">list</a>(\*\*<a href="src/retell/types/call_list_params.py">params</a>) -> <a href="./src/retell/types/call_list_response.py">CallListResponse</a></code>
- <code title="post /register-call">client.call.<a href="./src/retell/resources/call.py">register</a>(\*\*<a href="src/retell/types/call_register_params.py">params</a>) -> <a href="./src/retell/types/call_register_response.py">CallRegisterResponse</a></code>

# PhoneNumber

Types:

```python
from retell_sdk.types import PhoneNumberResponse, PhoneNumberListResponse
from retell.types import PhoneNumberResponse, PhoneNumberListResponse
```

Methods:

- <code title="post /create-phone-number">client.phone_number.<a href="./src/retell_sdk/resources/phone_number.py">create</a>(\*\*<a href="src/retell_sdk/types/phone_number_create_params.py">params</a>) -> <a href="./src/retell_sdk/types/phone_number_response.py">PhoneNumberResponse</a></code>
- <code title="get /get-phone-number/{phone_number}">client.phone_number.<a href="./src/retell_sdk/resources/phone_number.py">retrieve</a>(phone_number) -> <a href="./src/retell_sdk/types/phone_number_response.py">PhoneNumberResponse</a></code>
- <code title="patch /update-phone-number/{phone_number}">client.phone_number.<a href="./src/retell_sdk/resources/phone_number.py">update</a>(phone_number, \*\*<a href="src/retell_sdk/types/phone_number_update_params.py">params</a>) -> <a href="./src/retell_sdk/types/phone_number_response.py">PhoneNumberResponse</a></code>
- <code title="get /list-phone-numbers">client.phone_number.<a href="./src/retell_sdk/resources/phone_number.py">list</a>() -> <a href="./src/retell_sdk/types/phone_number_list_response.py">PhoneNumberListResponse</a></code>
- <code title="delete /delete-phone-number/{phone_number}">client.phone_number.<a href="./src/retell_sdk/resources/phone_number.py">delete</a>(phone_number) -> None</code>
- <code title="post /create-phone-number">client.phone_number.<a href="./src/retell/resources/phone_number.py">create</a>(\*\*<a href="src/retell/types/phone_number_create_params.py">params</a>) -> <a href="./src/retell/types/phone_number_response.py">PhoneNumberResponse</a></code>
- <code title="get /get-phone-number/{phone_number}">client.phone_number.<a href="./src/retell/resources/phone_number.py">retrieve</a>(phone_number) -> <a href="./src/retell/types/phone_number_response.py">PhoneNumberResponse</a></code>
- <code title="patch /update-phone-number/{phone_number}">client.phone_number.<a href="./src/retell/resources/phone_number.py">update</a>(phone_number, \*\*<a href="src/retell/types/phone_number_update_params.py">params</a>) -> <a href="./src/retell/types/phone_number_response.py">PhoneNumberResponse</a></code>
- <code title="get /list-phone-numbers">client.phone_number.<a href="./src/retell/resources/phone_number.py">list</a>() -> <a href="./src/retell/types/phone_number_list_response.py">PhoneNumberListResponse</a></code>
- <code title="delete /delete-phone-number/{phone_number}">client.phone_number.<a href="./src/retell/resources/phone_number.py">delete</a>(phone_number) -> None</code>

# Agent

Types:

```python
from retell_sdk.types import AgentResponse, AgentListResponse
from retell.types import AgentResponse, AgentListResponse
```

Methods:

- <code title="post /create-agent">client.agent.<a href="./src/retell_sdk/resources/agent.py">create</a>(\*\*<a href="src/retell_sdk/types/agent_create_params.py">params</a>) -> <a href="./src/retell_sdk/types/agent_response.py">AgentResponse</a></code>
- <code title="get /get-agent/{agent_id}">client.agent.<a href="./src/retell_sdk/resources/agent.py">retrieve</a>(agent_id) -> <a href="./src/retell_sdk/types/agent_response.py">AgentResponse</a></code>
- <code title="patch /update-agent/{agent_id}">client.agent.<a href="./src/retell_sdk/resources/agent.py">update</a>(agent_id, \*\*<a href="src/retell_sdk/types/agent_update_params.py">params</a>) -> <a href="./src/retell_sdk/types/agent_response.py">AgentResponse</a></code>
- <code title="get /list-agents">client.agent.<a href="./src/retell_sdk/resources/agent.py">list</a>() -> <a href="./src/retell_sdk/types/agent_list_response.py">AgentListResponse</a></code>
- <code title="delete /delete-agent/{agent_id}">client.agent.<a href="./src/retell_sdk/resources/agent.py">delete</a>(agent_id) -> None</code>
- <code title="post /create-agent">client.agent.<a href="./src/retell/resources/agent.py">create</a>(\*\*<a href="src/retell/types/agent_create_params.py">params</a>) -> <a href="./src/retell/types/agent_response.py">AgentResponse</a></code>
- <code title="get /get-agent/{agent_id}">client.agent.<a href="./src/retell/resources/agent.py">retrieve</a>(agent_id) -> <a href="./src/retell/types/agent_response.py">AgentResponse</a></code>
- <code title="patch /update-agent/{agent_id}">client.agent.<a href="./src/retell/resources/agent.py">update</a>(agent_id, \*\*<a href="src/retell/types/agent_update_params.py">params</a>) -> <a href="./src/retell/types/agent_response.py">AgentResponse</a></code>
- <code title="get /list-agents">client.agent.<a href="./src/retell/resources/agent.py">list</a>() -> <a href="./src/retell/types/agent_list_response.py">AgentListResponse</a></code>
- <code title="delete /delete-agent/{agent_id}">client.agent.<a href="./src/retell/resources/agent.py">delete</a>(agent_id) -> None</code>

# Llm

Types:

```python
from retell_sdk.types import LlmResponse, LlmListResponse
from retell.types import LlmResponse, LlmListResponse
```

Methods:

- <code title="post /create-retell-llm">client.llm.<a href="./src/retell_sdk/resources/llm.py">create</a>(\*\*<a href="src/retell_sdk/types/llm_create_params.py">params</a>) -> <a href="./src/retell_sdk/types/llm_response.py">LlmResponse</a></code>
- <code title="get /get-retell-llm/{llm_id}">client.llm.<a href="./src/retell_sdk/resources/llm.py">retrieve</a>(llm_id) -> <a href="./src/retell_sdk/types/llm_response.py">LlmResponse</a></code>
- <code title="patch /update-retell-llm/{llm_id}">client.llm.<a href="./src/retell_sdk/resources/llm.py">update</a>(llm_id, \*\*<a href="src/retell_sdk/types/llm_update_params.py">params</a>) -> <a href="./src/retell_sdk/types/llm_response.py">LlmResponse</a></code>
- <code title="get /list-retell-llms">client.llm.<a href="./src/retell_sdk/resources/llm.py">list</a>() -> <a href="./src/retell_sdk/types/llm_list_response.py">LlmListResponse</a></code>
- <code title="delete /delete-retell-llm/{llm_id}">client.llm.<a href="./src/retell_sdk/resources/llm.py">delete</a>(llm_id) -> None</code>
- <code title="post /create-retell-llm">client.llm.<a href="./src/retell/resources/llm.py">create</a>(\*\*<a href="src/retell/types/llm_create_params.py">params</a>) -> <a href="./src/retell/types/llm_response.py">LlmResponse</a></code>
- <code title="get /get-retell-llm/{llm_id}">client.llm.<a href="./src/retell/resources/llm.py">retrieve</a>(llm_id) -> <a href="./src/retell/types/llm_response.py">LlmResponse</a></code>
- <code title="patch /update-retell-llm/{llm_id}">client.llm.<a href="./src/retell/resources/llm.py">update</a>(llm_id, \*\*<a href="src/retell/types/llm_update_params.py">params</a>) -> <a href="./src/retell/types/llm_response.py">LlmResponse</a></code>
- <code title="get /list-retell-llms">client.llm.<a href="./src/retell/resources/llm.py">list</a>() -> <a href="./src/retell/types/llm_list_response.py">LlmListResponse</a></code>
- <code title="delete /delete-retell-llm/{llm_id}">client.llm.<a href="./src/retell/resources/llm.py">delete</a>(llm_id) -> None</code>
2 changes: 1 addition & 1 deletion bin/check-release-environment
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ warnings=()
errors=()

if [ -z "${PYPI_TOKEN}" ]; then
warnings+=("The RETELL_SDK_PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.")
warnings+=("The RETELL_PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.")
fi

lenWarnings=${#warnings[@]}
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ show_error_codes = True
# Exclude _files.py because mypy isn't smart enough to apply
# the correct type narrowing and as this is an internal module
# it's fine to just use Pyright.
exclude = ^(src/retell_sdk/_files\.py|_dev/.*\.py)$
exclude = ^(src/retell/_files\.py|_dev/.*\.py)$

strict_equality = True
implicit_reexport = True
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[project]
name = "retell-sdk"
version = "0.1.0-alpha.2"
description = "The official Python library for the retell-sdk API"
description = "The official Python library for the retell API"
readme = "README.md"
license = "Apache-2.0"
authors = [
{ name = "Retell Sdk", email = "founders@retellai.com" },
{ name = "Retell", email = "founders@retellai.com" },
]
dependencies = [
"httpx>=0.23.0, <1",
Expand Down Expand Up @@ -84,7 +84,7 @@ typecheck = { chain = [
"typecheck:mypy"
]}
"typecheck:pyright" = "pyright"
"typecheck:verify-types" = "pyright --verifytypes retell_sdk --ignoreexternal"
"typecheck:verify-types" = "pyright --verifytypes retell --ignoreexternal"
"typecheck:mypy" = "mypy ."

[build-system]
Expand All @@ -97,7 +97,7 @@ include = [
]

[tool.hatch.build.targets.wheel]
packages = ["src/retell_sdk"]
packages = ["src/retell"]

[tool.black]
line-length = 120
Expand Down Expand Up @@ -171,7 +171,7 @@ length-sort = true
length-sort-straight = true
combine-as-imports = true
extra-standard-library = ["typing_extensions"]
known-first-party = ["retell_sdk", "tests"]
known-first-party = ["retell", "tests"]

[tool.ruff.per-file-ignores]
"bin/**.py" = ["T201", "T203"]
Expand Down
2 changes: 1 addition & 1 deletion release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@
],
"release-type": "python",
"extra-files": [
"src/retell_sdk/_version.py"
"src/retell/_version.py"
]
}
Loading