token27/nexus-ai-content
Composer 安装命令:
composer require token27/nexus-ai-content
包简介
Generic content orchestration layer for NexusAI workflows, prompts, tracking, pricing, and domain extensions.
README 文档
README
A framework-agnostic, workflow-first PHP 8.3+ content orchestration layer for the NexusAI ecosystem. Compose versioned prompts, AI drivers, resumable workflows, tracking, pricing, and domain extensions behind one fluent API.
Why nexus-ai-content?
Article generation, social posts, newsletters, scripts, product descriptions, and future content types all need the same foundation:
- choose a content type and workflow
- resolve versioned prompts from
nexus-ai-prompts - execute nodes through
nexus-ai-workflows - call providers through
nexus-ai - track every run through
nexus-ai-tracking - calculate cost and enforce budgets through
nexus-ai-pricing - keep domain packages focused on their domain instead of infrastructure
nexus-ai-content is that shared layer. It is intentionally not an article generator. Article logic belongs in nexus-ai-content-articles.
Features
- Engine + Builder + Registry pattern consistent with the NexusAI libraries.
- Fluent content API for provider/model selection, workflow selection, variables, language, run id, tracking, pricing, and budgets.
- Workflow registry keyed by
contentType/workflowName. - Prompt-aware AI node with
ContentAINode. - Tracking-ready execution with run id, prompt id, prompt version, content type, workflow, provider, model, tokens, cost, and latency.
- Pricing-ready execution with post-request cost calculation and optional pre-request budget checks.
- Extension bootstrap so packages like
nexus-ai-content-articlescan register workflows cleanly. - Test-friendly driver injection through
withDriver().
Installation
composer require token27/nexus-ai-content
Requires: PHP 8.3+ and the core NexusAI packages listed in composer.json.
Quick Start
use Token27\NexusAI\Content\ContentEngine; use Token27\NexusAI\Content\Node\ContentAINode; use Token27\NexusAI\Workflows\Engine\WorkflowBuilder; $workflow = WorkflowBuilder::named('default') ->addNode('draft', new ContentAINode( promptIdentifier: 'content/draft', outputKey: 'content', promptVersion: '1.0.0', )) ->build(); $engine = ContentEngine::create() ->withPromptRegistry($promptRegistry) ->withTracking($tracking) ->withPricing($pricing); $engine->getRegistry()->register('article', $workflow); $result = $engine ->for('openai', 'gpt-4o-mini') ->withContentType('article') ->withLanguage('es') ->withVariable('topic', 'Calidad de contenido con IA') ->withBudget(0.25) ->generate(); echo $result->text;
For tests, inject a pre-built driver:
$result = $engine ->for('fake', 'test-model') ->withContentType('article') ->withDriver($fakeDriver) ->generate();
Documentation
| Guide | Description |
|---|---|
| Documentation Home | Full documentation map |
| Installation | Composer, dependencies, and first setup |
| Quick Start | First workflow with a fake driver |
| Fluent API | Engine and builder methods |
| Workflows | Registering and running content workflows |
| Prompts | Using nexus-ai-prompts with ContentAINode |
| Tracking and Pricing | Telemetry, costs, budgets, and tokenizer notes |
| Extending | Creating domain extensions |
| Testing | Testing content workflows and nodes |
| Contributing | Development setup and collaboration rules |
| Architecture | Why this package exists before article domains |
| Troubleshooting | Common failures and fixes |
Examples
The examples/ directory contains runnable production-style examples that read .env, configure real providers through NexusAI, load prompts, enable pricing, and optionally write tracking events:
- 00-openai-draft.php
- 01-anthropic-outline.php
- 02-gemini-spanish.php
- 03-deepseek-budget.php
- 04-tracking-jsonfile.php
- 05-custom-openai-compatible.php
- 06-testing-fake-driver.php
- 07-openai-raw-prompt.php
Quality Gates
composer validate --strict vendor/bin/php-cs-fixer fix --dry-run --diff vendor/bin/phpstan analyse --level=8 src tests vendor/bin/phpunit
License
MIT. See LICENSE.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-22