API Reference¶
This section contains the auto-generated API documentation for Genie Tooling.
Explore the modules and classes below for detailed information.
Core¶
Configuration¶
Plugins (Protocols & Implementations)¶
This section can be expanded by mkdocstrings
or by manually linking to specific plugin protocol documentation pages. Key plugin categories include:
* Tools
* LLM Providers
* Command Processors
* RAG Components (Loaders, Splitters, Embedders, Vector Stores, Retrievers)
* Tool Lookup Providers
* Definition Formatters
* Caching Providers
* Key Providers
* Invocation Strategies
* Error Handling
* Logging & Redaction
* Code Executors
* Prompt System Plugins (Registries, Templates)
* Conversation State Providers
* Observability Tracers
* HITL Approvers
* Token Usage Recorders
* Guardrail Plugins
* LLM Output Parsers
genie_tooling ¶
genie-tooling¶
A hyper-pluggable Python middleware for Agentic AI and LLM applications. Async-first for performance.
Classes¶
BaseAgent ¶
Bases: ABC
Abstract base class for agents that implement specific execution patterns (e.g., ReAct, Plan-and-Execute) using the Genie facade.
Initializes the BaseAgent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
genie
|
Genie
|
An initialized instance of the Genie facade. |
required |
agent_config
|
Optional[Dict[str, Any]]
|
Optional dictionary for agent-specific configurations. |
None
|
Source code in src/genie_tooling/agents/base_agent.py
Functions¶
run
abstractmethod
async
¶
The main entry point to execute the agent's logic for a given goal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
goal
|
str
|
The high-level goal or task for the agent to accomplish. |
required |
**kwargs
|
Any
|
Additional runtime parameters specific to the agent's execution. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
The final result or outcome of the agent's execution. |
Any
|
The structure of the result is specific to the agent implementation. |
Source code in src/genie_tooling/agents/base_agent.py
teardown
async
¶
Optional method for any cleanup specific to the agent. The Genie instance itself should be torn down separately by the application.
Source code in src/genie_tooling/agents/base_agent.py
PlanAndExecuteAgent ¶
Bases: BaseAgent
Implements the Plan-and-Execute agentic loop. 1. Planner: LLM generates a sequence of steps (tool calls) to achieve the goal. Steps can name their outputs for use in subsequent steps. 2. Executor: Executes these steps sequentially, resolving placeholders.
Source code in src/genie_tooling/agents/plan_and_execute_agent.py
ReActAgent ¶
Bases: BaseAgent
Implements the ReAct (Reason-Act) agentic loop.
Source code in src/genie_tooling/agents/react_agent.py
AgentOutput ¶
Bases: TypedDict
Standardized output structure from an agent's run method.
PlannedStep ¶
Bases: TypedDict
Represents a single step in a generated plan.
ReActObservation ¶
Bases: TypedDict
Represents one cycle of Thought-Action-Observation in ReAct.
CacheProviderPlugin ¶
Bases: Plugin
, Protocol
Protocol for a cache provider, designed for async operations.
Functions¶
get
async
¶
Retrieves an item from the cache. Args: key: The key of the item to retrieve. Returns: The cached item, or None if the key is not found or item is expired.
Source code in src/genie_tooling/cache_providers/abc.py
set
async
¶
Stores an item in the cache. Args: key: The key under which to store the item. value: The item to store. Should be serializable if cache is external. ttl_seconds: Optional time-to-live in seconds. If None, item may persist indefinitely or use a default TTL defined by the cache provider.
Source code in src/genie_tooling/cache_providers/abc.py
delete
async
¶
Deletes an item from the cache. Args: key: The key of the item to delete. Returns: True if the key existed and was deleted, False otherwise.
Source code in src/genie_tooling/cache_providers/abc.py
exists
async
¶
Checks if a key exists in the cache (and is not expired). Args: key: The key to check. Returns: True if the key exists and is valid, False otherwise.
Source code in src/genie_tooling/cache_providers/abc.py
clear_all
async
¶
Clears all items from the cache managed by this provider. Use with caution, especially for shared caches. Returns: True if the clear operation was successful or attempted, False on failure.
Source code in src/genie_tooling/cache_providers/abc.py
CodeExecutionResult ¶
Bases: NamedTuple
Standardized result structure for code execution.
CodeExecutorPlugin ¶
Bases: Plugin
, Protocol
Protocol for a plugin that executes code, ideally in a sandboxed environment.
Functions¶
execute_code
async
¶
execute_code(
language: str,
code: str,
timeout_seconds: int,
input_data: Optional[Dict[str, Any]] = None,
) -> CodeExecutionResult
Asynchronously executes the provided code string in the specified language.
Implementations should strive for secure execution (sandboxing).
Args:
language: The programming language of the code.
code: The code script to execute.
timeout_seconds: Maximum allowed execution time in seconds.
input_data: Optional dictionary to make available as variables within the code's scope
(e.g., as a global dict named _input
or similar, executor-defined).
Returns:
A CodeExecutionResult NamedTuple.
Source code in src/genie_tooling/code_executors/abc.py
CommandProcessorPlugin ¶
Bases: Plugin
, Protocol
Protocol for a plugin that processes a natural language command to determine which tool to use and what parameters to pass to it.
Functions¶
setup
async
¶
Initializes the command processor. Args: config: Processor-specific configuration dictionary. Expected to contain 'genie_facade: Genie' for accessing other middleware components.
Source code in src/genie_tooling/command_processors/abc.py
process_command
async
¶
process_command(
command: str,
conversation_history: Optional[List[ChatMessage]] = None,
correlation_id: Optional[str] = None,
) -> CommandProcessorResponse
Processes the given command, potentially using conversation history and other Genie components (via the facade provided in setup), to decide on a tool and its parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command
|
str
|
The natural language command string from the user. |
required |
conversation_history
|
Optional[List[ChatMessage]]
|
Optional list of previous ChatMessages in the conversation. |
None
|
correlation_id
|
Optional[str]
|
Optional ID to link related trace events. |
None
|
Returns:
Type | Description |
---|---|
CommandProcessorResponse
|
A CommandProcessorResponse dictionary. |
Source code in src/genie_tooling/command_processors/abc.py
CommandProcessorResponse ¶
Bases: TypedDict
Standardized response from a CommandProcessorPlugin.
PluginManager ¶
Manages discovery, loading, and access to plugins. Implements Hybrid: Entry Points + Configured Dev Directory discovery.
Source code in src/genie_tooling/core/plugin_manager.py
Chunk ¶
Bases: Protocol
Represents a chunk of a document after splitting.
Document ¶
Bases: Protocol
Represents a loaded document before splitting.
Plugin ¶
Bases: Protocol
Base protocol for all plugins.
Attributes¶
Functions¶
setup
async
¶
Optional asynchronous setup method for plugins.
This method is called by the PluginManager after a plugin is instantiated. It is the primary mechanism for a plugin to receive its configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
Optional[Dict[str, Any]]
|
A dictionary containing the specific configuration for this
plugin instance. This dictionary is sourced from the relevant
|
None
|
Source code in src/genie_tooling/core/types.py
teardown
async
¶
RetrievedChunk ¶
StructuredError ¶
Bases: TypedDict
Standardized structure for reporting errors, especially to LLMs.
DefinitionFormatterPlugin ¶
Bases: Plugin
, Protocol
Protocol for a plugin that formats a tool's metadata into a specific structure (e.g., for LLMs, for human readability).
Functions¶
format ¶
Takes the comprehensive metadata from Tool.get_metadata() and transforms it into the specific output format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool_metadata
|
Dict[str, Any]
|
The raw metadata dictionary from a Tool instance. |
required |
Returns:
Type | Description |
---|---|
Any
|
The formatted definition (e.g., a dict for JSON, a string for text). |
Any
|
The type |
Source code in src/genie_tooling/definition_formatters/abc.py
DocumentLoaderPlugin ¶
Bases: Plugin
, Protocol
Loads documents from a source into an async stream of Document objects.
Functions¶
load
async
¶
Loads documents from the given source URI. Args: source_uri: The URI of the data source (e.g., file path, URL, database connection string). config: Loader-specific configuration dictionary. Yields: Document objects.
Source code in src/genie_tooling/document_loaders/abc.py
EmbeddingGeneratorPlugin ¶
Bases: Plugin
, Protocol
Generates embeddings for an async stream of Chunks.
Functions¶
embed
async
¶
embed(
chunks: AsyncIterable[Chunk], config: Optional[Dict[str, Any]] = None
) -> AsyncIterable[Tuple[Chunk, EmbeddingVector]]
Generates embeddings for each chunk. Args: chunks: An async iterable of Chunk objects. config: Embedder-specific configuration (e.g., model_name, batch_size, key_provider). Yields: Tuples of (Chunk, EmbeddingVector).
Source code in src/genie_tooling/embedding_generators/abc.py
ErrorFormatter ¶
Bases: Plugin
, Protocol
Protocol for formatting StructuredError for different consumers (e.g., LLM, logs).
Functions¶
format ¶
Formats the structured_error. Args: structured_error: The error dictionary produced by an ErrorHandler. target_format: A hint for the desired output format (e.g., "llm", "json", "human_log"). Default is "llm". Returns: The formatted error (e.g., a string for LLM, a dict for JSON). This method is synchronous.
Source code in src/genie_tooling/error_formatters/abc.py
ErrorHandler ¶
Bases: Plugin
, Protocol
Protocol for handling exceptions during tool execution and converting them to StructuredError.
Functions¶
handle ¶
Handles an exception that occurred during tool.execute() or related steps. Args: exception: The exception instance caught. tool: The Tool instance that was being executed (typed as Any to avoid circular import). Implementations can cast or use getattr to access tool.identifier. context: Optional context dictionary active during the call. Returns: A StructuredError dictionary. This method is synchronous as error classification is typically CPU-bound.
Source code in src/genie_tooling/error_handlers/abc.py
InputGuardrailPlugin ¶
Bases: GuardrailPlugin
, Protocol
Protocol for guardrails that check input data (e.g., prompts, user messages).
Functions¶
check_input
async
¶
Checks input data. Returns: GuardrailViolation: Contains action (allow, block, warn) and reason.
Source code in src/genie_tooling/guardrails/abc.py
OutputGuardrailPlugin ¶
Bases: GuardrailPlugin
, Protocol
Protocol for guardrails that check output data (e.g., LLM responses, tool results).
Functions¶
check_output
async
¶
Checks output data. Returns: GuardrailViolation: Contains action (allow, block, warn) and reason.
Source code in src/genie_tooling/guardrails/abc.py
ToolUsageGuardrailPlugin ¶
Bases: GuardrailPlugin
, Protocol
Protocol for guardrails that check tool usage attempts.
Functions¶
check_tool_usage
async
¶
check_tool_usage(
tool: Tool, params: Dict[str, Any], context: Optional[Dict[str, Any]] = None
) -> GuardrailViolation
Checks if a tool usage attempt is permissible. Returns: GuardrailViolation: Contains action (allow, block, warn) and reason.
Source code in src/genie_tooling/guardrails/abc.py
GuardrailViolation ¶
Bases: TypedDict
Represents the outcome of a guardrail check.
HumanApprovalRequestPlugin ¶
Bases: Plugin
, Protocol
Protocol for a plugin that requests human approval for an action.
Functions¶
request_approval
async
¶
Requests human approval for a given action or data. Implementations will vary (e.g., CLI prompt, web UI notification, API call).
Source code in src/genie_tooling/hitl/abc.py
HITLManager ¶
HITLManager(
plugin_manager: PluginManager,
default_approver_id: Optional[str] = None,
approver_configurations: Optional[Dict[str, Dict[str, Any]]] = None,
)
Source code in src/genie_tooling/hitl/manager.py
ApprovalRequest ¶
Bases: TypedDict
Represents a request for human approval.
ApprovalResponse ¶
Bases: TypedDict
Represents the response from a human approval request.
InputValidationException ¶
InputValidationException(
message: str, errors: Any = None, params: Optional[Dict[str, Any]] = None
)
Bases: ValueError
Custom exception for input validation errors, providing more context.
Source code in src/genie_tooling/input_validators/abc.py
InputValidator ¶
Bases: Plugin
, Protocol
Protocol for input parameter validators.
Functions¶
validate ¶
Validates parameters against a schema. Should raise InputValidationException on failure. May return params (possibly coerced or with defaults applied by validator). This method is synchronous as validation is typically CPU-bound.
Source code in src/genie_tooling/input_validators/abc.py
InvocationStrategy ¶
Bases: Plugin
, Protocol
Protocol for a strategy that defines the complete lifecycle of invoking a tool. This includes validation, execution, transformation, caching, and error handling. All strategies must be designed to be async.
Functions¶
invoke
async
¶
invoke(
tool: Tool,
params: Dict[str, Any],
key_provider: KeyProvider,
context: Optional[Dict[str, Any]],
invoker_config: Dict[str, Any],
) -> Any
Executes the full tool invocation lifecycle according to this strategy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool
|
Tool
|
The Tool instance to invoke. |
required |
params
|
Dict[str, Any]
|
The parameters for the tool. |
required |
key_provider
|
KeyProvider
|
The async key provider. |
required |
context
|
Optional[Dict[str, Any]]
|
Optional context dictionary. |
required |
invoker_config
|
Dict[str, Any]
|
Configuration from the ToolInvoker, including: - "plugin_manager": PluginManager instance - "validator_id": Optional[str] - "transformer_id": Optional[str] - "error_handler_id": Optional[str] - "error_formatter_id": Optional[str] - "cache_provider_id": Optional[str] - "cache_config": Optional[Dict[str, Any]] - "tracing_manager": Optional[InteractionTracingManager] - "correlation_id": Optional[str] |
required |
Returns:
Type | Description |
---|---|
Any
|
The result of the tool execution (possibly transformed by an OutputTransformer) |
Any
|
or a structured error (formatted by an ErrorFormatter). The exact type depends |
Any
|
on the formatter's output. |
Source code in src/genie_tooling/invocation_strategies/abc.py
LLMProviderPlugin ¶
Bases: Plugin
, Protocol
Protocol for a plugin that interacts with a Large Language Model provider.
Functions¶
setup
async
¶
Initializes the LLM provider. The 'config' dictionary is expected to contain 'key_provider: KeyProvider' if the specific LLM provider implementation requires API keys.
Source code in src/genie_tooling/llm_providers/abc.py
ChatMessage ¶
Bases: TypedDict
Represents a single message in a chat conversation. Compatible with OpenAI's ChatCompletion message structure.
LLMChatResponse ¶
Bases: TypedDict
Standardized response for chat completion LLM calls.
LLMCompletionResponse ¶
Bases: TypedDict
Standardized response for text completion LLM calls.
LLMUsageInfo ¶
Bases: TypedDict
Represents token usage information from an LLM response.
ToolCall ¶
Bases: TypedDict
Represents a tool call requested by the LLM. Compatible with OpenAI's tool_calls structure.
ToolCallFunction ¶
Bases: TypedDict
Represents the function to be called within a ToolCall.
LogAdapterPlugin ¶
Bases: Plugin
, Protocol
Protocol for a logging/monitoring adapter.
Functions¶
setup
async
¶
Configures logging handlers or integrates with external monitoring systems. This method is called after the adapter is instantiated. Args: config: Adapter-specific configuration dictionary. May include 'plugin_manager' if this adapter needs to load other plugins (e.g., a RedactorPlugin).
Source code in src/genie_tooling/log_adapters/abc.py
process_event
async
¶
process_event(
event_type: str,
data: Dict[str, Any],
schema_for_data: Optional[Dict[str, Any]] = None,
) -> None
Processes a structured event (e.g., for monitoring or detailed logging). Data should be pre-sanitized by this method or by a configured RedactorPlugin. Args: event_type: A string identifying the type of event (e.g., "tool_invoked", "tool_error"). data: A dictionary containing event-specific data. schema_for_data: Optional JSON schema corresponding to 'data', to aid redaction.
Source code in src/genie_tooling/log_adapters/abc.py
ToolLookupService ¶
ToolLookupService(
tool_manager: ToolManager,
plugin_manager: PluginManager,
default_provider_id: Optional[str] = DEFAULT_LOOKUP_PROVIDER_ID,
default_indexing_formatter_id: Optional[str] = DEFAULT_INDEXING_FORMATTER_ID,
tracing_manager: Optional[InteractionTracingManager] = None,
)
Source code in src/genie_tooling/lookup/service.py
Functions¶
add_or_update_tools
async
¶
add_or_update_tools(
tool_ids: List[str],
provider_id_override: Optional[str] = None,
indexing_formatter_id_override: Optional[str] = None,
provider_config_override: Optional[Dict[str, Any]] = None,
correlation_id: Optional[str] = None,
) -> None
Adds or updates a list of tools in the specified lookup provider's index. This is an incremental update.
Source code in src/genie_tooling/lookup/service.py
remove_tools
async
¶
remove_tools(
tool_ids: List[str],
provider_id_override: Optional[str] = None,
provider_config_override: Optional[Dict[str, Any]] = None,
correlation_id: Optional[str] = None,
) -> None
Removes a list of tools from the specified lookup provider's index.
Source code in src/genie_tooling/lookup/service.py
RankedToolResult ¶
RankedToolResult(
tool_identifier: str,
score: float,
matched_tool_data: Optional[Dict[str, Any]] = None,
description_snippet: Optional[str] = None,
matched_keywords: Optional[List[str]] = None,
similarity_score_details: Optional[Dict[str, float]] = None,
)
Represents a tool found by a lookup provider, with diagnostic info.
Source code in src/genie_tooling/lookup/types.py
InteractionTracerPlugin ¶
TraceEvent ¶
Bases: TypedDict
Represents a single event to be traced.
OutputTransformer ¶
Bases: Plugin
, Protocol
Protocol for output transformers.
LLMOutputParserPlugin ¶
Bases: Plugin
, Protocol
Protocol for a plugin that parses the text output of an LLM.
Functions¶
parse ¶
Parses the LLM's text output. Args: text_output: The raw text string from the LLM. schema: Optional schema (e.g., Pydantic model, JSON schema) to guide parsing. Returns: The parsed data, which could be a dict, list, Pydantic model instance, etc. Raises: ValueError or a custom parsing exception if parsing fails.
Source code in src/genie_tooling/prompts/llm_output_parsers/abc.py
RedactorPlugin ¶
Bases: Plugin
, Protocol
Protocol for a data redaction plugin.
Functions¶
sanitize ¶
Sanitizes data to remove or mask sensitive information. This method is synchronous as redaction is typically CPU-bound. Args: data: The data to sanitize (can be any Python object, commonly dicts or lists). schema_hints: Optional JSON schema corresponding to 'data'. If provided, the redactor can use schema annotations (e.g., 'x-sensitive', 'format') to guide redaction. Returns: The sanitized data, with sensitive parts replaced or removed.
Source code in src/genie_tooling/redactors/abc.py
RetrieverPlugin ¶
Bases: Plugin
, Protocol
Retrieves relevant chunks based on a query, typically by composing an embedder and a vector store.
Functions¶
retrieve
async
¶
Retrieves relevant chunks for the given query. Args: query: The natural language query string. top_k: The number of top results to return. config: Retriever-specific configuration. This should include details for the embedder (e.g., "embedder_id", "embedder_config") and vector store (e.g., "vector_store_id", "vector_store_config") that this retriever instance will use. It should also contain "plugin_manager". Returns: A list of RetrievedChunk objects.
Source code in src/genie_tooling/retrievers/abc.py
KeyProvider ¶
Bases: Protocol
Protocol for a component that securely provides API keys. This protocol must be implemented by the consuming application. The middleware itself does not store or manage API keys directly. All methods must be async.
Functions¶
get_key
async
¶
Asynchronously retrieves the API key value for the given key name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key_name
|
str
|
The logical name of the API key required by a tool (e.g., "OPENWEATHERMAP_API_KEY", "OPENAI_API_KEY"). |
required |
Returns:
Type | Description |
---|---|
Optional[str]
|
The API key string if found and accessible, otherwise None. |
Optional[str]
|
Implementations should fetch keys securely (e.g., from environment |
Optional[str]
|
variables, a secrets manager/vault, or application configuration). |
Optional[str]
|
It should log (at debug level) if a key is requested but not found, |
Optional[str]
|
but avoid logging the key value itself. |
Source code in src/genie_tooling/security/key_provider.py
DistributedTaskQueuePlugin ¶
Bases: Plugin
, Protocol
Protocol for a plugin that interacts with a distributed task queue system.
Functions¶
submit_task
async
¶
submit_task(
task_name: str,
args: Tuple = (),
kwargs: Optional[Dict[str, Any]] = None,
queue_name: Optional[str] = None,
task_options: Optional[Dict[str, Any]] = None,
) -> str
Submits a task to the distributed queue. Returns: str: The unique ID of the submitted task. Raises: Exception: If submission fails.
Source code in src/genie_tooling/task_queues/abc.py
get_task_status
async
¶
Gets the status of a previously submitted task.
Source code in src/genie_tooling/task_queues/abc.py
get_task_result
async
¶
get_task_result(
task_id: str,
queue_name: Optional[str] = None,
timeout_seconds: Optional[float] = None,
) -> Any
Retrieves the result of a completed task. May block until the task is complete or timeout occurs. Raises: TimeoutError: If timeout is specified and exceeded. Exception: If task failed or other error.
Source code in src/genie_tooling/task_queues/abc.py
revoke_task
async
¶
Revokes (cancels) a pending or running task. Args: terminate: If True, attempt to terminate a running task. Returns: True if revocation was successful or task was already completed/revoked.
Source code in src/genie_tooling/task_queues/abc.py
TextSplitterPlugin ¶
Bases: Plugin
, Protocol
Splits an async stream of Documents into an async stream of Chunks.
Functions¶
split
async
¶
split(
documents: AsyncIterable[Document], config: Optional[Dict[str, Any]] = None
) -> AsyncIterable[Chunk]
Splits documents into smaller chunks. Args: documents: An async iterable of Document objects. config: Splitter-specific configuration (e.g., chunk_size, chunk_overlap). Yields: Chunk objects.
Source code in src/genie_tooling/text_splitters/abc.py
TokenUsageRecorderPlugin ¶
Bases: Plugin
, Protocol
Protocol for a plugin that records LLM token usage.
Functions¶
record_usage
async
¶
Records a single token usage event.
get_summary
async
¶
Retrieves a summary of token usage. The structure of the summary is implementation-dependent.
Source code in src/genie_tooling/token_usage/abc.py
clear_records
async
¶
Clears recorded usage data, optionally based on criteria.
Source code in src/genie_tooling/token_usage/abc.py
TokenUsageRecord ¶
Bases: TypedDict
Represents a single LLM token usage event.
ToolLookupProviderPlugin ¶
Bases: Plugin
, Protocol
Protocol for a plugin that finds relevant tools based on a query.
Functions¶
index_tools
async
¶
Builds or completely replaces an internal index using formatted tool data. This is for full, batch re-indexing. For dynamic updates, use add/update/remove_tool.
Source code in src/genie_tooling/tool_lookup_providers/abc.py
add_tool
async
¶
Adds a single tool to the index. Returns: True if the tool was added successfully, False otherwise.
Source code in src/genie_tooling/tool_lookup_providers/abc.py
update_tool
async
¶
update_tool(
tool_id: str, tool_data: Dict[str, Any], config: Optional[Dict[str, Any]] = None
) -> bool
Updates an existing tool in the index. This may be an add/overwrite operation. Returns: True if the tool was updated successfully, False otherwise.
Source code in src/genie_tooling/tool_lookup_providers/abc.py
remove_tool
async
¶
Removes a single tool from the index by its ID. Returns: True if the tool was removed or did not exist, False on failure.
Source code in src/genie_tooling/tool_lookup_providers/abc.py
find_tools
async
¶
find_tools(
natural_language_query: str, top_k: int = 5, config: Optional[Dict[str, Any]] = None
) -> List[RankedToolResult]
Searches the indexed tools based on the natural_language_query. Returns: A list of RankedToolResult objects, sorted by relevance (highest score first).
Source code in src/genie_tooling/tool_lookup_providers/abc.py
ToolPlugin ¶
Bases: Plugin
, Protocol
Protocol for a tool that can be executed by the middleware. All tools must be designed to be async.
Attributes¶
Functions¶
get_metadata
async
¶
Returns comprehensive metadata about the tool. This metadata is crucial for tool discovery, LLM function calling, and UI display.
Expected structure: { "identifier": str, (matches self.identifier) "name": str, (human-friendly name) "description_human": str, (detailed for developers/UI) "description_llm": str, (concise, token-efficient for LLM prompts/function descriptions) "input_schema": Dict[str, Any], (JSON Schema for tool parameters) "output_schema": Dict[str, Any], (JSON Schema for tool's expected output structure) "key_requirements": List[Dict[str, str]], (e.g., [{"name": "API_KEY_NAME", "description": "Purpose of key"}]) "tags": List[str], (for categorization, e.g., ["weather", "api", "location"]) "version": str, (e.g., "1.0.0") "cacheable": bool, (optional, hints if tool output can be cached, default False) "cache_ttl_seconds": Optional[int] (optional, default TTL if cacheable) }
Source code in src/genie_tooling/tools/abc.py
execute
async
¶
Executes the tool with the given parameters. Must be an async method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
Dict[str, Any]
|
Validated parameters for the tool, conforming to its input_schema. |
required |
key_provider
|
KeyProvider
|
An async key provider instance for fetching necessary API keys. |
required |
context
|
Dict[str, Any]
|
A dictionary carrying session or request-specific data.
This can include framework-level information (e.g., 'correlation_id',
'otel_context' for distributed tracing, 'genie_framework_instance')
as well as application-specific data passed into methods like
|
required |
Returns:
Type | Description |
---|---|
Any
|
The result of the tool execution. The structure should align with output_schema. |
Any
|
If an error occurs during execution that the tool handles, it should still |
Any
|
return a structured response, possibly including an 'error' field, conforming |
Any
|
to its output_schema. Unhandled exceptions will be caught by the InvocationStrategy. |
Source code in src/genie_tooling/tools/abc.py
ToolManager ¶
ToolManager(
plugin_manager: PluginManager,
tracing_manager: Optional[InteractionTracingManager] = None,
)
Source code in src/genie_tooling/tools/manager.py
Functions¶
register_decorated_tools
async
¶
Processes a list of @tool decorated functions, enabling them based on the auto_enable flag and whether they are listed in the initial tool_configurations.
Source code in src/genie_tooling/tools/manager.py
VectorStorePlugin ¶
Bases: Plugin
, Protocol
Interface for interacting with a vector database.
Functions¶
add
async
¶
add(
embeddings: AsyncIterable[Tuple[Chunk, EmbeddingVector]],
config: Optional[Dict[str, Any]] = None,
) -> Dict[str, Any]
Adds chunks and their embeddings to the vector store. Should handle batching internally if the input stream is large. Args: embeddings: An async iterable of (Chunk, EmbeddingVector) tuples. config: Vector store-specific configuration (e.g., collection name, batch_size). Returns: A dictionary with status, e.g., {"added_count": int, "errors": List[str]}
Source code in src/genie_tooling/vector_stores/abc.py
search
async
¶
search(
query_embedding: EmbeddingVector,
top_k: int,
filter_metadata: Optional[Dict[str, Any]] = None,
config: Optional[Dict[str, Any]] = None,
) -> List[RetrievedChunk]
Searches the vector store for chunks similar to the query_embedding. Args: query_embedding: The embedding vector of the query. top_k: The number of top results to return. filter_metadata: Optional metadata filter to apply during search. config: Search-specific configuration. Returns: A list of RetrievedChunk objects.
Source code in src/genie_tooling/vector_stores/abc.py
delete
async
¶
delete(
ids: Optional[List[str]] = None,
filter_metadata: Optional[Dict[str, Any]] = None,
delete_all: bool = False,
config: Optional[Dict[str, Any]] = None,
) -> bool
Deletes items from the vector store. Args: ids: Optional list of chunk IDs to delete. filter_metadata: Optional metadata filter to select items for deletion. delete_all: If True, delete all items in the collection/store. config: Deletion-specific configuration. Returns: True if deletion was successful (or partially successful), False otherwise.
Source code in src/genie_tooling/vector_stores/abc.py
Functions¶
tool ¶
Decorator to transform a Python function into a Genie-compatible Tool.
Source code in src/genie_tooling/decorators.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
|