Package opengradient.alphasense
OpenGradient AlphaSense Tools
Functions
Create read workflow tool
def create_read_workflow_tool(tool_type: opengradient.alphasense.types.ToolType, workflow_contract_address: str, tool_name: str, tool_description: str, output_formatter: Callable[..., str] = <function <lambda>>) ‑> langchain_core.tools.base.BaseTool
Creates a tool that reads results from a workflow contract on OpenGradient.
This function generates a tool that can be integrated into either a LangChain pipeline or a Swarm system, allowing the workflow results to be retrieved and formatted as part of a chain of operations.
Returns
BaseTool: For ToolType.LANGCHAIN, returns a LangChain StructuredTool. Callable: For ToolType.SWARM, returns a decorated function with appropriate metadata.
Raises
ValueError
: If an invalid tool_type is provided.
Create run model tool
def create_run_model_tool(tool_type: opengradient.alphasense.types.ToolType, model_cid: str, tool_name: str, model_input_provider: Callable, model_output_formatter: Callable[[InferenceResult], str], tool_input_schema: Optional[Type[BaseModel]] = None, tool_description: str = 'Executes the given ML model', inference_mode: opengradient.types.InferenceMode = 0) ‑> langchain_core.tools.base.BaseTool
Creates a tool that wraps an OpenGradient model for inference.
This function generates a tool that can be integrated into either a LangChain pipeline or a Swarm system, allowing the model to be executed as part of a chain of operations. The tool uses the provided model_input_provider
function to obtain both the necessary input data and any additional inputs from the Agent itself -- specified through the tool_input_schema
-- and runs inference on the specified OpenGradient model.
The model_output_formatter
then allows users to specify the format of their tools response after receiving the model inference result.
Returns
BaseTool: For ToolType.LANGCHAIN, returns a LangChain StructuredTool. Callable: For ToolType.SWARM, returns a decorated function with appropriate metadata.
Raises
ValueError
: If an invalid tool_type is provided.
Classes
ToolType
class ToolType(*args, **kwds)
Indicates the framework the tool is compatible with.
Variables
static
LANGCHAIN
static
SWARM