概览
Copilot Chat 支持的每个 AI 模型都有不同的优势。为帮助您决定使用哪个模型,本文提供了常见开发者任务的真实案例示例,包括示例提示、响应以及为何特定模型适合的指导。
这些示例展示了模型在推理方式、响应深度以及处理视觉输入能力方面的差异。使用它们来比较输出质量,并为您的特定工作流选择合适的模型。
欲查看受支持模型的完整列表及并排功能比较,请参见 AI 模型比较。
GPT-4.1
GPT-4.1 是常见开发任务的良好选择,这些任务受益于速度、响应性和通用推理能力。如果您正在处理需要广泛知识、快速迭代或基本代码理解的任务,GPT-4.1 可能是适合的模型。
示例情景
设想您正在为 Python 服务编写访问控制的辅助函数。您想添加文档字符串以阐明函数的用途。
下面是授予文档编辑访问权限的辅助函数
def grant_editor_access(user_id, doc_id):
access = AccessManager()
access.assign_role(
resource_type="document",
resource_id=doc_id,
role="editor",
user_id=user_id
)
示例提示
Add a docstring to the function that explains what it does.
def grant_editor_access(user_id, doc_id):
access = AccessManager()
access.assign_role(
resource_type="document",
resource_id=doc_id,
role="editor",
user_id=user_id
)
Add a docstring to the function that explains what it does.
Add a docstring to the function that explains what it does.
示例回复
注意
以下响应为示例。Copilot Chat 的回复具有不确定性,您可能会得到与此处显示的不同的响应。
def grant_editor_access(user_id, doc_id):
"""
Grants editor access to a specific document for a given user.
This function uses the AccessManager to assign the "editor" role
to the specified user for the provided document ID.
Args:
user_id (str): The ID of the user to grant access to.
doc_id (str): The ID of the document to which access is being granted.
"""
access = AccessManager()
access.assign_role(
resource_type="document",
resource_id=doc_id,
role="editor",
user_id=user_id
)
为什么 GPT-4.1 适合
- 该函数简短且独立,非常适合快速生成文档字符串。
- GPT-4.1 能识别该模式并提供清晰、简洁的解释。
- 此任务不需要深度推理或复杂逻辑。
GPT-5 mini
OpenAI GPT-5 mini 是一种快速、成本高效的模型,专为简单或重复的编码任务设计。它提供可靠、简洁的答案,延迟极低,适用于实时建议和轻量开发工作流。GPT-5 mini 针对速度和响应性进行优化,使您能够快速迭代小的代码更改或即时获取对直接提示的反馈。
示例情景
假设您正在编写实用脚本,需要过滤用户记录列表,仅保留活跃用户,并按注册日期排序。该任务简单,不需要深度推理或多步骤逻辑。
以下是示例用户列表
users = [
{"name": "Alice", "active": True, "signup_date": "2023-12-10"},
{"name": "Bob", "active": False, "signup_date": "2023-11-05"},
{"name": "Charlie", "active": True, "signup_date": "2024-01-15"}
]
示例提示
Filter the list of users to only include active users, and sort them by signup_date.
users = [
{"name": "Alice", "active": True, "signup_date": "2023-12-10"},
{"name": "Bob", "active": False, "signup_date": "2023-11-05"},
{"name": "Charlie", "active": True, "signup_date": "2024-01-15"}
]
Filter the list of users to only include active users, and sort them by signup_date.
Filter the list of users to only include active users, and sort them by signup_date.
示例回复
注意
以下响应为示例。Copilot Chat 的回复具有不确定性,您可能会得到与此处显示的不同的响应。
# Filter to only include active users
active_users = [user for user in users if user["active"]]
# Sort active users by signup_date
active_users_sorted = sorted(active_users, key=lambda user: user["signup_date"])
print(active_users_sorted)
为什么 GPT-5 mini 适合
- 该任务直接明了,受益于快速、低延迟的响应。
- GPT-5 mini 为成本和速度进行优化,非常适合快速编辑、原型设计和实用代码。
- 当您需要对简单编码问题获得可靠答案且不想等待不必要的深度时,请使用此模型。
GPT-5.2
GPT-5.2 支持图像输入,开发者可以在 UI 检查、图表分析或布局调试等任务中引入视觉上下文。这使得 GPT-5.2 在需要图像输入提升问题解决的场景中尤为有用,例如让 Copilot 分析 UI 截图的可访问性问题或帮助理解布局中的视觉错误。
示例情景
您正在设计一个购物车系统,并拥有一个描述 Cart、Product、User 和 Order 之间关系的 UML 类图。您不想从头编写系统,而是想上传图像并让 Copilot 生成类代码。

示例提示
Use this UML diagram to generate the classes for a shopping cart system.
Use this UML diagram to generate the classes for a shopping cart system.
示例回复
注意
以下响应为示例。Copilot Chat 的回复具有不确定性,您可能会得到与此处显示的不同的响应。
Copilot 将为图中的每个类生成相应的类代码,包括它们之间的关系。以下是为 Cart 类生成的示例代码
from cart_item import CartItem
from order import Order
class Cart:
def __init__(self, cart_id, user_id):
self.cart_id = cart_id
self.user_id = user_id
self.items = []
def add_item(self, item):
self.items.append(item)
def remove_item(self, item):
self.items = [i for i in self.items if i != item]
def calculate_total(self):
return sum(item.quantity * item.product.price for item in self.items)
def place_order(self):
# Implementation for placing an order
return Order("", None, 0)
为什么 GPT-5.2 适合
- 它能够解释视觉资产,如 UML 图、线框图或流程图,以生成代码脚手架或提供架构建议。
- 它可用于审查 UI 布局或表单设计的截图并生成相应代码。
Claude Haiku 4.5
Claude Haiku 4.5 是日常编码支持的良好选择——包括编写文档、回答特定语言问题或生成样板代码。它提供有帮助、直接的答案,不会让任务过于复杂。如果您在成本受限的情况下工作,建议使用 Claude Haiku 4.5,因为它在许多与 Claude Sonnet 4.5 相同的任务上表现稳健,但资源使用更低。
示例情景
设想您正在为一个应用实现单元测试和集成测试。您希望确保测试全面,覆盖所有可能的边缘情况,无论是否已考虑到。
完整的操作流程请参见 使用 GitHub Copilot 编写测试。
为什么 Claude Haiku 4.5 适合
- 它在日常编码任务上表现良好,例如测试生成、样板代码搭建和验证逻辑。
- 该任务涉及多步骤推理,但由于逻辑并不深,仍在较低级模型的可靠范围内。
Claude Sonnet 4.5
Claude Sonnet 4.5 在软件开发全生命周期中表现卓越,从初始设计到错误修复、维护再到优化。它特别适合跨文件重构或架构规划,因为这需要对组件间上下文的深入理解。
示例情景
设想您正在通过将遗留的 COBOL 应用重写为 Node.js 来进行现代化改造。该项目涉及理解陌生的源代码、跨语言转换逻辑、迭代构建替代实现,并通过测试套件验证正确性。
完整的操作流程请参见 使用 GitHub Copilot 现代化遗留代码。
为什么 Claude Sonnet 4.5 适合
- Claude Sonnet 4.5 能很好地处理复杂上下文,适用于跨多个文件或语言的工作流。
- 其混合推理架构使其能够在快速回答和更深入的逐步问题解决之间切换。