From 218bd10d6d469b8c8a0305c5e2f048cab218d74b Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Mon, 26 May 2025 10:05:10 -0700 Subject: [PATCH] Include dataclasses in plugin tool docs Refs #1000 Refs https://github.com/simonw/llm/issues/997#issuecomment-2873497310 --- docs/conf.py | 7 ++++++- docs/plugins/advanced-model-plugins.md | 11 +++++++++++ llm/__init__.py | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index c1583b1..8c83cd6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -30,7 +30,12 @@ from subprocess import PIPE, Popen # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ["myst_parser", "sphinx_copybutton", "sphinx_markdown_builder"] +extensions = [ + "myst_parser", + "sphinx_copybutton", + "sphinx_markdown_builder", + "sphinx.ext.autodoc", +] myst_enable_extensions = ["colon_fence"] markdown_http_base = "https://llm.datasette.io/en/stable" diff --git a/docs/plugins/advanced-model-plugins.md b/docs/plugins/advanced-model-plugins.md index 25bae95..56156f8 100644 --- a/docs/plugins/advanced-model-plugins.md +++ b/docs/plugins/advanced-model-plugins.md @@ -138,6 +138,17 @@ Adding {ref}`tools support ` involves several steps: This [commit to llm-gemini](https://github.com/simonw/llm-gemini/commit/a7f1096cfbb733018eb41c29028a8cc6160be298) implementing tools helps demonstrate what this looks like for a real plugin. +Here are the relevant dataclasses: + +```{eval-rst} +.. autoclass:: llm.Tool + +.. autoclass:: llm.ToolCall + +.. autoclass:: llm.ToolResult +``` + + (advanced-model-plugins-attachments)= ## Attachments for multi-modal models diff --git a/llm/__init__.py b/llm/__init__.py index 8c1b420..8467ebf 100644 --- a/llm/__init__.py +++ b/llm/__init__.py @@ -22,6 +22,7 @@ from .models import ( Tool, Toolbox, ToolCall, + ToolResult, ) from .utils import schema_dsl, Fragment from .embeddings import Collection @@ -59,6 +60,7 @@ __all__ = [ "Tool", "Toolbox", "ToolCall", + "ToolResult", "user_dir", "schema_dsl", ]