概述
Copilot对话 中支持的每个 AI 模型都有不同的优势。 为了帮助你决定使用哪种模型,本文提供了常见开发人员任务的真实示例,以及示例提示、响应和指导,说明为什么特定模型非常适合。
这些示例介绍了模型在推理风格、响应深度和处理视觉输入的能力方面的差异。 使用它们来比较输出质量,并为你的特定工作流程选择合适的模型。
有关支持的模型和并排功能比较的完整列表,请参阅“AI 模型比较”。
GPT-4.1
对于受益于速度、响应能力和常规用途推理的常见开发任务,GPT-4.1 是一个不错的选择。 在处理需要广泛知识、快速迭代或基础代码理解的任务时,可以使用 GPT-4.1 模型。
示例方案
请考虑在 Python 服务中为访问控制编写辅助函数的场景。 你想添加 docstrings 来阐明函数的目的。
下面是为文档授予编辑权限的辅助函数:
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对话 的回答是不确定的,因此你可能会得到与这里所显示的不同的回答。
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 为何适合
- 该函数简短且独立,因此非常适合快速生成 docstring。
- GPT-4.1 可以识别模式,并提供清晰、简洁的说明。
- 该任务不需要深层推理或复杂逻辑。
数据变量.copilot.copilot_gpt_5_mini %}
OpenAI GPT-5 微型 是一种快速且成本高效的模型,专为简单或重复编码任务而设计。 它能以极低的延迟提供可靠、简洁的答案,非常适合用于获取实时建议和轻量级开发工作流。 GPT-5 微型 针对速度和响应能力进行了优化,因此你可以针对小型代码更改进行快速迭代,或者对简单的提示进行即时反馈。
示例方案
假设你正在构建一个实用脚本,需要筛选用户记录的列表,使结果仅包含活跃用户,并按其注册日期排序。 这项任务很简单,不需要深度推理或多步骤逻辑。
以下是用户列表的示例:
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对话 的回答是不确定的,因此你可能会得到与这里所显示的不同的回答。
# 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 微型 是一个理想的选择
- 这项任务简单直接,可通过快速、低延迟的响应高效完成。
- GPT-5 微型 针对成本和速度进行了优化,使其成为快速编辑、原型制作和实用工具代码的理想选择。
- 如果希望获得简单编码问题的可靠答案,但不想等待不必要的深度解析时,可使用此模型。
数据 变量.copilot.copilot_gpt_52 %}
示例方案
你正在设计一个购物车系统,并有一个 UML 类关系图,概述了 Cart、Product、User 和 Order 之间的关系。 你不想从头开始编写系统,而是想上传关系图的图像,并要求 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对话 的回答是不确定的,因此你可能会得到与这里所显示的不同的回答。
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 布局或窗体设计和生成的屏幕截图非常有用。
克劳德·海库 4.5
克劳德·海库 4.5 是日常编码支持的良好选择,包括编写文档、回答特定语言的问题或生成模板代码。 它提供有用的直接答案,不会过度复杂化任务。 如果你在成本约束范围内工作,则建议 克劳德·海库 4.5,因为它在 克劳德十四行诗 4.5的许多相同任务上提供可靠的性能,但资源使用率较低。
示例方案
考虑一个场景,你正在为应用程序实现单元测试和集成测试。 你希望确保测试是全面的,并涵盖你可能想到和可能没有想到的任何边缘情况。
关于方案的完整指南,请参阅 使用 GitHub Copilot 编写测试。
为什么 克劳德·海库 4.5 是一个理想的选择
- 它在测试生成、样板基架和验证逻辑等日常编码任务方面表现良好。
- 该任务倾向于多步骤推理,但仍处于较不先进模型的置信区间内,因为逻辑不太深入。
克劳德十四行诗 4.5
克劳德十四行诗 4.5 在软件开发生命周期的各个阶段都表现出色,从初始设计到 Bug 修复,从维护到优化。 它尤其适用于多文件重构或架构规划场景,在这些场景中理解跨组件的上下文非常重要。
示例方案
考虑这样一个场景:你正在用 Node.js 重写旧 COBOL 应用程序,从而使其现代化。 project涉及理解不熟悉的源代码、跨语言转换逻辑、迭代生成替换项,以及通过测试套件验证正确性。
有关场景的完整指南,请参阅 使用 GitHub Copilot 将旧代码现代化。
为什么 克劳德十四行诗 4.5 是一个理想的选择
- 克劳德十四行诗 4.5 能够很好地处理复杂的上下文,使其适用于跨多个文件或语言的工作流。
- 其混合推理体系结构使其能够在快速答案和更深入、分布式问题解决之间切换。
其他阅读材料
-
[AUTOTITLE](/copilot/reference/ai-models/model-comparison) -
[AUTOTITLE](/copilot/copilot-chat-cookbook)