bots.dev package

Submodules

bots.dev.auto_terminal module

bots.dev.auto_terminal.check_for_interrupt() bool[source]

Check if user pressed Escape without blocking execution. Returns True if Escape was pressed, False otherwise.

bots.dev.auto_terminal.setup_raw_mode()[source]

Set up terminal for raw input mode on Unix systems (untested)

bots.dev.auto_terminal.restore_terminal(old_settings)[source]

Restore terminal settings on Unix systems

bots.dev.auto_terminal.pretty(string: str, name: str | None = None, width: int = 1000, indent: int = 4) None[source]

Prints a string nicely

bots.dev.auto_terminal.initialize_bot() ChatGPT_Bot | AnthropicBot | None[source]
bots.dev.auto_terminal.clean_dict(d: dict, indent: int = 4, level: int = 1)[source]

Clean a dict containing recursive json dumped strings for printing Returns: clean string representation of the dict

bots.dev.auto_terminal.main() None[source]

bots.dev.decorators module

Development decorators for enhancing bot functionality and debugging.

This module provides decorators and utilities for: - Lazy function implementation using LLMs (@lazy) - Post-mortem debugging on exceptions (@debug_on_error) - HTTP logging filters for cleaner output

The primary features are: - @lazy: Generates function implementations at runtime using LLM - @debug_on_error: Launches pdb debugger on exceptions - NoHTTPFilter: Filters out HTTP-related logging noise

Example

from bots.dev.decorators import lazy, debug_on_error

@lazy(“Implement a quicksort algorithm”) def sort_list(items: list) -> list:

pass # Implementation will be generated by LLM

@debug_on_error def risky_operation():

# Will launch debugger if this raises an exception process_data()

class bots.dev.decorators.NoHTTPFilter(name='')[source]

Bases: Filter

Filters out logging records containing ‘response’ in the logger name.

Use when you need to reduce noise from HTTP-related logging in the application. This filter helps prevent logging output from being flooded with HTTP response logs while still maintaining other important log messages.

Inherits from:

logging.Filter: Base class for logging filters

name

The name of the filter (inherited from logging.Filter)

Type:

str

Example

logger = logging.getLogger(__name__) http_filter = NoHTTPFilter() logger.addFilter(http_filter)

filter(record: LogRecord) bool[source]

Check if the log record should be filtered.

Parameters:

record (logging.LogRecord) – The log record to be checked

Returns:

True if the record should be kept (doesn’t contain ‘response’),

False if it should be filtered out

Return type:

bool

bots.dev.decorators.lazy(prompt: str | None = None, bot: Bot | None = None, context: str | None = None) Callable[source]

Decorator that lazily implements a function using an LLM at runtime.

Use when you need to generate function implementations dynamically using an LLM. The implementation will be generated on first call and persisted to the source file.

Parameters:
  • prompt (Optional[str]) – Additional instructions for the LLM about how to implement the function. Defaults to empty string.

  • bot (Optional[Bot]) – The bot instance to use for implementation. Defaults to a new AnthropicBot instance.

  • context (Optional[str]) – Level of context to provide to the LLM. Options are: - ‘None’: No additional context - ‘low’: Only the containing class - ‘medium’: The entire current file - ‘high’: Current file and interfaces of other files in directory - ‘very high’: All Python files in directory Defaults to ‘None’.

Returns:

A decorator function that wraps the target function

Return type:

Callable

Example

@lazy(“Sort using a funny algorithm. Name variables as though you’re a clown.”) def sort(arr: list[int]) -> list[int]:

pass

bots.dev.decorators._get_context(func: Callable, context_level: str) str[source]

Retrieves contextual code based on the specified context level.

Use when you need to gather source code context for an LLM to understand the environment of a function.

Parameters:
  • func (Callable) – The function to get context for

  • context_level (str) – Level of context to retrieve: - ‘None’: Returns empty string - ‘low’: Returns only the containing class - ‘medium’: Returns entire current file - ‘high’: Returns current file and interfaces of other files - ‘very high’: Returns all Python files in directory

Returns:

The requested context as a string

Return type:

str

Raises:

ValueError – If context_level is not one of the valid options

bots.dev.decorators._get_py_interface(file_path: str) str[source]

Extracts the public interface (classes and functions) from a Python file.

Use when you need to get a high-level overview of a Python module’s structure without including implementation details.

Parameters:

file_path (str) – Path to the Python file to analyze

Returns:

A string containing the module’s interface, including class and function

signatures with their docstrings

Return type:

str

bots.dev.decorators.debug_on_error(func: Callable) Callable[source]

Decorator that launches post-mortem debugging on exception.

Use when you need to automatically start a debugging session when a function raises an unhandled exception. This is particularly useful during development and troubleshooting.

Parameters:

func (Callable) – The function to wrap with debugging capabilities

Returns:

A wrapped version of the function that will launch pdb on error

Return type:

Callable

Example

@debug_on_error def might_fail():

# If this raises an exception, you’ll get a pdb prompt risky_operation()

bots.dev.start module

Module contents