climb.tool package

Subpackages

Submodules

climb.tool.tool_comms module

class climb.tool.tool_comms.StreamRedirector(q: Queue)[source]

Bases: object

flush() None[source]
write(text: str) None[source]
class climb.tool.tool_comms.ToolCommunicator[source]

Bases: object

print(*args: Any) None[source]
set_returns(tool_return: str, user_report: List[str | Figure | Figure] | None = None, files_in: List[str] | None = None, files_out: List[str] | None = None) None[source]
exception climb.tool.tool_comms.ToolException[source]

Bases: Exception

class climb.tool.tool_comms.ToolOutput[source]

Bases: object

set_empty() None[source]
property tool_return: str
property user_report_outputs: List[str | Figure | Figure]
class climb.tool.tool_comms.ToolThread(*args: Any, **keywords: Any)[source]

Bases: Thread

SYSTEM_EXIT_MSG = 'ThreadWithTrace killed'
globaltrace(frame: Any, event: str, arg: Any) Callable | None[source]
join(timeout: int | None = None) None[source]

Wait until the thread terminates.

This blocks the calling thread until the thread whose join() method is called terminates – either normally or through an unhandled exception or until the optional timeout occurs.

When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). As join() always returns None, you must call is_alive() after join() to decide whether a timeout happened – if the thread is still alive, the join() call timed out.

When the timeout argument is not present or None, the operation will block until the thread terminates.

A thread can be join()ed many times.

join() raises a RuntimeError if an attempt is made to join the current thread as that would cause a deadlock. It is also an error to join() a thread before it has been started and attempts to do so raises the same exception.

kill(timeout: int | None = None) None[source]
localtrace(frame: Any, event: str, arg: Any) Callable | None[source]
start(std_q: Queue, exc_q: Queue, backup_output_file_path: str) None[source]

Start the thread’s activity.

It must be called at most once per thread object. It arranges for the object’s run() method to be invoked in a separate thread of control.

This method will raise a RuntimeError if called more than once on the same thread object.

climb.tool.tool_comms.except_hook(args: Any, exc_queue: Queue) NoReturn[source]
climb.tool.tool_comms.execute_tool(tool_func: Callable, wd: str, **kwargs: Any) Tuple[ToolThread, Iterable[str | ToolOutput]][source]
climb.tool.tool_comms.live_output_iterable(thread: ToolThread, comm_q: Queue, exc_q: Queue, std_q: Queue, return_holder: ToolOutput, wd: str) Iterable[str | ToolOutput][source]
climb.tool.tool_comms.process_stream_chunk(s: str) str | None[source]

climb.tool.tools module

class climb.tool.tools.ToolBase[source]

Bases: ABC

abstract property description: str
abstract property description_for_user: str

A description of what this tool does, for the user. Should make sense in the context: “This tool <description_for_user>.”

execute(**kwargs: Any) Iterable[str | ToolOutput][source]
property logs_useful: bool

Return True if the logs of this tool are especially useful for the LLM to understand what has been done.

This will be used by the engine to determine whether to shorten the logs if needed for token reasons etc. This is up to the engine’s discretion, this property just provides a hint.

The user will always be able to see the full logs.

Returns:

True if the logs of this tool are especially useful for the LLM to understand what has been done.

Return type:

bool

abstract property name: str
receive_user_inputs_requested(user_input: UserInputRequest | None) None[source]
receive_working_directory(working_directory: str) None[source]
abstract property specification: Dict[str, Any]
stop_execution(timeout: int | None = 1) None[source]
property user_input_requested: List[UserInputRequest]
climb.tool.tools.get_str_up_to_marker(s: str, marker: str) str[source]

Module contents

class climb.tool.ToolBase[source]

Bases: ABC

abstract property description: str
abstract property description_for_user: str

A description of what this tool does, for the user. Should make sense in the context: “This tool <description_for_user>.”

execute(**kwargs: Any) Iterable[str | ToolOutput][source]
property logs_useful: bool

Return True if the logs of this tool are especially useful for the LLM to understand what has been done.

This will be used by the engine to determine whether to shorten the logs if needed for token reasons etc. This is up to the engine’s discretion, this property just provides a hint.

The user will always be able to see the full logs.

Returns:

True if the logs of this tool are especially useful for the LLM to understand what has been done.

Return type:

bool

abstract property name: str
receive_user_inputs_requested(user_input: UserInputRequest | None) None[source]
receive_working_directory(working_directory: str) None[source]
abstract property specification: Dict[str, Any]
stop_execution(timeout: int | None = 1) None[source]
property user_input_requested: List[UserInputRequest]
class climb.tool.ToolCommunicator[source]

Bases: object

print(*args: Any) None[source]
set_returns(tool_return: str, user_report: List[str | Figure | Figure] | None = None, files_in: List[str] | None = None, files_out: List[str] | None = None) None[source]
class climb.tool.ToolOutput[source]

Bases: object

set_empty() None[source]
property tool_return: str
property user_report_outputs: List[str | Figure | Figure]
class climb.tool.UserInputRequest(*, key: str, kind: Literal['text', 'file', 'multiple_files'], description: str | None = None, extra: Dict[str, Any] = {})[source]

Bases: BaseModel

check_received_input() None[source]
description: str | None
extra: Dict[str, Any]
key: str
kind: Literal['text', 'file', 'multiple_files']
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • context – The context.

property received_input: Any
climb.tool.get_tool(tool_name: str) ToolBase[source]
climb.tool.list_all_tool_specs(filter_tool_names: List[str] | None = None) List[Dict[str, Any]][source]