承接 hammrouni/nanoagent 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hammrouni/nanoagent

Composer 安装命令:

composer require hammrouni/nanoagent

包简介

NanoAgent is a lightweight library designed to strip away the complexity of modern AI development.

README 文档

README

Latest Version on Packagist Total Downloads License PHP Version GitHub Stars GitHub Issues

Bring the power of LLMs to your PHP application—without the bloat.

NanoAgent is a lightweight library designed to strip away the complexity of modern AI development. While other libraries force you into steep learning curves, massive dependency trees, and rigid architectural patterns, NanoAgent takes a different approach: simplicity as a feature.

Whether you are building a complex autonomous agent or just need to integrate smart decision-making into a project, NanoAgent lets you focus on the task, not the configuration.

Why NanoAgent?

The AI landscape is filled with "everything-included" frameworks that are often too heavy for practical, day-to-day PHP development.

  • Stop wrestling with complex configurations: No need to learn a new DSL (Domain-Specific Language) or manage a dozen config files.
  • Drop-in ready: Works with Laravel, Symfony, Slim, or plain PHP scripts.
  • Zero friction: Go from composer install to a working agent in minutes.

Features

  • ⚡ Adaptable: Seamlessly switch between OpenAI, Groq, Anthropic, DeepSeek, and OpenRouter with a single line of config.
  • 🛠️ Tool-First Architecture: Give your AI "hands." Easily map PHP functions as tools that your agent can intelligently execute to interact with your database, APIs, or filesystem.
  • 🎯 Goal-Oriented Execution: Define clear, context-aware tasks. The agent handles the reasoning, you handle the results.
  • 💎 Minimalist Design: A tiny footprint with massive potential. Use only what you need, with no hidden magic.

🚀 Quick Start

This guide provides step-by-step instructions for installing, configuring, and running the NanoAgent PHP library in any PHP environment.

Prerequisites

  • PHP 8.0 or higher
  • Composer installed globally

📦 Installation & Setup

  1. Initialize a project:

    mkdir my-agent-project && cd my-agent-project
    composer require hammrouni/nanoagent
  2. Configuration : Create config.php (copy the example from NanoAgent/config.php.example) in the project root to manage credentials.

    // config.php
    return [
        // API Key
        'api_key' => 'your_api_key_here',
        
        // AI Provider (groq, openai, anthropic, etc.)
        'provider' => '',
        
        // Model to use
        'model' => '',
    ];

    Then usage becomes:

    // index.php
    $config = require __DIR__ . '/config.php';
    
    $agent = new Agent(
        llm: $config
        // ... other parameters
    );
  3. Troubleshooting

  • Class not found: Run composer dump-autoload to regenerate the autoload files.
  • API Error: Check config.php or your environment variables to ensure the API key is correct.
  • PHP Version: Ensure you are running PHP 8.0+ by checking php -v.

🛠️ Advanced Usage: Tools

Give your agent "hands" by defining tools.

use NanoAgent\Tools\FunctionTool;

$calculator = new FunctionTool(
    name: 'calculator',
    description: 'Add two numbers',
    parameters: [
        'type' => 'object',
        'properties' => [
            'a' => ['type' => 'integer', 'description' => 'First number'],
            'b' => ['type' => 'integer', 'description' => 'Second number']
        ],
        'required' => ['a', 'b']
    ],
    callable: fn(array $args) => $args['a'] + $args['b']
);

$agent = new Agent(
    llm: [...], 
    tools: [$calculator]
);

📂 Examples

Check the examples/ directory for advanced use cases:

Example Description
Basic Usage Fundamental agent initialization and task execution.
Chat Stateful conversation loop using PHP Sessions.
Memory Chat Persistent conversation history saved to JSON.
Structured Output Extract JSON data from unstructured text.
Knowledge Base RAG: Ask questions against private documents.
Streaming Real-time token streaming (SSE).
Agent Chain Multi-agent workflow (Researcher feeds Writer).
Multi-Tool Orchestrate multiple tools to solve complex requests.
Advanced Tools Complex multi-step tool usage with simulated database state.
API Integration Fetch real-world data from external APIs.
Multi-Provider Switch between different AI providers programmatically.

Supported Providers

  • Groq
  • OpenAI (not tested)
  • OpenRouter (not tested)
  • Anthropic (not tested)
  • DeepSeek (not tested)

License

MIT

hammrouni/nanoagent 适用场景与选型建议

hammrouni/nanoagent 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 hammrouni/nanoagent 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 hammrouni/nanoagent 我们能提供哪些服务?
定制开发 / 二次开发

基于 hammrouni/nanoagent 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 31
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-18