输入输出格式#
实验性功能
这是一个实验性功能,可能会随时更改。了解更多更多。
支持的类型#
Promptflow 官方支持以下流程类型。
输入: 基本类型(
int,float,bool,str),dict,TypedDict,list输出:基本类型(
int,float,bool,str),dict,TypedDict,dataclass,list初始化:基本类型(
int,float,bool,str),Connection(包括自定义连接),ModelConfiguration,TypedDict,list
如果用户在代码/YAML中有不支持的类型,将会引发验证错误。
YAML支持#
以下是Python类型到YAML类型的映射:
Python 类型 |
YAML 类型 |
描述 |
|---|---|---|
|
int |
整数类型 |
|
double |
双精度类型 |
|
bool |
布尔类型 |
|
字符串 |
字符串类型 |
|
list |
列表类型 |
|
对象 |
字典类型 |
|
对象 |
类型化字典类型 |
|
object |
数据类类型 |
|
连接类型,将特殊处理 |
|
|
模型配置类型,将特殊处理 |
|
|
模型配置类型,将特殊处理 |
以下是上述支持类型的示例 YAML。
inputs:
int_input:
type: int
float_input:
type: double
bool_input:
type: bool
string_input:
type: string
dict_input:
type: object
list_input:
type: list
outputs:
int_output:
type: int
float_output:
type: double
bool_output:
type: bool
string_output:
type: string
dict_output:
type: object
list_output:
type: list
init:
int_init:
type: int
float_init:
type: double
bool_init:
type: bool
string_init:
type: string
open_ai_connection:
type: OpenAIConnection
azure_open_ai_connection:
type: AzureOpenAIConnection
custom_connection:
type: CustomConnection
open_ai_model_config:
type: OpenAIModelConfiguration
azure_open_ai_model_config:
type: AzureOpenAIModelConfiguration
不支持的类型示例#
# using unsupported types in flow will fail with validation error
class MyOwnClass:
pass
class MyFlow:
# not supported
def __init__(self, my_own_obj: MyOwnClass):
pass
# not supported
def my_flow(my_own_obj: MyOwnClass):
pass
示例验证错误:“输入‘my_own_obj’是一个复杂的python类型。请改用字典。”
流#
流在流程中受支持,您只需在函数中返回一个生成器类型。 参考openai文档了解如何使用纯python代码实现:how_to_stream_completions。
参考此流程sample以获取详细信息。