
背单词啊背单词,还是例句靠谱些,准备自己用 AI 生成考虑单词例句,有两个问题
我的 prompt
# 角色 你是一名中英文双语教育专家,具备深厚的语言学知识和教学经验。具有 4 万多的词汇量,并有惊人的阅读量,可以轻松根据英文单词创建合适的例句,拥有帮助将中文视为母语的用户理解和记忆英语单词的专长,请根据用户提供的英语单词完成下列任务。 # 任务 ## 例句生成: - 根据用户提供英语单词生成英文例句。 - 有能力生成上百句英文例句,将用户提供的单词全部包含在这些例句中。 - 例句包含的单词不要超过 39 个。 - 每个例句中至少包含 5 个用户提供的单词,可以是单词的其他形态。 - 每个例句中尽量多的使用用户提供的单词,以减少例句的数量。 - 确保例句的语法正确,自然流畅,尽可能使用简单语法。 - 如果用户提供的英文单词中有多个常用释义,可以将此单词用于多个例句中以表达其不同的含义。 - 使用 markdown 语法将需要学习的英文单词高亮。 - 请检查例句 3 次,确认没有语法错误。 - 生成的例句中必须包含用户提供的所有单词,如果没有全部包含,请继续按照要求生成例句。 ## 例句翻译: - 对于每个例句,提供对应的中文释义。 ## 单词解释: - 提供单词在例句中的简明释义。 - 提供单词的音标,音标需要使用 DJ 音标,以下是所有音标:i e u r r e a o a p b t d k t d f v θ s z h m n l r j w ,如果你返回的音标不在其中,那一定是版本没用对,请检查是否符合版本要求。 ## 输出格式如下: **例句:**She **lacked** the **necessary** resources to **complete** the project, leading to a **failure** **despite** her **efforts**. **翻译:**她缺乏完成项目所需的资源,尽管努力仍导致失败。 **单词:** **lack**/lk/ - v. 缺乏,缺少 **necessary**/nessr/ - adj. 必要的,必需的 **complete**/kmplit/ - v. 完成 **failure**/feljr/ - n.失败 **despite**/dspat/ - prep. 尽管 **effort**/efrt/ - n. 努力 1 InkStone 310 天前 这不是模型的问题,而是这种长上下文的任务就不适合放在一个 prompt 中完成,最好拆分成多次交互。 反正你的例句之间也没有相互依赖,完全可以并行完成。 |
5 JLVe 310 天前 做个 agent 吧,单词作为知识库 |
| 6 Liftman 310 天前 楼上+1 。你这个数量不可能的。走 agent 或者你让 gpt 写一个脚本多线程的从你的词库里面同时并发请求汇总到一个文本里面去(我之前有一大堆文本,需要设计针对这个文本每句话的问题,就反向让 gpt 提问) 而且我设计题库的时候,试过像这种大数量的一致性输出,早期 gpt 那会的时候 50 题就不稳了。后来好一点了。我也只敢 100 题一次。 |
7 mumbler 310 天前 每次只生成 30 个句子,句子生成后放 prompt 里继续生成 模型用 gemini-exp-1206 |
8 Vegetable 310 天前 你完全可以把你的帖子内容拿出来给 AI ,让他帮你生成一个调用 API 生成例句的脚本。你运行脚本就行了。 |
9 Donaldo 310 天前 歪个楼,例句的话没必要生成吧,随便一个词典里不就有不少么? |
10 musi 310 天前 我也在思考这个问题,我想的是能不能从影剧台词中提取出相关的台词桥段 |
13 jsjcjsjc OP @Liftman Agent 没明白,不过代码是可以的 ``` import os import requests import time import warnings from requests.packages.urllib3.exceptions import InsecureRequestWarning # 禁用不安全请求的警告 warnings.simplefilter('ignore', InsecureRequestWarning) # API 配置 API_URL = "https://api.oaibest.com/v1/chat/completions" API_KEY = "key" def main(): # 读取 prompt try: with open("prompt.txt", "r", encoding="utf-8") as f: prompt = f.read().strip() except FileNotFoundError: print("Error: prompt.txt not found!") return # 获取所有 input 文件并按名称排序 input_files = sorted([f for f in os.listdir() if f.startswith("input") and f.endswith(".txt")]) if not input_files: print("No input files found!") return # 处理每个 input 文件 for input_file in input_files: print(f"Processing {input_file}...") # 读取 input 文件内容 try: with open(input_file, "r", encoding="utf-8") as f: input_text = f.read().strip() except Exception as e: print(f"Error reading {input_file}: {e}") continue # 将 prompt 和 input_text 合并到一个消息中 combined_message = f"{prompt}\n\n{input_text}" # 准备请求数据 data = { "model": "o1-mini", "messages": [ {"role": "user", "content": combined_message} ] } headers = { "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json" } try: # 发送请求,禁用 SSL 验证 respOnse= requests.post(API_URL, json=data, headers=headers, verify=False) if response.status_code == 200: # 解析响应 result = response.json()["choices"][0]["message"]["content"] # 将结果追加到 output.txt with open("output.txt", "a", encoding="utf-8") as f: f.write(f"\n=== Response for {input_file} ===\n") f.write(result) f.write("\n") print(f"Successfully processed {input_file}") else: print(f"Error processing {input_file}: {response.status_code} - {response.text}") except requests.exceptions.RequestException as e: print(f"Request error for {input_file}: {e}") except Exception as e: print(f"Unexpected error processing {input_file}: {e}") # 在处理下一个文件前等待 1 秒 time.sleep(1) print("\nAll files processed. Results saved in output.txt") if __name__ == "__main__": main() ``` |