模块 1:AI 工具包基础 [Duration]() [Difficulty]() [Prerequisites]() 学习目标 完成本模块后,你将能够: ✅ 安装并配置适用于 Visual Studio Code 的 AI 工具包 ✅ 浏览模型目录,了解不同模型来源 ✅ 使用 Playground 进行模型测试和实验 ✅ 利用 Agent Builder 创建自定义 AI 代理 ✅ 对比不同提供商的模型性能 ✅ 应用提示工程的最佳实践 AI 工具包简介 (AITK) 适用于 Visual Studio Code 的 AI 工具包是微软的旗舰扩展,将 VS Code 打造为一个全面的 AI 开发环境。它连接了 AI 研究与实际应用开发,让各种技能水平的开发者都能轻松使用生成式 AI。
完成本模块后,你将能够:
适用于 Visual Studio Code 的 AI 工具包是微软的旗舰扩展,将 VS Code 打造为一个全面的 AI 开发环境。它连接了 AI 研究与实际应用开发,让各种技能水平的开发者都能轻松使用生成式 AI。
| 功能 | 描述 | 使用场景 |
|---|---|---|
| ️ 模型目录 | 访问来自 GitHub、ONNX、OpenAI、Anthropic、Google 的 100+ 模型 | 模型发现与选择 |
| ** BYOM 支持** | 集成你自己的模型(本地或远程) | 定制模型部署 |
| ** 交互式 Playground** | 通过聊天界面实时测试模型 | 快速原型设计与测试 |
| ** 多模态支持** | 处理文本、图像和附件 | 复杂 AI 应用 |
| ⚡ 批量处理 | 同时运行多个提示 | 高效测试流程 |
| ** 模型评估** | 内置指标(F1、相关性、相似度、一致性) | 性能评估 |
步骤 1:访问扩展市场
Ctrl+Shift+X 或 Cmd+Shift+X)步骤 2:选择版本
步骤 3:安装并激活
%E5%88%9D%E5%AD%A6%E8%80%85%E5%AD%A6%E4%B9%A0%E6%8C%87%E5%8D%97/aitkext.webp)
** 目标**:熟悉模型目录并测试你的第一个 AI 模型
模型目录是你进入 AI 生态系统的入口。它汇聚了多个提供商的模型,方便发现和比较。
** 导航指南:**
点击 AI 工具包侧边栏中的 MODELS - Catalog
%E5%88%9D%E5%AD%A6%E8%80%85%E5%AD%A6%E4%B9%A0%E6%8C%87%E5%8D%97/aimodel.webp)
** 小贴士**:寻找具备你用例所需特性的模型(例如代码生成、创意写作、分析)。
⚠️ 注意:GitHub 托管的模型(即 GitHub Models)免费使用,但请求和令牌有速率限制。若要访问非 GitHub 模型(例如通过 Azure AI 或其他端点托管的外部模型),需要提供相应的 API 密钥或认证信息。
模型选择策略:
** 配置流程:**
%E5%88%9D%E5%AD%A6%E8%80%85%E5%AD%A6%E4%B9%A0%E6%8C%87%E5%8D%97/playground.webp)
⚙️ 理解模型参数:
Playground 是你的 AI 实验室。以下方法能帮助你最大化其价值:
** 提示工程最佳实践:**
** 测试场景:**
# Example 1: Code Generation "Write a Python function that calculates the factorial of a number using recursion. Include error handling and docstrings." # Example 2: Creative Writing "Write a professional email to a client explaining a project delay, maintaining a positive tone while being transparent about challenges." # Example 3: Data Analysis "Analyze this sales data and provide insights: [paste your data]. Focus on trends, anomalies, and actionable recommendations."
%E5%88%9D%E5%AD%A6%E8%80%85%E5%AD%A6%E4%B9%A0%E6%8C%87%E5%8D%97/result1.webp)
** 目标**:使用相同提示对比不同模型,了解各自优势
** 操作说明:**
%E5%88%9D%E5%AD%A6%E8%80%85%E5%AD%A6%E4%B9%A0%E6%8C%87%E5%8D%97/set.webp)
%E5%88%9D%E5%AD%A6%E8%80%85%E5%AD%A6%E4%B9%A0%E6%8C%87%E5%8D%97/compare.webp)
** 关键洞察:**
** 目标**:创建针对特定任务和工作流的专业 AI 代理
Agent Builder 是 AI 工具包的核心。它允许你创建专用的 AI 助手,结合大型语言模型的能力与自定义指令、特定参数和专业知识。
** 代理架构组件:**
%E5%88%9D%E5%AD%A6%E8%80%85%E5%AD%A6%E4%B9%A0%E6%8C%87%E5%8D%97/agentbuilder.webp)
** 创建有效的系统提示:**
# Template Structure: ## Role Definition You are a [specific role] with expertise in [domain]. ## Capabilities - List specific abilities - Define scope of knowledge - Clarify limitations ## Behavior Guidelines - Response style (formal, casual, technical) - Output format preferences - Error handling approach ## Examples Provide 2-3 examples of ideal interactions
当然,你也可以使用 Generate System Prompt 让 AI 帮助生成和优化提示
** 参数优化:**
| 参数 | 推荐范围 | 使用场景 |
|---|---|---|
| Temperature | 0.1-0.3 | 技术性/事实性回答 |
| Temperature | 0.7-0.9 | 创意/头脑风暴任务 |
| Max Tokens | 500-1000 | 简洁回答 |
| Max Tokens | 2000-4000 | 详细解释 |
** 任务**:创建专门的 Python 编程助手
** 配置步骤:**
模型选择:选择 Claude 3.5 Sonnet(非常适合代码)
系统提示设计:
# Python Programming Expert Agent ## Role You are a senior Python developer with 10+ years of experience. You excel at writing clean, efficient, and well-documented Python code. ## Capabilities - Write production-ready Python code - Debug complex issues - Explain code concepts clearly - Suggest best practices and optimizations - Provide complete working examples ## Response Format - Always include docstrings - Add inline comments for complex logic - Suggest testing approaches - Mention relevant libraries when applicable ## Code Quality Standards - Follow PEP 8 style guidelines - Use type hints where appropriate - Handle exceptions gracefully - Write readable, maintainable code
%E5%88%9D%E5%AD%A6%E8%80%85%E5%AD%A6%E4%B9%A0%E6%8C%87%E5%8D%97/pythonagent.webp)
测试场景:
** 成功标准:**
测试你的理解:
** 恭喜!**你已掌握 AI 工具包的基础知识,准备好构建更高级的 AI 应用!
准备好探索更高级功能?继续学习 模块 2:基于 AI 工具包的 MCP 基础,你将学会如何:
免责声明:
本文件使用 AI 翻译服务 Co-op Translator 进行翻译。尽管我们力求准确,但请注意,自动翻译可能包含错误或不准确之处。原始语言的文件应被视为权威来源。对于重要信息,建议采用专业人工翻译。我们不对因使用本翻译而产生的任何误解或误释承担责任。