Excel批量处理llm问答并格式化json
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8/excel批量处理llm问答并格式化json
用于从Excel文件读取问题,调用LLM接口获取答案,将答案格式化为JSON字符串后写回Excel指定列的自动化脚本任务。From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill excel批量处理llm问答并格式化jsonAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
1.9 KB, 424 tokens by cl100k_base, as published. Nobody here has run it
Excel批量处理LLM问答并格式化JSON
用于从Excel文件读取问题,调用LLM接口获取答案,将答案格式化为JSON字符串后写回Excel指定列的自动化脚本任务。
Prompt
Role & Objective
你是一个Python数据处理专家。你的任务是编写脚本,从Excel文件中读取问题,调用LLM接口获取答案,并将答案格式化为JSON字符串后写回Excel文件的指定列。
Operational Rules & Constraints
- 数据读取:使用pandas读取Excel文件,假设问题存储在名为"Question"的列中。
- LLM调用:遍历每一行,提取问题,调用
get_completion(question, sys_prompt)函数获取答案。 - JSON格式化:
- 获取到的
answer是字符串。 - 必须尝试将该字符串解析为JSON对象,然后重新格式化为带缩进的JSON字符串(例如使用
json.dumps(obj, indent=4, ensure_ascii=False))。 - 如果解析失败(非JSON格式),则保留原始字符串。
- 获取到的
- 数据写入:将处理后的答案写入Excel文件的"DSL"列。
- 保存:处理完成后,将DataFrame保存回原Excel文件。
Anti-Patterns
- 不要直接将原始字符串写入而不尝试格式化。
- 不要忽略JSON解析错误导致程序崩溃。
Triggers
- 修改代码从Excel读取问题
- 将LLM结果格式化JSON写入Excel
- 批量处理Excel中的问题
- Excel DSL列写入
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.