Astreus

カスタムプラグイン

Astreusのドキュメントでカスタムプラグインについて学び、エージェントシステムを構築するためのセットアップの手引き、APIのパターン、実践的な例を確認しましょう。 信頼性の高いAstreusエージェントシステムを構築するために必要なセットアップのパターン、API、実践的な例を学びましょう。

エージェント用のツールを備えたカスタムプラグインを作成・登録します。

クイックスタート

完全なサンプルをクローンする

最も簡単な始め方は、完全なサンプルリポジトリをクローンすることです。

git clone https://github.com/astreus-ai/examples
cd examples/custom-plugins
npm install

またはパッケージのみをインストール

ゼロから構築したい場合は次のようにします。

npm install @astreus-ai/astreus

環境設定

# .env
OPENAI_API_KEY=sk-your-openai-api-key-here
DB_URL=sqlite://./astreus.db

カスタム天気プラグイン

import { Agent, ToolDefinition, PluginDefinition } from '@astreus-ai/astreus';

// Define a custom tool
const weatherTool: ToolDefinition = {
  name: 'get_weather',
  description: 'Get current weather for a location',
  parameters: {
    location: {
      name: 'location',
      type: 'string',
      description: 'City name',
      required: true
    },
    units: {
      name: 'units',
      type: 'string',
      description: 'Temperature units (celsius or fahrenheit)',
      required: false,
      enum: ['celsius', 'fahrenheit']
    }
  },
  handler: async (params) => {
    // Simulate weather API call
    const weather = {
      temperature: 22,
      conditions: 'sunny',
      location: params.location as string
    };

    return {
      success: true,
      data: weather
    };
  }
};

// Create plugin
const weatherPlugin: PluginDefinition = {
  name: 'weather-plugin',
  version: '1.0.0',
  description: 'Weather information tools',
  tools: [weatherTool]
};

// Create agent and register plugin
const agent = await Agent.create({
  name: 'WeatherAgent',
  model: 'gpt-4o'
});

await agent.registerPlugin(weatherPlugin);

// Use the plugin in conversation
const response = await agent.ask("What's the weather like in Tokyo?");
console.log(response); // Agent automatically uses the weather tool

サンプルの実行

リポジトリをクローンした場合は次を実行します。

npm run dev

ゼロから構築した場合は、上記のコードを含むindex.tsファイルを作成し、次を実行します。

npx tsx index.ts

リポジトリ

完全なサンプルはGitHubで公開されています: examples/custom-plugins

最終更新日: 2026年7月6日

このセクション内

最初のエージェント

Astreusのドキュメントで最初のエージェントについて学び、エージェントシステムを構築するためのセットアップの手引き、APIのパターン、実践的な例を確認しましょう。 信頼性の高いAstreusエージェントシステムを構築するために必要なセットアップのパターン、API、実践的な例を学びましょう。

メモリを使ったエージェント

Astreusのドキュメントでメモリを使ったエージェントについて学び、エージェントシステムを構築するためのセットアップの手引き、APIのパターン、実践的な例を確認しましょう。 信頼性の高いAstreusエージェントシステムを構築するために必要なセットアップのパターン、API、実践的な例を学びましょう。

ナレッジを使ったエージェント

Astreusのドキュメントでナレッジを使ったエージェントについて学び、エージェントシステムを構築するためのセットアップの手引き、APIのパターン、実践的な例を確認しましょう。 信頼性の高いAstreusエージェントシステムを構築するために必要なセットアップのパターン、API、実践的な例を学びましょう。

ビジョンを使ったエージェント

Astreusのドキュメントでビジョンを使ったエージェントについて学び、エージェントシステムを構築するためのセットアップの手引き、APIのパターン、実践的な例を確認しましょう。 信頼性の高いAstreusエージェントシステムを構築するために必要なセットアップのパターン、API、実践的な例を学びましょう。