Skip to content

base

Class info

Classes

Name Children Inherits
InputProvider
llmling_agent.ui.base
Base class for handling all UI interactions.

🛈 DocStrings

Base input provider class.

InputProvider

Bases: ABC

Base class for handling all UI interactions.

Source code in src/llmling_agent/ui/base.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
class InputProvider(ABC):
    """Base class for handling all UI interactions."""

    async def get_input(
        self,
        context: AgentContext,
        prompt: str,
        output_type: type | None = None,
        message_history: list[ChatMessage] | None = None,
    ) -> Any:
        """Get normal input (used by HumanProvider).

        Args:
            context: Current agent context
            prompt: The prompt to show to the user
            output_type: Optional type for structured responses
            message_history: Optional conversation history
        """
        if output_type:
            return await self.get_structured_input(
                context, prompt, output_type, message_history
            )
        return await self.get_text_input(context, prompt, message_history)

    async def get_text_input(
        self,
        context: AgentContext[Any],
        prompt: str,
        message_history: list[ChatMessage] | None = None,
    ) -> str:
        """Get normal text input."""
        raise NotImplementedError

    async def get_structured_input(
        self,
        context: AgentContext[Any],
        prompt: str,
        output_type: type[BaseModel],
        message_history: list[ChatMessage] | None = None,
    ) -> BaseModel:
        """Get structured input, with promptantic and fallback handling."""
        raise NotImplementedError

    @abstractmethod
    def get_tool_confirmation(
        self,
        context: AgentContext[Any],
        tool: Tool,
        args: dict[str, Any],
        message_history: list[ChatMessage] | None = None,
    ) -> Coroutine[Any, Any, ConfirmationResult]:
        """Get tool execution confirmation.

        Args:
            context: Current agent context
            tool: Information about the tool to be executed
            args: Tool arguments
            message_history: Optional conversation history
        """

    @abstractmethod
    def get_elicitation(
        self,
        context: AgentContext[Any],
        params: types.ElicitRequestParams,
        message_history: list[ChatMessage] | None = None,
    ) -> Coroutine[Any, Any, types.ElicitResult | types.ErrorData]:
        """Get user response to elicitation request.

        Args:
            context: Current agent context
            params: MCP elicit request parameters
            message_history: Optional conversation history
        """

get_elicitation abstractmethod

get_elicitation(
    context: AgentContext[Any],
    params: ElicitRequestParams,
    message_history: list[ChatMessage] | None = None,
) -> Coroutine[Any, Any, ElicitResult | ErrorData]

Get user response to elicitation request.

Parameters:

Name Type Description Default
context AgentContext[Any]

Current agent context

required
params ElicitRequestParams

MCP elicit request parameters

required
message_history list[ChatMessage] | None

Optional conversation history

None
Source code in src/llmling_agent/ui/base.py
80
81
82
83
84
85
86
87
88
89
90
91
92
93
@abstractmethod
def get_elicitation(
    self,
    context: AgentContext[Any],
    params: types.ElicitRequestParams,
    message_history: list[ChatMessage] | None = None,
) -> Coroutine[Any, Any, types.ElicitResult | types.ErrorData]:
    """Get user response to elicitation request.

    Args:
        context: Current agent context
        params: MCP elicit request parameters
        message_history: Optional conversation history
    """

get_input async

get_input(
    context: AgentContext,
    prompt: str,
    output_type: type | None = None,
    message_history: list[ChatMessage] | None = None,
) -> Any

Get normal input (used by HumanProvider).

Parameters:

Name Type Description Default
context AgentContext

Current agent context

required
prompt str

The prompt to show to the user

required
output_type type | None

Optional type for structured responses

None
message_history list[ChatMessage] | None

Optional conversation history

None
Source code in src/llmling_agent/ui/base.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
async def get_input(
    self,
    context: AgentContext,
    prompt: str,
    output_type: type | None = None,
    message_history: list[ChatMessage] | None = None,
) -> Any:
    """Get normal input (used by HumanProvider).

    Args:
        context: Current agent context
        prompt: The prompt to show to the user
        output_type: Optional type for structured responses
        message_history: Optional conversation history
    """
    if output_type:
        return await self.get_structured_input(
            context, prompt, output_type, message_history
        )
    return await self.get_text_input(context, prompt, message_history)

get_structured_input async

get_structured_input(
    context: AgentContext[Any],
    prompt: str,
    output_type: type[BaseModel],
    message_history: list[ChatMessage] | None = None,
) -> BaseModel

Get structured input, with promptantic and fallback handling.

Source code in src/llmling_agent/ui/base.py
53
54
55
56
57
58
59
60
61
async def get_structured_input(
    self,
    context: AgentContext[Any],
    prompt: str,
    output_type: type[BaseModel],
    message_history: list[ChatMessage] | None = None,
) -> BaseModel:
    """Get structured input, with promptantic and fallback handling."""
    raise NotImplementedError

get_text_input async

get_text_input(
    context: AgentContext[Any],
    prompt: str,
    message_history: list[ChatMessage] | None = None,
) -> str

Get normal text input.

Source code in src/llmling_agent/ui/base.py
44
45
46
47
48
49
50
51
async def get_text_input(
    self,
    context: AgentContext[Any],
    prompt: str,
    message_history: list[ChatMessage] | None = None,
) -> str:
    """Get normal text input."""
    raise NotImplementedError

get_tool_confirmation abstractmethod

get_tool_confirmation(
    context: AgentContext[Any],
    tool: Tool,
    args: dict[str, Any],
    message_history: list[ChatMessage] | None = None,
) -> Coroutine[Any, Any, ConfirmationResult]

Get tool execution confirmation.

Parameters:

Name Type Description Default
context AgentContext[Any]

Current agent context

required
tool Tool

Information about the tool to be executed

required
args dict[str, Any]

Tool arguments

required
message_history list[ChatMessage] | None

Optional conversation history

None
Source code in src/llmling_agent/ui/base.py
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
@abstractmethod
def get_tool_confirmation(
    self,
    context: AgentContext[Any],
    tool: Tool,
    args: dict[str, Any],
    message_history: list[ChatMessage] | None = None,
) -> Coroutine[Any, Any, ConfirmationResult]:
    """Get tool execution confirmation.

    Args:
        context: Current agent context
        tool: Information about the tool to be executed
        args: Tool arguments
        message_history: Optional conversation history
    """