promptflow.contracts.tool module#
- class promptflow.contracts.tool.ConnectionType#
Bases:
object
This class provides methods to interact with connection types.
- static get_connection_class(type_name: str) Optional[type] #
Get connection type by type name.
- Parameters:
type_name (str) – The type name of the connection
- Returns:
The connection type
- Return type:
type
- static is_connection_class_name(type_name: str) bool #
Check if the given type name is a connection type.
- Parameters:
type_name (str) – The type name of the connection
- Returns:
Whether the given type name is a connection type
- Return type:
bool
- static is_connection_value(val: Any) bool #
Check if the given value is a connection.
- Parameters:
val (Any) – The value to check
- Returns:
Whether the given value is a connection
- Return type:
bool
- static is_custom_strong_type(val: Any) bool #
Check if the given value is a custom strong type connection.
- Parameters:
val (Any) – The value to check
- Returns:
Whether the given value is a custom strong type
- Return type:
bool
- static serialize_conn(connection: Any) dict #
Serialize the given connection.
- Parameters:
connection (Any) – The connection to serialize
- Returns:
A dictionary representation of the connection.
- Return type:
dict
- class promptflow.contracts.tool.InputDefinition(type: List[ValueType], default: Optional[str] = None, description: Optional[str] = None, enum: Optional[List[str]] = None, custom_type: Optional[List[str]] = None)#
Bases:
object
Input definition.
- custom_type: List[str] = None#
- default: str = None#
- description: str = None#
- static deserialize(data: dict) InputDefinition #
Deserialize dict to input definition.
- Parameters:
data (dict) – The dict needs to be deserialized
- Returns:
The deserialized input definition
- Return type:
- enum: List[str] = None#
- serialize() dict #
Serialize input definition to dict.
- Returns:
The serialized input definition
- Return type:
dict
- to_flow_input_definition()#
Used for eager flow to convert input definition to flow input definition.
- class promptflow.contracts.tool.OutputDefinition(type: List[ValueType], description: str = '', is_property: bool = False)#
Bases:
object
Output definition.
- description: str = ''#
- static deserialize(data: dict) OutputDefinition #
Deserialize dict to output definition.
- Parameters:
data (dict) – The dict needs to be deserialized
- Returns:
The deserialized output definition
- Return type:
- is_property: bool = False#
- serialize() dict #
Serialize output definition to dict.
- Returns:
The serialized output definition
- Return type:
dict
- class promptflow.contracts.tool.Tool(name: str, type: ToolType, inputs: Dict[str, InputDefinition], outputs: Optional[Dict[str, OutputDefinition]] = None, description: Optional[str] = None, module: Optional[str] = None, class_name: Optional[str] = None, source: Optional[str] = None, code: Optional[str] = None, function: Optional[str] = None, connection_type: Optional[List[str]] = None, is_builtin: Optional[bool] = None, stage: Optional[str] = None, enable_kwargs: Optional[bool] = False, deprecated_tools: Optional[List[str]] = None)#
Bases:
object
Tool definition.
- Parameters:
name (str) – The name of the tool
type (ToolType) – The type of the tool
inputs (Dict[str, InputDefinition]) – The inputs of the tool
outputs (Optional[Dict[str, OutputDefinition]]) – The outputs of the tool
description (Optional[str]) – The description of the tool
module (Optional[str]) – The module of the tool
class_name (Optional[str]) – The class name of the tool
source (Optional[str]) – The source of the tool
code (Optional[str]) – The code of the tool
function (Optional[str]) – The function of the tool
connection_type (Optional[List[str]]) – The connection type of the tool
is_builtin (Optional[bool]) – Whether the tool is a built-in tool
stage (Optional[str]) – The stage of the tool
enable_kwargs (Optional[bool]) – Whether to enable kwargs, only available for customer python tool
deprecated_tools (Optional[List[str]]) – A list of old tool IDs that are mapped to the current tool ID.
- class_name: Optional[str] = None#
- code: Optional[str] = None#
- connection_type: Optional[List[str]] = None#
- deprecated_tools: Optional[List[str]] = None#
- description: Optional[str] = None#
- static deserialize(data: dict) Tool #
Deserialize dict to tool.
- Parameters:
data (dict) – The dict needs to be deserialized
- Returns:
The deserialized tool
- Return type:
- enable_kwargs: Optional[bool] = False#
- function: Optional[str] = None#
- inputs: Dict[str, InputDefinition]#
- is_builtin: Optional[bool] = None#
- module: Optional[str] = None#
- name: str#
- outputs: Optional[Dict[str, OutputDefinition]] = None#
- serialize() dict #
Serialize tool to dict and skip None fields.
- Returns:
The serialized tool
- Return type:
dict
- source: Optional[str] = None#
- stage: Optional[str] = None#
- class promptflow.contracts.tool.ToolFuncCallScenario(value)#
Bases:
str
,Enum
An enumeration.
- DYNAMIC_LIST = 'dynamic_list'#
- GENERATED_BY = 'generated_by'#
- REVERSE_GENERATED_BY = 'reverse_generated_by'#
- class promptflow.contracts.tool.ToolType(value)#
Bases:
str
,Enum
Tool types.
- CSHARP = 'csharp'#
- CUSTOM_LLM = 'custom_llm'#
- LLM = 'llm'#
- PROMPT = 'prompt'#
- PYTHON = 'python'#
- class promptflow.contracts.tool.ValueType(value)#
Bases:
str
,Enum
Value types.
- ASSISTANT_DEFINITION = 'assistant_definition'#
- BOOL = 'bool'#
- DOUBLE = 'double'#
- FILE_PATH = 'file_path'#
- IMAGE = 'image'#
- INT = 'int'#
- LIST = 'list'#
- OBJECT = 'object'#
- PROMPT_TEMPLATE = 'prompt_template'#
- SECRET = 'secret'#
- STRING = 'string'#