Tools¶
Tools are LangChain BaseTools the solver can call between reasoning steps.
APE ships three: Julia (sandboxed Julia/Oscar execution),
LMFDB (SQL access to a read-only LMFDB mirror), and
SessionNotebook (scratch memory scoped to one
session).
To author your own, expose a callable that returns a BaseTool, a list of
them, or a ToolProvider — the protocol
implemented by all three built-in tools.
tools ¶
Julia ¶
Julia(server_ip: str = '127.0.0.1', server_port: int = 8081, response_timeout: int = 30, execution_timeout: int = 10, max_result_len: int = 500)
Bases: ToolProvider
ToolProvider that runs LLM-generated Julia code in a sandboxed
execution server, with the Oscar computer-algebra package available. Code is
sent to an HTTP server at server_ip:server_port; configure the endpoint
and timeouts via the constructor.
get_tool ¶
Creates and returns a tool configured with the specified timeout. Possible server response statuses: 'success', 'runtime_error', 'syntax_error', 'timeout' Possible response statuses returned by the tool: all of the above and 'server_error'
LMFDB ¶
LMFDB(host: str = DEFAULT_HOST, user: str = DEFAULT_USER, password: str = DEFAULT_PASSWORD, dbname: str = DEFAULT_DBNAME, port: int = DEFAULT_PORT, connect_timeout_s: int = DEFAULT_CONNECT_TIMEOUT_S, pool_workers: int = DEFAULT_POOL_WORKERS, statement_timeout_ms: int = DEFAULT_STATEMENT_TIMEOUT_MS, retry_count: int = DEFAULT_RETRY_COUNT, retry_backoff_s: int = DEFAULT_RETRY_BACKOFF_S, query_timeout: int = DEFAULT_QUERY_TIMEOUT, result_max_rows: int = DEFAULT_RESULT_MAX_ROWS)
Bases: ToolProvider
ToolProvider exposing SQL access to a read-only LMFDB (L-functions and
Modular Forms Database) mirror. Builds a toolkit of three tools: list the
available tables, show a table's schema, and run a SQL query. Connection
details, pooling, and query/result limits are configured via the constructor;
queries run under a statement timeout and capped result size.
The read-only guarantee comes from the mirror's database account, not from
this tool — queries are validated for syntax but not restricted to SELECT.
shutdown ¶
Shut down the worker pool and close the connection pool. Registered to run automatically at interpreter exit.
get_tool ¶
Return the LMFDB toolkit (the list-tables, table-schema, and query tools).
get_toolkit ¶
Build the three LMFDB tools: list tables, show a table schema, and run a SQL query.
get_query_tool ¶
get_query_tool(timeout: int = DEFAULT_QUERY_TIMEOUT, result_max_rows: int = DEFAULT_RESULT_MAX_ROWS) -> BaseTool
Build the tool that runs a SQL query against the mirror.
| Parameters: |
|
|---|
get_tables_tool ¶
Build the tool that lists the available LMFDB tables.
get_schema_tool ¶
Build the tool that returns the schema of a named LMFDB table.
SessionNotebook ¶
Bases: ToolProvider
ToolProvider giving the solver a single markdown scratchpad scoped to
one session. The tool supports read (optionally a line range), write
(replace the contents), and append. State lives on the instance and is
wiped by reset between solves.
base ¶
ToolProvider ¶
Bases: Protocol
Interface for classes that build and return LangChain tools. All configuration and state should be injected via the constructor, not passed to get_tool.
get_tool may return either a single BaseTool or a list of them
(e.g. a database toolkit); callers must handle both.
get_tool ¶
Build and return the tool(s) this provider exposes — either a single
BaseTool or a list of them (e.g. a multi-tool toolkit).