Fix For New Schemas (#187)
This is a start but may be incomplete --------- Co-authored-by: Nate Barbettini <nate@arcade-ai.com>
This commit is contained in:
parent
179837f7fb
commit
2cc9aba0f4
6 changed files with 37 additions and 36 deletions
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
|
|
@ -29,11 +29,11 @@
|
||||||
"cwd": "${workspaceFolder}"
|
"cwd": "${workspaceFolder}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Debug `arcade chat -s -h localhost`",
|
"name": "Debug `arcade chat -s -d -h localhost`",
|
||||||
"type": "python",
|
"type": "python",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${workspaceFolder}/arcade/run_cli.py",
|
"program": "${workspaceFolder}/arcade/run_cli.py",
|
||||||
"args": ["chat", "-s", "-h", "localhost"],
|
"args": ["chat", "-d", "-h", "localhost"],
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"jinja": true,
|
"jinja": true,
|
||||||
"justMyCode": true,
|
"justMyCode": true,
|
||||||
|
|
|
||||||
|
|
@ -122,11 +122,11 @@ class BaseActor(Actor):
|
||||||
"environment": self.environment,
|
"environment": self.environment,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
invocation_id = tool_request.invocation_id or ""
|
execution_id = tool_request.execution_id or ""
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{invocation_id} | Calling tool: {tool_fqname} version: {tool_request.tool.version}"
|
f"{execution_id} | Calling tool: {tool_fqname} version: {tool_request.tool.version}"
|
||||||
)
|
)
|
||||||
logger.debug(f"{invocation_id} | Tool inputs: {tool_request.inputs}")
|
logger.debug(f"{execution_id} | Tool inputs: {tool_request.inputs}")
|
||||||
|
|
||||||
tracer = trace.get_tracer(__name__)
|
tracer = trace.get_tracer(__name__)
|
||||||
with tracer.start_as_current_span("RunTool"):
|
with tracer.start_as_current_span("RunTool"):
|
||||||
|
|
@ -144,27 +144,27 @@ class BaseActor(Actor):
|
||||||
|
|
||||||
if output.error:
|
if output.error:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"{invocation_id} | Tool {tool_fqname} version {tool_request.tool.version} failed"
|
f"{execution_id} | Tool {tool_fqname} version {tool_request.tool.version} failed"
|
||||||
)
|
)
|
||||||
logger.warning(f"{invocation_id} | Tool error: {output.error.message}")
|
logger.warning(f"{execution_id} | Tool error: {output.error.message}")
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"{invocation_id} | Tool developer message: {output.error.developer_message}"
|
f"{execution_id} | Tool developer message: {output.error.developer_message}"
|
||||||
)
|
)
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"{invocation_id} | duration: {duration_ms}ms | Tool output: {output.value}"
|
f"{execution_id} | duration: {duration_ms}ms | Tool output: {output.value}"
|
||||||
)
|
)
|
||||||
if output.error.traceback_info:
|
if output.error.traceback_info:
|
||||||
logger.debug(f"{invocation_id} | Tool traceback: {output.error.traceback_info}")
|
logger.debug(f"{execution_id} | Tool traceback: {output.error.traceback_info}")
|
||||||
else:
|
else:
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{invocation_id} | Tool {tool_fqname} version {tool_request.tool.version} success"
|
f"{execution_id} | Tool {tool_fqname} version {tool_request.tool.version} success"
|
||||||
)
|
)
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"{invocation_id} | duration: {duration_ms}ms | Tool output: {output.value}"
|
f"{execution_id} | duration: {duration_ms}ms | Tool output: {output.value}"
|
||||||
)
|
)
|
||||||
|
|
||||||
return ToolCallResponse(
|
return ToolCallResponse(
|
||||||
invocation_id=invocation_id,
|
execution_id=execution_id,
|
||||||
duration=duration_ms,
|
duration=duration_ms,
|
||||||
finished_at=datetime.now().isoformat(),
|
finished_at=datetime.now().isoformat(),
|
||||||
success=not output.error,
|
success=not output.error,
|
||||||
|
|
|
||||||
|
|
@ -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.authorization_url:
|
if tool_authorization.url: # type: ignore[attr-defined]
|
||||||
authorization_url = str(tool_authorization.authorization_url)
|
authorization_url = str(tool_authorization.url) # type: ignore[attr-defined]
|
||||||
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"
|
||||||
|
|
@ -446,7 +446,7 @@ def wait_for_authorization_completion(
|
||||||
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.authorization_id),
|
authorization_id=cast(str, auth_response.id), # type: ignore[attr-defined]
|
||||||
scopes=" ".join(auth_response.scopes) if auth_response.scopes else NOT_GIVEN,
|
scopes=" ".join(auth_response.scopes) if auth_response.scopes else NOT_GIVEN,
|
||||||
wait=59,
|
wait=59,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -244,8 +244,8 @@ class ToolCallRequest(BaseModel):
|
||||||
|
|
||||||
run_id: str | None = None
|
run_id: str | None = None
|
||||||
"""The globally-unique run ID provided by the Engine."""
|
"""The globally-unique run ID provided by the Engine."""
|
||||||
invocation_id: str | None = None
|
execution_id: str | None = None
|
||||||
"""The globally-unique ID for this tool invocation in the run."""
|
"""The globally-unique ID for this tool execution in the run."""
|
||||||
created_at: str | None = None
|
created_at: str | None = None
|
||||||
"""The timestamp when the tool invocation was created."""
|
"""The timestamp when the tool invocation was created."""
|
||||||
tool: ToolReference
|
tool: ToolReference
|
||||||
|
|
@ -311,13 +311,13 @@ class ToolCallOutput(BaseModel):
|
||||||
class ToolCallResponse(BaseModel):
|
class ToolCallResponse(BaseModel):
|
||||||
"""The response to a tool invocation."""
|
"""The response to a tool invocation."""
|
||||||
|
|
||||||
invocation_id: str
|
execution_id: str
|
||||||
"""The globally-unique ID for this tool invocation."""
|
"""The globally-unique ID for this tool execution."""
|
||||||
finished_at: str
|
finished_at: str
|
||||||
"""The timestamp when the tool invocation finished."""
|
"""The timestamp when the tool execution finished."""
|
||||||
duration: float
|
duration: float
|
||||||
"""The duration of the tool invocation in milliseconds (ms)."""
|
"""The duration of the tool execution in milliseconds (ms)."""
|
||||||
success: bool
|
success: bool
|
||||||
"""Whether the tool invocation was successful."""
|
"""Whether the tool execution was successful."""
|
||||||
output: ToolCallOutput | None = None
|
output: ToolCallOutput | None = None
|
||||||
"""The output of the tool invocation."""
|
"""The output of the tool invocation."""
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,11 @@
|
||||||
},
|
},
|
||||||
"run_id": {
|
"run_id": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "ID of the overall run"
|
"description": "The globally-unique run ID provided by the Engine."
|
||||||
},
|
},
|
||||||
"invocation_id": {
|
"execution_id": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "ID of this specific tool call"
|
"description": "The globally-unique ID for this tool execution in the run."
|
||||||
},
|
},
|
||||||
"created_at": {
|
"created_at": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "uri"
|
"format": "uri"
|
||||||
},
|
},
|
||||||
"invocation_id": {
|
"execution_id": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "ID of this specific tool call"
|
"description": "The globally-unique ID for this tool execution."
|
||||||
},
|
},
|
||||||
"duration": {
|
"duration": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
|
|
@ -17,11 +17,12 @@
|
||||||
},
|
},
|
||||||
"finished_at": {
|
"finished_at": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "date-time"
|
"format": "date-time",
|
||||||
|
"description": "The timestamp when the tool execution finished."
|
||||||
},
|
},
|
||||||
"success": {
|
"success": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Whether the tool call was successful"
|
"description": "Whether the tool execution was successful"
|
||||||
},
|
},
|
||||||
"output": {
|
"output": {
|
||||||
// Can be null/omitted, in the case of a null-returning (void) function
|
// Can be null/omitted, in the case of a null-returning (void) function
|
||||||
|
|
@ -81,15 +82,15 @@
|
||||||
"requires_authorization": {
|
"requires_authorization": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"authorization_url": {
|
"id": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The ID for checking the status of the authorization"
|
||||||
|
},
|
||||||
|
"url": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "uri",
|
"format": "uri",
|
||||||
"description": "The URL to redirect the user to for authorization"
|
"description": "The URL to redirect the user to for authorization"
|
||||||
},
|
},
|
||||||
"authorization_id": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "The ID for checking the status of the authorization"
|
|
||||||
},
|
|
||||||
"scopes": {
|
"scopes": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
|
@ -102,7 +103,7 @@
|
||||||
"description": "The status of the authorization"
|
"description": "The status of the authorization"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["status"],
|
"required": ["id", "status"],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue