dialog_topic_detection_mapper¶
Generates user's topic labels and analysis in a dialog.
This operator processes a dialog to detect and label the topics discussed by the user. It takes input from history_key
, query_key
, and response_key
and outputs lists of labels and analysis for each query in the dialog. The operator uses a predefined system prompt and templates to build the input prompt for the API call. It supports customizing the system prompt, templates, and patterns for parsing the API response. The results are stored in the meta
field under the keys specified by labels_key
and analysis_key
. If these keys already exist in the meta
field, the operator skips processing. The operator retries the API call up to try_num
times in case of errors.
在对话中生成用户的话题标签和分析。
该算子处理对话以检测并标记用户讨论的话题。它从history_key
、query_key
和response_key
获取输入,并为对话中的每个查询输出标签和分析列表。该算子使用预定义的系统提示和模板来构建API调用的输入提示。它支持自定义系统提示、模板和模式以解析API响应。结果存储在meta
字段下的labels_key
和analysis_key
指定的键下。如果这些键已经存在于meta
字段中,该算子将跳过处理。该算子在出现错误时最多重试try_num
次API调用。
Type 算子类型: mapper
Tags 标签: cpu, api
🔧 Parameter Configuration 参数配置¶
name 参数名 |
type 类型 |
default 默认值 |
desc 说明 |
---|---|---|---|
|
<class 'str'> |
|
API model name. |
|
typing.Optional[typing.List[str]] |
|
The output topic candidates. Use open-domain topic labels if it is None. |
|
typing.Annotated[int, Ge(ge=0)] |
|
The max num of round in the dialog to build the prompt. |
|
<class 'str'> |
|
The key name in the meta field to store the output labels. It is 'dialog_topic_labels' in default. |
|
<class 'str'> |
|
The key name in the meta field to store the corresponding analysis. It is 'dialog_topic_labels_analysis' in default. |
|
typing.Optional[str] |
|
URL endpoint for the API. |
|
typing.Optional[str] |
|
Path to extract content from the API response. Defaults to 'choices.0.message.content'. |
|
typing.Optional[str] |
|
System prompt for the task. |
|
typing.Optional[str] |
|
Template for query part to build the input prompt. |
|
typing.Optional[str] |
|
Template for response part to build the input prompt. |
|
typing.Optional[str] |
|
Template for topic candidates to build the input prompt. |
|
typing.Optional[str] |
|
Template for analysis part to build the input prompt. |
|
typing.Optional[str] |
|
Template for labels part to build the input prompt. |
|
typing.Optional[str] |
|
Pattern to parse the return topic analysis. |
|
typing.Optional[str] |
|
Pattern to parse the return topic labels. |
|
typing.Annotated[int, Gt(gt=0)] |
|
The number of retry attempts when there is an API call error or output parsing error. |
|
typing.Dict |
|
Parameters for initializing the API model. |
|
typing.Dict |
|
Extra parameters passed to the API call. e.g {'temperature': 0.9, 'top_p': 0.95} |
|
|
Extra keyword arguments. |
📊 Effect demonstration 效果演示¶
test_default¶
DialogTopicDetectionMapper(api_model='qwen2.5-72b-instruct')
📥 input data 输入数据¶
📤 output data 输出数据¶
✨ explanation 解释¶
This example uses the default settings of the DialogTopicDetectionMapper operator to detect and label the topics in a conversation. The operator processes each round of the dialog, identifying the main topics discussed and providing an analysis for each. The output includes a list of topic labels and a corresponding analysis for each round of the dialog. 这个例子使用了DialogTopicDetectionMapper算子的默认设置来检测和标注对话中的主题。算子处理对话中的每一轮,识别讨论的主要话题,并为每一轮提供分析。输出包括每轮对话的主题标签列表和相应的分析。