typespec-create-agent
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate TypeSpec Declarative Agent
创建TypeSpec声明式Agent
Create a complete TypeSpec declarative agent for Microsoft 365 Copilot with the following structure:
为Microsoft 365 Copilot创建一个完整的TypeSpec声明式Agent,需遵循以下结构:
Requirements
要求
Generate a file with:
main.tsp-
Agent Declaration
- Use decorator with a descriptive name and description
@agent - Name should be 100 characters or less
- Description should be 1,000 characters or less
- Use
-
Instructions
- Use decorator with clear behavioral guidelines
@instructions - Define the agent's role, expertise, and personality
- Specify what the agent should and shouldn't do
- Keep under 8,000 characters
- Use
-
Conversation Starters
- Include 2-4 decorators
@conversationStarter - Each with a title and example query
- Make them diverse and showcase different capabilities
- Include 2-4
-
Capabilities (based on user needs)
- - for web content with optional site scoping
WebSearch - - for document access with URL filtering
OneDriveAndSharePoint - - for Teams channel/chat access
TeamsMessages - - for email access with folder filtering
Email - - for organization people search
People - - for Python code execution
CodeInterpreter - - for image generation
GraphicArt - - for Copilot connector content
GraphConnectors - - for Dataverse data access
Dataverse - - for meeting content access
Meetings
生成一个文件,包含:
main.tsp-
Agent声明
- 使用装饰器,包含描述性名称和说明
@agent - 名称长度不超过100个字符
- 说明长度不超过1000个字符
- 使用
-
指令
- 使用装饰器,定义清晰的行为准则
@instructions - 明确Agent的角色、专业能力和个性
- 指定Agent可以做和不可以做的事情
- 内容长度不超过8000个字符
- 使用
-
对话起始项
- 包含2-4个装饰器
@conversationStarter - 每个装饰器包含标题和示例查询语句
- 确保起始项多样化,展示不同的功能
- 包含2-4个
-
功能配置(基于用户需求)
- - 用于网页内容搜索,支持可选的站点范围限定
WebSearch - - 用于访问文档,支持URL过滤
OneDriveAndSharePoint - - 用于访问Teams频道/聊天内容
TeamsMessages - - 用于访问邮件,支持文件夹过滤
Email - - 用于组织内人员搜索
People - - 用于执行Python代码
CodeInterpreter - - 用于生成图片
GraphicArt - - 用于Copilot连接器内容访问
GraphConnectors - - 用于访问Dataverse数据
Dataverse - - 用于访问会议内容
Meetings
Template Structure
模板结构
typescript
import "@typespec/http";
import "@typespec/openapi3";
import "@microsoft/typespec-m365-copilot";
using TypeSpec.Http;
using TypeSpec.M365.Copilot.Agents;
@agent({
name: "[Agent Name]",
description: "[Agent Description]"
})
@instructions("""
[Detailed instructions about agent behavior, role, and guidelines]
""")
@conversationStarter(#{
title: "[Starter Title 1]",
text: "[Example query 1]"
})
@conversationStarter(#{
title: "[Starter Title 2]",
text: "[Example query 2]"
})
namespace [AgentName] {
// Add capabilities as operations here
op capabilityName is AgentCapabilities.[CapabilityType]<[Parameters]>;
}typescript
import "@typespec/http";
import "@typespec/openapi3";
import "@microsoft/typespec-m365-copilot";
using TypeSpec.Http;
using TypeSpec.M365.Copilot.Agents;
@agent({
name: "[Agent Name]",
description: "[Agent Description]"
})
@instructions("""
[Detailed instructions about agent behavior, role, and guidelines]
""")
@conversationStarter(#{
title: "[Starter Title 1]",
text: "[Example query 1]"
})
@conversationStarter(#{
title: "[Starter Title 2]",
text: "[Example query 2]"
})
namespace [AgentName] {
// Add capabilities as operations here
op capabilityName is AgentCapabilities.[CapabilityType]<[Parameters]>;
}Best Practices
最佳实践
- Use descriptive, role-based agent names (e.g., "Customer Support Assistant", "Research Helper")
- Write instructions in second person ("You are...")
- Be specific about the agent's expertise and limitations
- Include diverse conversation starters that showcase different features
- Only include capabilities the agent actually needs
- Scope capabilities (URLs, folders, etc.) when possible for better performance
- Use triple-quoted strings for multi-line instructions
- 使用描述性的、基于角色的Agent名称(例如:"Customer Support Assistant"、"Research Helper")
- 指令使用第二人称撰写("你是...")
- 明确说明Agent的专业能力和局限性
- 包含多样化的对话起始项,展示不同功能
- 仅添加Agent实际需要的功能
- 尽可能限定功能范围(如URL、文件夹等)以提升性能
- 多行指令使用三引号字符串
Examples
示例流程
Ask the user:
- What is the agent's purpose and role?
- What capabilities does it need?
- What knowledge sources should it access?
- What are typical user interactions?
Then generate the complete TypeSpec agent definition.
询问用户以下问题:
- Agent的用途和角色是什么?
- 它需要哪些功能?
- 它应该访问哪些知识源?
- 典型的用户交互场景有哪些?
然后生成完整的TypeSpec Agent定义。