承接 cognesy/instructor-pipeline 相关项目开发

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

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

cognesy/instructor-pipeline

最新稳定版本:v2.3.1

Composer 安装命令:

composer require cognesy/instructor-pipeline

包简介

Pipeline processing functionality for Instructor PHP library

README 文档

README

Small immutable pipelines for value transformations with Result-backed state.

What It Is

The package now exposes one pipeline implementation:

  • value-oriented steps via through() and throughAll()
  • side effects via tap() and onFailure()
  • final shaping via finally()
  • lazy execution via PendingExecution
  • immutable state via ProcessingState
  • post-processing helpers via TransformState

Basic Usage

use Cognesy\Pipeline\Pipeline;
use Cognesy\Pipeline\ProcessingState;

$result = Pipeline::builder()
    ->through(fn(string $value) => trim($value))
    ->through(fn(string $value) => strtoupper($value))
    ->create()
    ->executeWith(ProcessingState::with(' hello '))
    ->value();

Failure Handling

use Cognesy\Pipeline\StateContracts\CanCarryState;
use Cognesy\Utils\Result\Result;

$result = Pipeline::builder()
    ->through(fn() => throw new RuntimeException('broken'))
    ->onFailure(fn(CanCarryState $state) => report($state->exception()))
    ->finally(fn(CanCarryState $state) => match ($state->isSuccess()) {
        true => $state->result(),
        false => Result::failure('pipeline failed'),
    })
    ->create()
    ->executeWith(ProcessingState::with('input'))
    ->result();

State Helpers

ProcessingState stores:

  • a Result
  • ordered tags

TransformState is a small helper for mapping, recovery, and tag-preserving state transformations after pipeline execution.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固