promptflow.azure.operations 模块#
- class promptflow.azure.operations.FlowOperations(operation_scope: OperationScope, operation_config: OperationConfig, all_operations: OperationsContainer, credential, service_caller: FlowServiceCaller, workspace: Workspace, **kwargs: Dict)#
基础类:
WorkspaceTelemetryMixin,_ScopeDependentOperations可以管理流程的FlowOperations。
你不应该直接实例化这个类。相反,你应该创建一个
PFClient实例,并且这个操作可以作为实例的属性使用。- create_or_update(flow: Union[str, Path, Flow], display_name: str = None, type: str = None, **kwargs) Flow#
创建一个从本地源到远程的流程,或更新现有流程的元数据。
更新流程
要更新现有的流程,您只能更新流程的显示名称、描述和标签。 流程名称是一个guid,可以通过两种方式找到:
创建流向 Azure 后,可以在“name”属性的打印消息中找到它。
在Azure门户中打开一个流程,GUID在URL中。例如
https://ml.azure.com/prompts/flow// /xxx
- Parameters:
flow (Union[str, Path, Flow]) – 要创建或更新的流的来源。创建流时,填写本地流路径。 更新流时,填写具有有效流名称的流对象,请参阅上面的文档字符串了解如何在azure上找到流名称。
display_name (str) – 要创建的流程的显示名称。如果未指定,则默认为流程文件夹名称 + 时间戳。例如:“web-classification-10-27-2023-14-19-10”
type (str) – 要创建的流程类型。可选值为 [“standard”, “evaluation”, “chat”]。 如果未指定,默认为 “standard”。
description (str) – 要创建的流程的描述。默认为流程 yaml 文件中的描述。
tags (Dict[str, str]) – 要创建的流程的标签。默认为流程 yaml 文件中的标签。
- get(name: str) Flow#
从Azure获取一个流程。
- Parameters:
name (str) – 要获取的流程的名称。
- Returns:
流程。
- Return type:
流程
- list(max_results: int = 50, flow_type: Optional[FlowType] = None, list_view_type: ListViewType = ListViewType.ACTIVE_ONLY, include_others: bool = False, **kwargs) List[Flow]#
从Azure列出流程。
- Parameters:
max_results (int) – 返回的最大运行次数,默认为50,最大为100
flow_type (Optional[FlowType]) – 流程类型,默认为 None,表示所有流程类型。其他支持的流程类型有 [“standard”, “evaluation”, “chat”]。
list_view_type (ListViewType) – 列表视图类型,默认为 ListViewType.ACTIVE_ONLY
include_others (bool) – 是否列出远程工作区中其他用户拥有的流程,默认为 False
- Returns:
流程列表。
- Return type:
列表[流程]
- class promptflow.azure.operations.RunOperations(operation_scope: OperationScope, operation_config: OperationConfig, all_operations: OperationsContainer, flow_operations: FlowOperations, trace_operations: TraceOperations, credential, service_caller: FlowServiceCaller, workspace: Workspace, **kwargs: Dict)#
基础类:
WorkspaceTelemetryMixin,_ScopeDependentOperations可以管理运行的RunOperations。
你不应该直接实例化这个类。相反,你应该创建一个
PFClient实例,并且这个操作可以作为实例的属性使用。- download(run: Union[str, 运行], output: Optional[Union[str, Path]] = None, overwrite: Optional[bool] = False) str#
下载运行的数据,包括输入、输出、快照和其他运行信息。
注意
下载完成后,您可以使用
pf run create --source将此运行注册为本地运行记录,然后您可以使用诸如pf run show/visualize之类的命令来检查此运行,就像检查从本地流程创建的运行一样。- Parameters:
run (Union[str, Run]) – 运行名称或运行对象
output (可选[str]) – 输出目录。默认为“~/.promptflow/.runs”文件夹。
overwrite (可选[bool]) – 是否覆盖现有的运行文件夹。默认为 False。
- Returns:
运行目录路径
- Return type:
字符串
- get_details(run: Union[str, 运行], max_results: int = 100, all_results: bool = False, **kwargs) DataFrame#
从运行中获取详细信息。
注意
如果all_results设置为True,max_results将被覆盖为sys.maxsize。
- Parameters:
run (Union[str, Run]) – 运行名称或运行对象
max_results (int) – 返回的最大运行次数,默认为100
all_results (bool) – 是否返回所有结果,默认为 False
- Raises:
RunOperationParameterError – 如果 max_results 不是一个正整数。
- Returns:
详细数据框。
- Return type:
pandas.DataFrame
- get_metrics(run: Union[str, 运行], **kwargs) dict#
从运行中获取指标。
- Parameters:
run (Union[str, Run]) – 运行或运行对象
- Returns:
指标
- Return type:
字典
- list(max_results: int = 50, list_view_type: ListViewType = ListViewType.ACTIVE_ONLY, **kwargs) List[运行]#
列出工作区中的运行。
- Parameters:
max_results (int) – 返回的最大运行次数,默认为50,最大为100
list_view_type (ListViewType) – 列表视图类型,默认为 ListViewType.ACTIVE_ONLY
- Returns:
运行列表。
- Return type:
列表[运行]
- stream(run: Union[str, 运行], raise_on_error: bool = True, timeout: int = 600, **kwargs) 运行#
流式传输运行的日志。