任务附件
为任务附加多种文件类型,以实现全面分析。
快速开始#
克隆完整示例#
最简单的开始方式是克隆完整的示例仓库:
git clone https://github.com/astreus-ai/examples
cd examples/task-attachments
npm install或仅安装包#
如果你更喜欢从零开始构建:
npm install @astreus-ai/astreus环境配置#
# .env
OPENAI_API_KEY=sk-your-openai-api-key-here
DB_URL=sqlite://./astreus.db带有多个附件的任务#
import { Agent } from '@astreus-ai/astreus';
const agent = await Agent.create({
name: 'AnalysisAgent',
model: 'gpt-6-astra',
visionModel: 'gpt-6-astra', // Specify vision model directly
vision: true // Enable vision for images
});
// Code review task with multiple file types
const reviewTask = await agent.createTask({
prompt: `Perform a comprehensive analysis:
1. Review the code for security issues
2. Check the design mockup for usability
3. Verify dependencies are up to date
4. Review documentation completeness`,
attachments: [
{
type: 'code',
path: './src/auth/login.ts',
name: 'Login Controller',
language: 'typescript'
},
{
type: 'image',
path: './designs/login-ui.png',
name: 'Login UI Mockup'
},
{
type: 'json',
path: './package.json',
name: 'Dependencies'
},
{
type: 'markdown',
path: './docs/api.md',
name: 'API Documentation'
}
],
metadata: {
type: 'comprehensive-review',
priority: 'high'
}
});
const result = await agent.executeTask(reviewTask.id);
console.log('Analysis complete:', result.response);运行示例#
如果你克隆了仓库:
npm run dev如果你从零开始构建,请创建一个 index.ts 文件并写入上面的代码,然后运行:
npx tsx index.ts仓库#
完整示例可在 GitHub 上获取:examples/task-attachments