From fdb52a6bfcc1922b2f80cf240624bfc7ccc82713 Mon Sep 17 00:00:00 2001 From: Alex Jenkins Date: Thu, 16 Apr 2026 04:03:41 -0400 Subject: [PATCH] Add docstrings to public classes (#812) Add class-level docstrings to five public classes in trustgraph-base: Flow, LlmService, ConsumerMetrics, ToolClient, and TriplesStoreService. Each docstring summarises the class's role in the system to aid discoverability for new contributors. Signed-off-by: Jenkins, Kenneth Alexander --- trustgraph-base/trustgraph/base/flow.py | 7 +++++++ trustgraph-base/trustgraph/base/llm_service.py | 6 ++++++ trustgraph-base/trustgraph/base/metrics.py | 6 ++++++ trustgraph-base/trustgraph/base/tool_client.py | 7 +++++++ trustgraph-base/trustgraph/base/triples_store_service.py | 6 ++++++ 5 files changed, 32 insertions(+) diff --git a/trustgraph-base/trustgraph/base/flow.py b/trustgraph-base/trustgraph/base/flow.py index cf88cbfd..9a515bf8 100644 --- a/trustgraph-base/trustgraph/base/flow.py +++ b/trustgraph-base/trustgraph/base/flow.py @@ -2,6 +2,13 @@ import asyncio class Flow: + """ + Runtime representation of a deployed flow process. + + This class maintains internal processor states and orchestrates + lifecycles (start, stop) for inputs (consumers) and parameters + that drive data flowing across linked nodes. + """ def __init__(self, id, flow, processor, defn): self.id = id diff --git a/trustgraph-base/trustgraph/base/llm_service.py b/trustgraph-base/trustgraph/base/llm_service.py index dc6a8e65..4077c74b 100644 --- a/trustgraph-base/trustgraph/base/llm_service.py +++ b/trustgraph-base/trustgraph/base/llm_service.py @@ -42,6 +42,12 @@ class LlmChunk: __slots__ = ["text", "in_token", "out_token", "model", "is_final"] class LlmService(FlowProcessor): + """ + Extensible service processing requests to Large Language Models (LLMs). + + This class handles the core logic of dispatching text completion or chat requests + to integrated underlying LLM providers (e.g. OpenAI, vertex ai). + """ def __init__(self, **params): diff --git a/trustgraph-base/trustgraph/base/metrics.py b/trustgraph-base/trustgraph/base/metrics.py index 4ffbac9c..618db62d 100644 --- a/trustgraph-base/trustgraph/base/metrics.py +++ b/trustgraph-base/trustgraph/base/metrics.py @@ -3,6 +3,12 @@ from prometheus_client import start_http_server, Info, Enum, Histogram from prometheus_client import Counter class ConsumerMetrics: + """ + Metrics tracking and reporting for flow consumers. + + This class manages prometheus metrics specifically related to consumers + within the flow, including state, requests, processing time, and queues. + """ def __init__(self, processor, flow, name): diff --git a/trustgraph-base/trustgraph/base/tool_client.py b/trustgraph-base/trustgraph/base/tool_client.py index e8955758..e4e2663f 100644 --- a/trustgraph-base/trustgraph/base/tool_client.py +++ b/trustgraph-base/trustgraph/base/tool_client.py @@ -5,6 +5,13 @@ from . request_response_spec import RequestResponse, RequestResponseSpec from .. schema import ToolRequest, ToolResponse class ToolClient(RequestResponse): + """ + Client for invoking tools over the flow messaging fabric. + + This class provides an interface to abstract away the messaging mechanics + and provides a direct awaitable mechanism for invoking tools and + getting their responses. + """ async def invoke(self, name, parameters={}, timeout=600): diff --git a/trustgraph-base/trustgraph/base/triples_store_service.py b/trustgraph-base/trustgraph/base/triples_store_service.py index ac6e2298..79036858 100644 --- a/trustgraph-base/trustgraph/base/triples_store_service.py +++ b/trustgraph-base/trustgraph/base/triples_store_service.py @@ -15,6 +15,12 @@ logger = logging.getLogger(__name__) default_ident = "triples-write" class TriplesStoreService(FlowProcessor): + """ + Component for maintaining the triples store. + + This service acts as a processor in the flow that receives knowledge triples + and writes them persistently into an overarching graph database or equivalent backend. + """ def __init__(self, **params):