Skip to content

mock_provider

Class info

Classes

Name Children Inherits
InputCall
llmling_agent.ui.mock_provider
Record of an input provider call.
    InputProvider
    llmling_agent.ui.base
    Base class for handling all UI interactions.
    MockInputProvider
    llmling_agent.ui.mock_provider
    Provider that records calls and returns pre-configured responses.

      🛈 DocStrings

      Mock input provider implementation.

      InputCall dataclass

      Record of an input provider call.

      Source code in src/llmling_agent/ui/mock_provider.py
      26
      27
      28
      29
      30
      31
      32
      33
      @dataclass
      class InputCall:
          """Record of an input provider call."""
      
          method: InputMethod
          args: tuple[Any, ...]
          kwargs: dict[str, Any]
          result: Any
      

      MockInputProvider

      Bases: InputProvider

      Provider that records calls and returns pre-configured responses.

      Source code in src/llmling_agent/ui/mock_provider.py
      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
      class MockInputProvider(InputProvider):
          """Provider that records calls and returns pre-configured responses."""
      
          def __init__(
              self,
              *,
              input_response: str = "mock response",
              tool_confirmation: ConfirmationResult = "allow",
              elicitation_response: dict[str, Any] | None = None,
          ):
              self.input_response = input_response
              self.tool_confirmation = tool_confirmation
              self.elicitation_response = elicitation_response or {"response": "mock response"}
              self.calls: list[InputCall] = []
      
          async def get_input(
              self,
              context: AgentContext,
              prompt: str,
              output_type: type | None = None,
              message_history: list[ChatMessage] | None = None,
          ) -> Any:
              kwargs = {"output_type": output_type, "message_history": message_history}
              args_ = (context, prompt)
              call = InputCall("get_input", args_, kwargs, result=self.input_response)
              self.calls.append(call)
              return self.input_response
      
          async def get_tool_confirmation(
              self,
              context: AgentContext,
              tool: Tool,
              args: dict[str, Any],
              message_history: list[ChatMessage] | None = None,
          ) -> ConfirmationResult:
              kwargs = {"message_history": message_history}
              args_ = (context, tool, args)
              result = self.tool_confirmation
              call = InputCall("get_tool_confirmation", args_, kwargs, result=result)
              self.calls.append(call)
              return result  # pyright: ignore
      
          async def get_elicitation(
              self,
              context: AgentContext,
              params: types.ElicitRequestParams,
              message_history: list[ChatMessage] | None = None,
          ) -> types.ElicitResult | types.ErrorData:
              from mcp import types
      
              kwargs = {"message_history": message_history}
              args_ = (context, params)
              result = types.ElicitResult(action="accept", content=self.elicitation_response)
              call = InputCall("get_elicitation", args_, kwargs, result=result)
              self.calls.append(call)
              return result