# python_openai_prompt_chainofthought **Repository Path**: enzoism/python_openai_prompt_chainofthought ## Basic Information - **Project Name**: python_openai_prompt_chainofthought - **Description**: python_openai_prompt_chainofthought - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-08-31 - **Last Updated**: 2026-08-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Prompt中引导思维链 关于在Prompt中引导思维链(Chain of Thought)输出,我需要先明确一个关键前提: 对于DeepSeek-R1等推理模型:思维链是内置且默认隐藏的(通过reasoning_content字段返回),你不需要在Prompt中刻意要求“逐步思考”,因为模型会自动推理。强行要求可能反而影响输出质量。 对于DeepSeek-V3或GPT-4等通用模型:思维链是需要显式引导的,通过Prompt工程让模型展示推理步骤。 以下我针对通用模型(非推理专用模型)给出几种有效的Prompt编写方法和代码示例。 | 文件 | 对应 README 方法 | |------|------------------| | src/python_deepseek_prompt/examples/a1_explicit_instruction.py | 方法一:显式指令法 | | src/python_deepseek_prompt/examples/a2_few_shot.py | 方法二:Few-shot 示例法 | | src/python_deepseek_prompt/examples/a3_json_format.py | 方法三:强制结构化输出(JSON 格式,含两种实现) | | src/python_deepseek_prompt/examples/a4_role_setting.py | 方法四:角色设定法 | | src/python_deepseek_prompt/examples/a5_step_by_step.py | 方法五:分步追问法 | | src/python_deepseek_prompt/examples/a6_r1_reasoner.py | 针对 DeepSeek-R1 推理模型的特殊处理 | | .env.example | 环境变量配置模板 | | .gitignore | 增加 .env 忽略,防止泄露 API_KEY | | pyproject.toml | 增加 openai、python-dotenv 依赖 |