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
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
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ client = Arcade(
api_key=os.environ.get("ARCADE_API_KEY"),
)

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 @@ -65,13 +65,13 @@ client = AsyncArcade(


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 @@ -104,7 +104,7 @@ from arcadepy import Arcade
client = Arcade()

try:
client.chat.completions(
client.chat.completions.completions(
messages=[
{
"role": "user",
Expand Down Expand Up @@ -154,7 +154,7 @@ client = Arcade(
)

# Or, configure per-request:
client.with_options(max_retries=5).chat.completions(
client.with_options(max_retries=5).chat.completions.completions(
messages=[
{
"role": "user",
Expand Down Expand Up @@ -184,7 +184,7 @@ client = Arcade(
)

# Override per-request:
client.with_options(timeout=5.0).chat.completions(
client.with_options(timeout=5.0).chat.completions.completions(
messages=[
{
"role": "user",
Expand Down Expand Up @@ -230,16 +230,16 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
from arcadepy import Arcade

client = Arcade()
response = client.chat.with_raw_response.completions(
response = client.chat.completions.with_raw_response.completions(
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.completions()` 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 @@ -253,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.completions(
messages=[
{
"role": "user",
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">completions</a>(\*\*<a href="src/arcadepy/types/chat/completion_completions_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>
16 changes: 8 additions & 8 deletions src/arcadepy/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@

class Arcade(SyncAPIClient):
auth: resources.AuthResource
chat: resources.ChatResource
health: resources.HealthResource
chat: resources.ChatResource
tools: resources.ToolsResource
with_raw_response: ArcadeWithRawResponse
with_streaming_response: ArcadeWithStreamedResponse
Expand Down Expand Up @@ -110,8 +110,8 @@ def __init__(
self._idempotency_header = "Idempotency-Key"

self.auth = resources.AuthResource(self)
self.chat = resources.ChatResource(self)
self.health = resources.HealthResource(self)
self.chat = resources.ChatResource(self)
self.tools = resources.ToolsResource(self)
self.with_raw_response = ArcadeWithRawResponse(self)
self.with_streaming_response = ArcadeWithStreamedResponse(self)
Expand Down Expand Up @@ -223,8 +223,8 @@ def _make_status_error(

class AsyncArcade(AsyncAPIClient):
auth: resources.AsyncAuthResource
chat: resources.AsyncChatResource
health: resources.AsyncHealthResource
chat: resources.AsyncChatResource
tools: resources.AsyncToolsResource
with_raw_response: AsyncArcadeWithRawResponse
with_streaming_response: AsyncArcadeWithStreamedResponse
Expand Down Expand Up @@ -286,8 +286,8 @@ def __init__(
self._idempotency_header = "Idempotency-Key"

self.auth = resources.AsyncAuthResource(self)
self.chat = resources.AsyncChatResource(self)
self.health = resources.AsyncHealthResource(self)
self.chat = resources.AsyncChatResource(self)
self.tools = resources.AsyncToolsResource(self)
self.with_raw_response = AsyncArcadeWithRawResponse(self)
self.with_streaming_response = AsyncArcadeWithStreamedResponse(self)
Expand Down Expand Up @@ -400,32 +400,32 @@ def _make_status_error(
class ArcadeWithRawResponse:
def __init__(self, client: Arcade) -> None:
self.auth = resources.AuthResourceWithRawResponse(client.auth)
self.chat = resources.ChatResourceWithRawResponse(client.chat)
self.health = resources.HealthResourceWithRawResponse(client.health)
self.chat = resources.ChatResourceWithRawResponse(client.chat)
self.tools = resources.ToolsResourceWithRawResponse(client.tools)


class AsyncArcadeWithRawResponse:
def __init__(self, client: AsyncArcade) -> None:
self.auth = resources.AsyncAuthResourceWithRawResponse(client.auth)
self.chat = resources.AsyncChatResourceWithRawResponse(client.chat)
self.health = resources.AsyncHealthResourceWithRawResponse(client.health)
self.chat = resources.AsyncChatResourceWithRawResponse(client.chat)
self.tools = resources.AsyncToolsResourceWithRawResponse(client.tools)


class ArcadeWithStreamedResponse:
def __init__(self, client: Arcade) -> None:
self.auth = resources.AuthResourceWithStreamingResponse(client.auth)
self.chat = resources.ChatResourceWithStreamingResponse(client.chat)
self.health = resources.HealthResourceWithStreamingResponse(client.health)
self.chat = resources.ChatResourceWithStreamingResponse(client.chat)
self.tools = resources.ToolsResourceWithStreamingResponse(client.tools)


class AsyncArcadeWithStreamedResponse:
def __init__(self, client: AsyncArcade) -> None:
self.auth = resources.AsyncAuthResourceWithStreamingResponse(client.auth)
self.chat = resources.AsyncChatResourceWithStreamingResponse(client.chat)
self.health = resources.AsyncHealthResourceWithStreamingResponse(client.health)
self.chat = resources.AsyncChatResourceWithStreamingResponse(client.chat)
self.tools = resources.AsyncToolsResourceWithStreamingResponse(client.tools)


Expand Down
12 changes: 6 additions & 6 deletions src/arcadepy/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@
"AsyncAuthResourceWithRawResponse",
"AuthResourceWithStreamingResponse",
"AsyncAuthResourceWithStreamingResponse",
"ChatResource",
"AsyncChatResource",
"ChatResourceWithRawResponse",
"AsyncChatResourceWithRawResponse",
"ChatResourceWithStreamingResponse",
"AsyncChatResourceWithStreamingResponse",
"HealthResource",
"AsyncHealthResource",
"HealthResourceWithRawResponse",
"AsyncHealthResourceWithRawResponse",
"HealthResourceWithStreamingResponse",
"AsyncHealthResourceWithStreamingResponse",
"ChatResource",
"AsyncChatResource",
"ChatResourceWithRawResponse",
"AsyncChatResourceWithRawResponse",
"ChatResourceWithStreamingResponse",
"AsyncChatResourceWithStreamingResponse",
"ToolsResource",
"AsyncToolsResource",
"ToolsResourceWithRawResponse",
Expand Down
24 changes: 19 additions & 5 deletions src/arcadepy/resources/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
async_to_streamed_response_wrapper,
)
from .._base_client import make_request_options
from ..types.authorization_response import AuthorizationResponse
from ..types.shared.authorization_response import AuthorizationResponse

__all__ = ["AuthResource", "AsyncAuthResource"]

Expand Down Expand Up @@ -95,21 +95,27 @@ def status(
*,
authorization_id: str,
scopes: str | NotGiven = NOT_GIVEN,
wait: int | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AuthorizationResponse:
"""
Checks the status of an ongoing authorization process for a specific tool
"""Checks the status of an ongoing authorization process for a specific tool.

If
'wait' param is present, does not respond until either the auth status becomes
completed or the timeout is reached.

Args:
authorization_id: Authorization ID

scopes: Scopes

wait: Timeout in seconds (max 60)

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -129,6 +135,7 @@ def status(
{
"authorization_id": authorization_id,
"scopes": scopes,
"wait": wait,
},
auth_status_params.AuthStatusParams,
),
Expand Down Expand Up @@ -208,21 +215,27 @@ async def status(
*,
authorization_id: str,
scopes: str | NotGiven = NOT_GIVEN,
wait: int | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AuthorizationResponse:
"""
Checks the status of an ongoing authorization process for a specific tool
"""Checks the status of an ongoing authorization process for a specific tool.

If
'wait' param is present, does not respond until either the auth status becomes
completed or the timeout is reached.

Args:
authorization_id: Authorization ID

scopes: Scopes

wait: Timeout in seconds (max 60)

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -242,6 +255,7 @@ async def status(
{
"authorization_id": authorization_id,
"scopes": scopes,
"wait": wait,
},
auth_status_params.AuthStatusParams,
),
Expand Down
Loading