使用我们全面的SDK为Adverant Nexus构建强大的插件
npm install @adverant-nexus/sdk
SDK兼容Node.js 18+并包含TypeScript类型定义。
pip install adverant-nexus-sdk
Python SDK需要Python 3.9或更高版本。
插件通过Model Context Protocol (MCP)扩展Nexus,提供AI代理可以发现和使用的工具、资源和提示词。
Nexus Client提供对核心平台服务的访问:
import { NexusClient } from '@adverant-nexus/sdk'
const nexus = new NexusClient({
apiKey: process.env.BRAIN_API_KEY
})
// Access GraphRAG memory
await nexus.graphrag.storeMemory({
content: 'Important information',
tags: ['customer', 'analysis']
})
// Orchestrate sub-agents
await nexus.agents.orchestrate({
task: 'Analyze customer feedback',
agents: ['sentiment', 'summarization']
})import { NexusPluginServer, Tool } from '@adverant-nexus/sdk/server'
const server = new NexusPluginServer({
name: 'my-plugin',
version: '1.0.0',
description: 'My awesome plugin'
})
// Define a tool
server.tool(new Tool({
name: 'analyze_data',
description: 'Analyzes data and returns insights',
inputSchema: {
type: 'object',
properties: {
data: { type: 'array' },
options: { type: 'object' }
},
required: ['data']
},
execute: async (input) => {
// Your implementation
return { insights: [...] }
}
}))
// Start the server
await server.start()// GraphRAG Memory
await nexus.graphrag.storeMemory({ content, tags })
await nexus.graphrag.query({ query, limit: 10 })
// Agent Orchestration
await nexus.agents.orchestrate({ task, agents })
// Learning System
await nexus.learning.recordPattern({ pattern, feedback })一个提供问候工具的基础插件:
import { NexusPluginServer, Tool } from '@adverant-nexus/sdk/server'
const server = new NexusPluginServer({
name: 'greeter',
version: '1.0.0'
})
server.tool(new Tool({
name: 'greet',
description: 'Greets a user by name',
inputSchema: {
type: 'object',
properties: {
name: { type: 'string' }
},
required: ['name']
},
execute: async ({ name }) => {
return { message: `Hello, ${name}!` }
}
}))
await server.start()