安装
逐步说明如何在您的应用中安装 Neuron 并创建智能体。
要求
安装
composer require neuron-core/neuron-ai创建一个 Agent
./vendor/bin/neuron make:agent App\\Neuron\\MyAgent.\vendor\bin\neuron make:agent App\Neuron\MyAgentnamespace App\Neuron;
use NeuronAI\Agent\Agent;
use NeuronAI\Agent\SystemPrompt;
use NeuronAI\Providers\Anthropic\Anthropic;
class MyAgent extends Agent
{
protected function provider(): AIProviderInterface
{
// 返回一个 AI 提供商(Anthropic、OpenAI、Ollama、Gemini 等)
return new Anthropic(
key: 'ANTHROPIC_API_KEY',
model: 'ANTHROPIC_MODEL',
);
}
public function instructions(): string
{
return (string) new SystemPrompt(
background: ["你是一个使用 Neuron 框架创建的友好 AI Agent。"],
);
}
}与 Agent 对话
监控与调试
Laravel 应用程序视频教程
最后更新于