Updates for arcadepy1.0.0rc Compatibility (#209)

# PR Description
arcadepy version 1.0.0rc renamed `AuthorizationResponse` to
`AuthAuthorizationResponse`
This commit is contained in:
Eric Gustin 2025-01-17 09:26:11 -08:00 committed by GitHub
parent e9d630f5dc
commit 3f9da98560
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 11 deletions

View file

@ -7,7 +7,7 @@ from typing import Any, Optional
import typer import typer
from arcadepy import Arcade from arcadepy import Arcade
from arcadepy.types import AuthorizationResponse from arcadepy.types import AuthAuthorizationResponse
from openai import OpenAI, OpenAIError from openai import OpenAI, OpenAIError
from rich.console import Console from rich.console import Console
from rich.markup import escape from rich.markup import escape
@ -271,7 +271,7 @@ def chat(
if tool_authorization and is_authorization_pending(tool_authorization): if tool_authorization and is_authorization_pending(tool_authorization):
chat_result = handle_tool_authorization( chat_result = handle_tool_authorization(
client, client,
AuthorizationResponse.model_validate(tool_authorization), AuthAuthorizationResponse.model_validate(tool_authorization),
history, history,
openai_client, openai_client,
model, model,

View file

@ -12,7 +12,7 @@ from urllib.parse import urlencode, urlparse
import idna import idna
import typer import typer
from arcadepy import NOT_GIVEN, APIConnectionError, APIStatusError, APITimeoutError, Arcade from arcadepy import NOT_GIVEN, APIConnectionError, APIStatusError, APITimeoutError, Arcade
from arcadepy.types import AuthorizationResponse from arcadepy.types import AuthAuthorizationResponse
from openai import OpenAI from openai import OpenAI
from openai.resources.chat.completions import ChatCompletionChunk, Stream from openai.resources.chat.completions import ChatCompletionChunk, Stream
from openai.types.chat.chat_completion import Choice as ChatCompletionChoice from openai.types.chat.chat_completion import Choice as ChatCompletionChoice
@ -404,7 +404,7 @@ def handle_chat_interaction(
def handle_tool_authorization( def handle_tool_authorization(
arcade_client: Arcade, arcade_client: Arcade,
tool_authorization: AuthorizationResponse, tool_authorization: AuthAuthorizationResponse,
history: list[dict[str, Any]], history: list[dict[str, Any]],
openai_client: OpenAI, openai_client: OpenAI,
model: str, model: str,
@ -412,8 +412,8 @@ def handle_tool_authorization(
stream: bool, stream: bool,
) -> ChatInteractionResult: ) -> ChatInteractionResult:
with Live(console=console, refresh_per_second=4) as live: with Live(console=console, refresh_per_second=4) as live:
if tool_authorization.url: # type: ignore[attr-defined] if tool_authorization.url:
authorization_url = str(tool_authorization.url) # type: ignore[attr-defined] authorization_url = str(tool_authorization.url)
webbrowser.open(authorization_url) webbrowser.open(authorization_url)
message = ( message = (
"You'll need to authorize this action in your browser.\n\n" "You'll need to authorize this action in your browser.\n\n"
@ -432,7 +432,7 @@ def handle_tool_authorization(
def wait_for_authorization_completion( def wait_for_authorization_completion(
client: Arcade, tool_authorization: AuthorizationResponse | None client: Arcade, tool_authorization: AuthAuthorizationResponse | None
) -> None: ) -> None:
""" """
Wait for the authorization for a tool call to complete i.e., wait for the user to click on Wait for the authorization for a tool call to complete i.e., wait for the user to click on
@ -441,13 +441,12 @@ def wait_for_authorization_completion(
if tool_authorization is None: if tool_authorization is None:
return return
auth_response = AuthorizationResponse.model_validate(tool_authorization) auth_response = AuthAuthorizationResponse.model_validate(tool_authorization)
while auth_response.status != "completed": while auth_response.status != "completed":
try: try:
auth_response = client.auth.status( auth_response = client.auth.status(
authorization_id=cast(str, auth_response.id), # type: ignore[attr-defined] id=cast(str, auth_response.id),
scopes=" ".join(auth_response.scopes) if auth_response.scopes else NOT_GIVEN,
wait=59, wait=59,
) )
except APITimeoutError: except APITimeoutError:

View file

@ -23,7 +23,7 @@ toml = "^0.10.2"
pyyaml = "^6.0" pyyaml = "^6.0"
tomlkit = "^0.12.4" tomlkit = "^0.12.4"
openai = "^1.36.0" # TODO: relax to an earlier version that still has what we need openai = "^1.36.0" # TODO: relax to an earlier version that still has what we need
arcadepy = "~0.2.0" arcadepy = "1.0.0rc1"
pyjwt = "^2.8.0" pyjwt = "^2.8.0"
loguru = "^0.7.0" loguru = "^0.7.0"
tqdm = "^4.1.0" tqdm = "^4.1.0"