Skip to content
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/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.ARCADE_AI_PYPI_TOKEN || secrets.PYPI_TOKEN }}
PYPI_TOKEN: ${{ secrets.ARCADE_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 @@ -18,4 +18,4 @@ jobs:
run: |
bash ./bin/check-release-environment
env:
PYPI_TOKEN: ${{ secrets.ARCADE_AI_PYPI_TOKEN || secrets.PYPI_TOKEN }}
PYPI_TOKEN: ${{ secrets.ARCADE_PYPI_TOKEN || secrets.PYPI_TOKEN }}
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.1.0-alpha.2"
".": "0.1.0-alpha.3"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 7
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/arcade-ai%2Farcade-engine-2f4d672c34ee530fb7290e2fb799d907aba7d9e47030659422f4e7760625be90.yml
configured_endpoints: 8
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/arcade-ai%2Farcade-engine-e021712a6bf43d1333001852981dae4a2461da7e8285a732f8adfbeb7b6d77c4.yml
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 0.1.0-alpha.3 (2024-10-14)

Full Changelog: [v0.1.0-alpha.2...v0.1.0-alpha.3](https://github.com/ArcadeAI/arcade-py/compare/v0.1.0-alpha.2...v0.1.0-alpha.3)

### Features

* **api:** api update ([#12](https://github.com/ArcadeAI/arcade-py/issues/12)) ([efadea8](https://github.com/ArcadeAI/arcade-py/commit/efadea87ab3842f65b9a042ad00019285199c8ba))
* **api:** api update ([#14](https://github.com/ArcadeAI/arcade-py/issues/14)) ([744e3f3](https://github.com/ArcadeAI/arcade-py/commit/744e3f3ec16f28155847fe0f195ef5b8e620859f))
* **api:** api update ([#15](https://github.com/ArcadeAI/arcade-py/issues/15)) ([4fe706f](https://github.com/ArcadeAI/arcade-py/commit/4fe706f3fb67ea7ec08e0410be1fc42f822d7f45))

## 0.1.0-alpha.2 (2024-10-14)

Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/ArcadeAI/arcade-py/compare/v0.1.0-alpha.1...v0.1.0-alpha.2)
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 Arcade AI
Copyright 2024 Arcade

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

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

The Arcade AI Python library provides convenient access to the Arcade AI REST API from any Python 3.7+
The Arcade Python library provides convenient access to the Arcade 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 @@ -28,22 +28,20 @@ The full API of this library can be found in [api.md](api.md).

```python
import os
from arcadepy import ArcadeAI
from arcadepy import Arcade

client = ArcadeAI(
client = Arcade(
# This is the default and can be omitted
api_key=os.environ.get("ARCADE_API_KEY"),
# defaults to "production".
environment="staging",
)

tool_response = client.tools.execute(
inputs="[object Object]",
response = client.tools.execute(
tool_name="Google.ListEmails",
inputs='{"n_emails": 10}',
tool_version="0.1.0",
user_id="user@example.com",
)
print(tool_response.invocation_id)
print(response.invocation_id)
```

While you can provide an `api_key` keyword argument,
Expand All @@ -53,29 +51,27 @@ so that your API Key is not stored in source control.

## Async usage

Simply import `AsyncArcadeAI` instead of `ArcadeAI` and use `await` with each API call:
Simply import `AsyncArcade` instead of `Arcade` and use `await` with each API call:

```python
import os
import asyncio
from arcadepy import AsyncArcadeAI
from arcadepy import AsyncArcade

client = AsyncArcadeAI(
client = AsyncArcade(
# This is the default and can be omitted
api_key=os.environ.get("ARCADE_API_KEY"),
# defaults to "production".
environment="staging",
)


async def main() -> None:
tool_response = await client.tools.execute(
inputs="[object Object]",
response = await client.tools.execute(
tool_name="Google.ListEmails",
inputs='{"n_emails": 10}',
tool_version="0.1.0",
user_id="user@example.com",
)
print(tool_response.invocation_id)
print(response.invocation_id)


asyncio.run(main())
Expand Down Expand Up @@ -103,12 +99,12 @@ All errors inherit from `arcadepy.APIError`.

```python
import arcadepy
from arcadepy import ArcadeAI
from arcadepy import Arcade

client = ArcadeAI()
client = Arcade()

try:
client.chat.completions(
client.chat.completions.create(
messages=[
{
"role": "user",
Expand Down Expand Up @@ -149,16 +145,16 @@ 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 arcadepy import ArcadeAI
from arcadepy import Arcade

# Configure the default for all requests:
client = ArcadeAI(
client = Arcade(
# default is 2
max_retries=0,
)

# Or, configure per-request:
client.with_options(max_retries=5).chat.completions(
client.with_options(max_retries=5).chat.completions.create(
messages=[
{
"role": "user",
Expand All @@ -174,21 +170,21 @@ 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 arcadepy import ArcadeAI
from arcadepy import Arcade

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

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

# Override per-request:
client.with_options(timeout=5.0).chat.completions(
client.with_options(timeout=5.0).chat.completions.create(
messages=[
{
"role": "user",
Expand All @@ -208,10 +204,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 `ARCADE_AI_LOG` to `debug`.
You can enable logging by setting the environment variable `ARCADE_LOG` to `debug`.

```shell
$ export ARCADE_AI_LOG=debug
$ export ARCADE_LOG=debug
```

### How to tell whether `None` means `null` or missing
Expand All @@ -231,19 +227,19 @@ 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 arcadepy import ArcadeAI
from arcadepy import Arcade

client = ArcadeAI()
response = client.chat.with_raw_response.completions(
client = Arcade()
response = client.chat.completions.with_raw_response.create(
messages=[{
"role": "user",
"content": "Hello, how can I use Arcade AI?",
}],
)
print(response.headers.get('X-My-Header'))

chat = response.parse() # get the object that `chat.completions()` would have returned
print(chat.id)
completion = response.parse() # get the object that `chat.completions.create()` would have returned
print(completion.id)
```

These methods return an [`APIResponse`](https://github.com/ArcadeAI/arcade-py/tree/main/src/arcadepy/_response.py) object.
Expand All @@ -257,7 +253,7 @@ The above interface eagerly reads the full response body when you make the reque
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.

```python
with client.chat.with_streaming_response.completions(
with client.chat.completions.with_streaming_response.create(
messages=[
{
"role": "user",
Expand Down Expand Up @@ -317,10 +313,10 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c
- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality

```python
from arcadepy import ArcadeAI, DefaultHttpxClient
from arcadepy import Arcade, DefaultHttpxClient

client = ArcadeAI(
# Or use the `ARCADE_AI_BASE_URL` env var
client = Arcade(
# Or use the `ARCADE_BASE_URL` env var
base_url="http://my.test.server.example.com:8083",
http_client=DefaultHttpxClient(
proxies="http://my.test.proxy.example.com",
Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ 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 Arcade AI please follow the respective company's security reporting guidelines.
or products provided by Arcade please follow the respective company's security reporting guidelines.

### Arcade AI Terms and Policies
### Arcade Terms and Policies

Please contact contact@arcade-ai.com for any questions or concerns regarding security of our services.

Expand Down
48 changes: 34 additions & 14 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,76 @@
# Shared Types

```python
from arcadepy.types import Error
from arcadepy.types import AuthorizationResponse, Error, ToolDefinition
```

# Auth

Types:

```python
from arcadepy.types import AuthorizationResponse
from arcadepy.types import AuthRequest
```

Methods:

- <code title="post /v1/auth/authorize">client.auth.<a href="./src/arcadepy/resources/auth.py">authorize</a>(\*\*<a href="src/arcadepy/types/auth_authorize_params.py">params</a>) -> <a href="./src/arcadepy/types/authorization_response.py">AuthorizationResponse</a></code>
- <code title="get /v1/auth/status">client.auth.<a href="./src/arcadepy/resources/auth.py">status</a>(\*\*<a href="src/arcadepy/types/auth_status_params.py">params</a>) -> <a href="./src/arcadepy/types/authorization_response.py">AuthorizationResponse</a></code>
- <code title="post /v1/auth/authorize">client.auth.<a href="./src/arcadepy/resources/auth.py">authorize</a>(\*\*<a href="src/arcadepy/types/auth_authorize_params.py">params</a>) -> <a href="./src/arcadepy/types/shared/authorization_response.py">AuthorizationResponse</a></code>
- <code title="get /v1/auth/status">client.auth.<a href="./src/arcadepy/resources/auth.py">status</a>(\*\*<a href="src/arcadepy/types/auth_status_params.py">params</a>) -> <a href="./src/arcadepy/types/shared/authorization_response.py">AuthorizationResponse</a></code>

# Chat
# Health

Types:

```python
from arcadepy.types import ChatMessage, ChatRequest, ChatResponse
from arcadepy.types import HealthSchema
```

Methods:

- <code title="post /v1/chat/completions">client.chat.<a href="./src/arcadepy/resources/chat.py">completions</a>(\*\*<a href="src/arcadepy/types/chat_completions_params.py">params</a>) -> <a href="./src/arcadepy/types/chat_response.py">ChatResponse</a></code>
- <code title="get /v1/health">client.health.<a href="./src/arcadepy/resources/health.py">check</a>() -> <a href="./src/arcadepy/types/health_schema.py">HealthSchema</a></code>

# Health
# Chat

Types:

```python
from arcadepy.types import HealthSchema
from arcadepy.types import ChatMessage, ChatRequest, ChatResponse, Choice, Usage
```

## Completions

Methods:

- <code title="get /v1/health">client.health.<a href="./src/arcadepy/resources/health.py">check</a>() -> <a href="./src/arcadepy/types/health_schema.py">HealthSchema</a></code>
- <code title="post /v1/chat/completions">client.chat.completions.<a href="./src/arcadepy/resources/chat/completions.py">create</a>(\*\*<a href="src/arcadepy/types/chat/completion_create_params.py">params</a>) -> <a href="./src/arcadepy/types/chat_response.py">ChatResponse</a></code>

# Tools

Types:

```python
from arcadepy.types import AuthorizeToolRequest, ExecuteToolRequest, ToolDefinition, ToolResponse
from arcadepy.types import (
AuthorizeToolRequest,
ExecuteToolRequest,
Inputs,
Output,
Parameter,
Requirements,
Response,
ResponseOutput,
ToolkitDefinition,
ValueSchema,
ToolListResponse,
)
```

Methods:

- <code title="post /v1/tools/authorize">client.tools.<a href="./src/arcadepy/resources/tools.py">authorize</a>(\*\*<a href="src/arcadepy/types/tool_authorize_params.py">params</a>) -> <a href="./src/arcadepy/types/authorization_response.py">AuthorizationResponse</a></code>
- <code title="post /v1/tools/execute">client.tools.<a href="./src/arcadepy/resources/tools.py">execute</a>(\*\*<a href="src/arcadepy/types/tool_execute_params.py">params</a>) -> <a href="./src/arcadepy/types/tool_response.py">ToolResponse</a></code>
- <code title="get /v1/tools/definition">client.tools.<a href="./src/arcadepy/resources/tools.py">retrieve_definition</a>(\*\*<a href="src/arcadepy/types/tool_retrieve_definition_params.py">params</a>) -> <a href="./src/arcadepy/types/tool_definition.py">ToolDefinition</a></code>
- <code title="get /v1/tools/list">client.tools.<a href="./src/arcadepy/resources/tools/tools.py">list</a>(\*\*<a href="src/arcadepy/types/tool_list_params.py">params</a>) -> <a href="./src/arcadepy/types/tool_list_response.py">ToolListResponse</a></code>
- <code title="post /v1/tools/authorize">client.tools.<a href="./src/arcadepy/resources/tools/tools.py">authorize</a>(\*\*<a href="src/arcadepy/types/tool_authorize_params.py">params</a>) -> <a href="./src/arcadepy/types/shared/authorization_response.py">AuthorizationResponse</a></code>
- <code title="post /v1/tools/execute">client.tools.<a href="./src/arcadepy/resources/tools/tools.py">execute</a>(\*\*<a href="src/arcadepy/types/tool_execute_params.py">params</a>) -> <a href="./src/arcadepy/types/response.py">Response</a></code>

## Definition

Methods:

- <code title="get /v1/tools/definition">client.tools.definition.<a href="./src/arcadepy/resources/tools/definition.py">get</a>(\*\*<a href="src/arcadepy/types/tools/definition_get_params.py">params</a>) -> <a href="./src/arcadepy/types/shared/tool_definition.py">ToolDefinition</a></code>
2 changes: 1 addition & 1 deletion bin/check-release-environment
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
errors=()

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

lenErrors=${#errors[@]}
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[project]
name = "arcadepy"
version = "0.1.0-alpha.2"
description = "The official Python library for the Arcade AI API"
version = "0.1.0-alpha.3"
description = "The official Python library for the Arcade API"
dynamic = ["readme"]
license = "Apache-2.0"
authors = [
{ name = "Arcade AI", email = "contact@arcade-ai.com" },
{ name = "Arcade", email = "contact@arcade-ai.com" },
]
dependencies = [
"httpx>=0.23.0, <1",
Expand Down
Loading
Loading