定制 dij-digital/langfuse-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

dij-digital/langfuse-php

最新稳定版本:v0.1.4

Composer 安装命令:

composer require dij-digital/langfuse-php

包简介

A langfuse wrapper for PHP

README 文档

README

This package provides a wrapper around the Langfuse Api, allowing you to easily integrate Langfuse into your PHP applications. It uses as few dependencies as possible.

This package supports the following features:

Prompts

  • Get text prompts
  • Get chat prompts
  • Compile text prompts
  • Compile chat prompts
  • Create text prompts
  • Create chat prompts
  • Fallback handling for prompt fetching errors
  • Fallback handling when no prompt is found

Ingestion

  • Create traces
  • Create generations

Requires PHP 8.3 or PHP 8.4

⚡️ Install the package using Composer:

composer require dij-digital/langfuse-php 

How to use this package

Prompt

use DIJ\Langfuse\PHP; use DIJ\Langfuse\PHP\Transporters\HttpTransporter; use GuzzleHttp\Client; $langfuse = new Langfuse(new HttpTransporter(new Client([ 'base_uri' => 'https://cloud.langfuse.com', //choose as needed 'auth' => ['PUBLIC_KEY', 'SECRET_KEY'], //generate a set in your project ]))); $langfuse->prompt()->text(promptName: 'promptName')->compile(params: ['key' => 'value']); $langfuse->prompt()->text(promptName: 'promptName')->compile(params: ['key' => 'value']); $langfuse->prompt()->chat(promptName: 'chatName')->compile(params: ['key' => 'value']); $langfuse->prompt()->list(); $langfuse->prompt()->create(promptName: 'promptName', prompt: 'text', type: PromptType::TEXT);

Ingestion

use DIJ\Langfuse\PHP; // Creates a trace and a generation visible in Langfuse UI $traceId = 'trace-id-123'; $langfuse->ingestion()->trace( input: 'prompt text', output: null, traceId: $traceId, name: 'name', sessionId: null, metadata: ['key' => 'value'] ); $langfuse->ingestion()->generation( input: 'prompt text', output: 'model output', traceId: $traceId, name: 'name', sessionId: null, promptName: 'promptName', promptVersion: 1, model: 'gpt-4o', modelParameters: ['temperature' => 0.7], metadata: ['key' => 'value'] );

Langfuse PHP was created by Tycho Engberink and is maintained by DIJ Digital under the MIT license.

统计信息

  • 总下载量: 1.72k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固