Use AuthorizationResponse and ToolDefinition (#221)
This commit is contained in:
parent
66e54d7cde
commit
6fb45c8797
7 changed files with 15 additions and 15 deletions
|
|
@ -7,7 +7,7 @@ from typing import Any, Optional
|
|||
|
||||
import typer
|
||||
from arcadepy import Arcade
|
||||
from arcadepy.types import AuthAuthorizationResponse
|
||||
from arcadepy.types import AuthorizationResponse
|
||||
from openai import OpenAI, OpenAIError
|
||||
from rich.console import Console
|
||||
from rich.markup import escape
|
||||
|
|
@ -269,7 +269,7 @@ def chat(
|
|||
if tool_authorization and is_authorization_pending(tool_authorization):
|
||||
chat_result = handle_tool_authorization(
|
||||
client,
|
||||
AuthAuthorizationResponse.model_validate(tool_authorization),
|
||||
AuthorizationResponse.model_validate(tool_authorization),
|
||||
history,
|
||||
openai_client,
|
||||
model,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from urllib.parse import urlencode, urlparse
|
|||
import idna
|
||||
import typer
|
||||
from arcadepy import NOT_GIVEN, APIConnectionError, APIStatusError, APITimeoutError, Arcade
|
||||
from arcadepy.types import AuthAuthorizationResponse
|
||||
from arcadepy.types import AuthorizationResponse
|
||||
from openai import OpenAI
|
||||
from openai.resources.chat.completions import ChatCompletionChunk, Stream
|
||||
from openai.types.chat.chat_completion import Choice as ChatCompletionChoice
|
||||
|
|
@ -404,7 +404,7 @@ def handle_chat_interaction(
|
|||
|
||||
def handle_tool_authorization(
|
||||
arcade_client: Arcade,
|
||||
tool_authorization: AuthAuthorizationResponse,
|
||||
tool_authorization: AuthorizationResponse,
|
||||
history: list[dict[str, Any]],
|
||||
openai_client: OpenAI,
|
||||
model: str,
|
||||
|
|
@ -432,7 +432,7 @@ def handle_tool_authorization(
|
|||
|
||||
|
||||
def wait_for_authorization_completion(
|
||||
client: Arcade, tool_authorization: AuthAuthorizationResponse | None
|
||||
client: Arcade, tool_authorization: AuthorizationResponse | None
|
||||
) -> None:
|
||||
"""
|
||||
Wait for the authorization for a tool call to complete i.e., wait for the user to click on
|
||||
|
|
@ -441,7 +441,7 @@ def wait_for_authorization_completion(
|
|||
if tool_authorization is None:
|
||||
return
|
||||
|
||||
auth_response = AuthAuthorizationResponse.model_validate(tool_authorization)
|
||||
auth_response = AuthorizationResponse.model_validate(tool_authorization)
|
||||
|
||||
while auth_response.status != "completed":
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ rich = "^13.7.1"
|
|||
Jinja2 = ">=3.1.5,<4.0.0"
|
||||
pyyaml = "^6.0"
|
||||
openai = "^1.36.0" # TODO: relax to an earlier version that still has what we need
|
||||
arcadepy = "1.0.0rc1"
|
||||
arcadepy = "^1.0.0"
|
||||
pyjwt = "^2.8.0"
|
||||
loguru = "^0.7.0"
|
||||
tqdm = "^4.1.0"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from typing import Any, Callable
|
||||
|
||||
from arcadepy import NOT_GIVEN, Arcade
|
||||
from arcadepy.types import ToolGetResponse as ToolDefinition
|
||||
from arcadepy.types import ToolDefinition
|
||||
from langchain_core.runnables import RunnableConfig
|
||||
from langchain_core.tools import StructuredTool
|
||||
from pydantic import BaseModel, Field, create_model
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ from collections.abc import Iterator
|
|||
from typing import Any, Optional
|
||||
|
||||
from arcadepy import Arcade
|
||||
from arcadepy.types import ToolGetResponse as ToolDefinition
|
||||
from arcadepy.types.shared import AuthAuthorizationResponse as AuthorizationResponse
|
||||
from arcadepy.types import ToolDefinition
|
||||
from arcadepy.types.shared import AuthorizationResponse
|
||||
from langchain_core.tools import StructuredTool
|
||||
|
||||
from langchain_arcade._utilities import (
|
||||
|
|
@ -188,7 +188,7 @@ class ArcadeToolManager:
|
|||
# First, gather single tools if the user specifically requested them.
|
||||
if tools:
|
||||
for tool_id in tools:
|
||||
# ToolsResource.get(...) returns a single ToolGetResponse.
|
||||
# ToolsResource.get(...) returns a single ToolDefinition.
|
||||
single_tool = self.client.tools.get(name=tool_id)
|
||||
all_tools.append(single_tool)
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ license = "MIT"
|
|||
[tool.poetry.dependencies]
|
||||
python = ">=3.10,<3.13"
|
||||
langchain-core = "^0.3.0"
|
||||
arcadepy = "~1.0.0rc1"
|
||||
arcadepy = "^1.0.0"
|
||||
langgraph = {version = ">=0.2.32,<0.3.0", optional = true}
|
||||
|
||||
[tool.poetry.extras]
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ from unittest.mock import MagicMock
|
|||
|
||||
import pytest
|
||||
from arcadepy.pagination import SyncOffsetPage
|
||||
from arcadepy.types import ToolGetResponse as ToolDefinition
|
||||
from arcadepy.types.shared import AuthAuthorizationResponse as AuthorizationResponse
|
||||
from arcadepy.types import ToolDefinition
|
||||
from arcadepy.types.shared import AuthorizationResponse
|
||||
from langchain_arcade.manager import ArcadeToolManager
|
||||
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ def make_tool():
|
|||
toolkit = kwargs.pop("toolkit", {"name": raw_toolkit})
|
||||
|
||||
# Provide a default input
|
||||
# arcadepy.types.ToolGetResponse expects "input" to be a valid structure (dict).
|
||||
# arcadepy.types.ToolDefinition expects "input" to be a valid structure (dict).
|
||||
tool_input = kwargs.pop("input", {"parameters": []})
|
||||
|
||||
# Convert MagicMock-based requirements (with authorization) to an appropriate dict,
|
||||
|
|
|
|||
Loading…
Reference in a new issue