CodeAutoGeneratedSampleEvaluator
318 字约 1 分钟
2025-10-09
📘 概述
CodeAutoGeneratedSampleEvaluator 是一个代码自动生成样本评估算子,用于根据代码文件中的自动生成标记来评估代码样本,并给出相应的分数,以便于过滤自动生成的代码文件。
__init__函数
def __init__(self, is_generated_func: Optional[Callable[[], bool]] = None)init参数说明
| 参数名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| is_generated_func | Optional[Callable[[], bool]] | None | 可选的外部检测函数,用于判断代码是否是自动生成的。 |
Prompt模板说明
| Prompt 模板名称 | 主要用途 | 适用场景 | 特点说明 |
|---|---|---|---|
run函数
def run(self, storage: DataFlowStorage, input_key: str)参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| storage | DataFlowStorage | 必需 | 数据流存储实例,负责读取与写入数据。 |
| input_key | str | 必需 | 输入列名,该列包含代码样本数据。 |
🧠 示例用法
🧾 默认输出格式(Output Format)
| 字段 | 类型 | 说明 |
|---|---|---|
| [input_key] | any | 输入的原始数据。 |
| CodeAutoGeneratedMarkerCount | int | 检测到的自动生成标记数量。 |
| CodeAutoGeneratedScore | float | 综合自动生成得分 (0.0 或 1.0,1.0 表示非自动生成)。 |
示例输入:
{
"code_lines": [
"# This file is auto-generated by the build system.",
"def main():",
" print(\"Hello, World!\")"
]
}示例输出:
{
"code_lines": [
"# This file is auto-generated by the build system.",
"def main():",
" print(\"Hello, World!\")"
],
"CodeAutoGeneratedMarkerCount": 1,
"CodeAutoGeneratedScore": 0.0
}
