Spaces:
No application file
No application file
from typing import Any, Literal, NotRequired | |
from pydantic import BaseModel, Field | |
from typing_extensions import TypedDict | |
class UserInput(BaseModel): | |
"""Basic user input for the agent.""" | |
user_message: str = Field( | |
description="User message to the AI agent.", | |
examples=["Hello, I want to report."], | |
) | |
thread_id: str | None = Field( | |
description="Thread ID to persist and continue a multi-turn conversation.", | |
default=None, | |
examples=["847c6285-8fc9-4560-a83f-4e628xx09254"], | |
) | |
class SingleResponse(BaseModel): | |
"""Basic user input for the agent.""" | |
response_message: str = Field( | |
description="Response content based on user input.", | |
examples=["Hello, I am a bot."], | |
) | |
responder: Literal["human", "ai", "tool", "custom"] = Field( | |
description="Generator of response.", | |
examples=["human", "ai", "tool", "custom"], | |
) | |
thread_id: str | None = Field( | |
description="Thread ID to persist and continue a multi-turn conversation.", | |
default=None, | |
examples=["847c6285-8fc9-4560-a83f-4e628xx09254"], | |
) | |
class ToolCall(TypedDict): | |
"""Represents a request to call a tool.""" | |
name: str | |
"""The name of the tool to be called.""" | |
args: dict[str, Any] | |
"""The arguments to the tool call.""" | |
id: str | None | |
"""An identifier associated with the tool call.""" | |
type: NotRequired[Literal["tool_call"]] | |
class Chat(BaseModel): | |
"""Message in a chat.""" | |
type: Literal["human", "ai", "tool", "custom"] = Field( | |
description="Role of the message.", | |
examples=["human", "ai", "tool", "custom"], | |
) | |
content: str = Field( | |
description="Content of the message.", | |
examples=["Hello, world!"], | |
) | |
tool_calls: list[ToolCall] = Field( | |
description="Tool calls in the message.", | |
default=[], | |
) | |
tool_call_id: str | None = Field( | |
description="Tool call that this message is responding to.", | |
default=None, | |
examples=["call_Jja7J89XsjrOLA5r!MEOW!SL"], | |
) | |
run_id: str | None = Field( | |
description="Run ID of the message.", | |
default=None, | |
examples=["847c6285-8fc9-4560-a83f-4e6285809254"], | |
) | |
response_metadata: dict[str, Any] = Field( | |
description="Response metadata. For example: response headers, logprobs, token counts.", | |
default={}, | |
) | |
custom_data: dict[str, Any] = Field( | |
description="Custom message data.", | |
default={}, | |
) | |