Giter Club home page Giter Club logo

yuanzhongqiao / langfuse-cn Goto Github PK

View Code? Open in Web Editor NEW

This project forked from langfuse/langfuse

0.0 0.0 0.0 4.43 MB

🪢 开源 LLM 可观察性、分析、提示管理、评估、测试、监控、日志记录、跟踪、LLMOps。🕵️‍♂️ Langfuse:LLM 工程平台。一起调试、分析和迭代 - 🍊YC W23 🤖 稳定的 SDK + Typescript、Python、OpenAI、Langchain、Litellm、Flowise、Superagent 和 Langflow 的集成

Home Page: https://langfuse.com

License: Other

Shell 0.11% JavaScript 1.12% TypeScript 98.19% CSS 0.18% PLpgSQL 0.13% Dockerfile 0.27%

langfuse-cn's Introduction

🪢朗福斯

基于 LLM 的应用程序的开源可观测性和分析

可观察性:在可视化 UI 中探索和调试复杂的日志和跟踪
分析:衡量和改善成本、延迟和响应质量


麻省理工学院许可证 不和谐 Github 仓库明星 langfuse 发布 CI 测试状态 正常运行时间状态 Y 组合器 W23 Docker 镜像 langfuse npm 包 PyPi 上的 langfuse Python 包


朗福斯是什么?

Langfuse 是一个针对基于 LLM 的应用程序的开源可观测性和分析解决方案。它主要面向生产用途,但一些用户也将其用于 LLM 应用程序的本地开发。

Langfuse 专注于基于法学硕士构建的应用程序。最近出现了许多新的抽象和常见的最佳实践,例如代理、链式提示、基于嵌入的检索、LLM 对 REPL 和 API 的访问。这些使得应用程序更加强大,但对于开发人员来说也是不可预测的,因为他们无法完全预测变化如何影响其应用程序的质量、成本和总体延迟。因此,Langfuse 有助于监控和调试这些应用程序。

演示(2 分钟)

langfuse_demo_2_min.mp4
langfuse_demo_2_min.mp4

默认静音,启用画外音声音

在这里探索 Langfuse 中的演示项目(需要免费帐户):https://langfuse.com/demo

可观测性

Langfuse 提供了一个管理 UI 来探索提取的数据。

  • LLM 应用程序执行的嵌套视图;跟踪的详细信息:延迟、成本、分数
  • 根据用户反馈分段执行跟踪,例如识别生产问题

分析

报告

  • 按模型划分的令牌使用情况
  • 痕迹量
  • 分数/评估

细分为

  • 用户
  • 发布
  • 提示/连锁版本
  • 提示/链类型
  • 时间

→ 预计未来几周将发布更多分析数据的方法。

开始使用

第 1 步:运行服务器

朗弗斯云

由 Langfuse 团队管理部署,提供慷慨的免费套餐(爱好计划),无需信用卡。

链接:创建帐户了解更多

本地主机

要求:docker、docker compose(例如使用 Docker Desktop)

# Clone repository
git clone https://github.com/langfuse/langfuse.git
cd langfuse

# Run server and database docker compose up -d

自托管(Docker)

→ 说明

部署在铁路上

第 2 步:数据摄取

用于仪器应用的 SDK

完全异步、类型化的 SDK 用于检测任何 LLM 应用程序。目前可用于 Python 和 JS/TS。

→包含如何使用 SDK 的示例指南

包裹 描述 链接
PyPI版本 Python 文档,存储库
npm版本 JS/TS:节点 >= 18,边缘运行时 文档,存储库
npm 包 JS/TS:节点 <18 文档,存储库

朗链应用

Langfuse 回调处理程序自动检测 Langchain 应用程序。目前可用于 Python 和 JS/TS。

Python

pip install langfuse
# Initialize Langfuse handler
from langfuse.callback import CallbackHandler
handler = CallbackHandler(PUBLIC_KEY, SECRET_KEY)

# Setup Langchain from langchain.chains import LLMChain ... chain = LLMChain(llm=llm, prompt=prompt)

# Add Langfuse handler as callback chain.run(input="<user_input", callbacks=[handler])

Python 的 Langchain 集成文档

JS/TS

JS/TS 的 Langchain 集成文档

将分数/评估添加到迹线中(可选)

痕迹的质量/评估通过分数(文档)进行跟踪。分数与痕迹相关,并且可选地与观察结果相关。分数可以通过以下方式添加:

  • 后端 SDK(请参阅上面的文档):{trace, event, span, generation}.score()

  • API(请参阅下面的文档):POST /api/public/scores

  • 客户端使用 Web SDK,例如捕获用户反馈或其他基于用户的质量指标:

    npm install langfuse
    // Client-side (browser)
    

    import { LangfuseWeb } from "langfuse";

    const langfuseWeb = new LangfuseWeb({ publicKey: process.env.LANGFUSE_PUBLIC_KEY, });

    // frontend handler (example: React) export function UserFeedbackComponent(props: { traceId: string }) { const handleUserFeedback = async (value: number) => { await langfuseWeb.score({ traceId: props.traceId, name: "user_feedback", value, }); }; return ( <div> <button onClick={() => handleUserFeedback(1)}>👍</button> <button onClick={() => handleUserFeedback(-1)}>👎</button> </div> ); }

    <clipboard-copy aria-label="Copy" class="ClipboardButton btn btn-invisible js-clipboard-copy m-2 p-0 tooltipped-no-delay d-flex flex-justify-center flex-items-center" data-copy-feedback="Copied!" data-tooltip-direction="w" value="// Client-side (browser)

    import { LangfuseWeb } from "langfuse";

    const langfuseWeb = new LangfuseWeb({ publicKey: process.env.LANGFUSE_PUBLIC_KEY, });

    // frontend handler (example: React) export function UserFeedbackComponent(props: { traceId: string }) { const handleUserFeedback = async (value: number) => { await langfuseWeb.score({ traceId: props.traceId, name: "user_feedback", value, }); }; return (

    <button onClick={() => handleUserFeedback(1)}>👍 <button onClick={() => handleUserFeedback(-1)}>👎
    ); }" tabindex="0" role="button">

应用程序编程接口

API参考

  • POST/PATCH 路由来摄取数据
  • 在下游应用程序中使用数据的 GET 路由(例如嵌入式分析)

问题/反馈

维护者在 Langfuse Discord中非常活跃,并且很乐意回答问题或讨论有关项目未来的反馈/想法。

为 Langfuse 做出贡献

加入Discord社区。

如需贡献,请向我们发送 PR、提出 GitHub 问题或发送电子邮件至[email protected]

开发设置

有关如何设置开发环境的详细信息,请参阅CONTRIBUTING.md 。

执照

Langfuse 已获得 MIT 许可,文件夹除外ee/。有关更多详细信息,请参阅许可证文档

杂项

升级 Langfuse (本地主机)

# Stop server and db
docker compose down

# Pull latest changes git pull docker-compose pull

# Run server and db docker compose up -d

<clipboard-copy aria-label="Copy" class="ClipboardButton btn btn-invisible js-clipboard-copy m-2 p-0 tooltipped-no-delay d-flex flex-justify-center flex-items-center" data-copy-feedback="Copied!" data-tooltip-direction="w" value="# Stop server and db docker compose down

Pull latest changes

git pull docker-compose pull

Run server and db

docker compose up -d" tabindex="0" role="button">

在 CI 中运行 Langfuse 进行集成测试

查看Python SDKJS/TS SDK的 GitHub Actions 工作流程。

遥测

默认情况下,Langfuse 会自动向**服务器 (PostHog) 报告基本使用情况统计数据。

这有助于我们:

  1. 了解 Langfuse 的使用方式并改进最相关的功能。
  2. 跟踪内部和外部(例如筹款)报告的总体使用情况。

所有数据均不与第三方共享,也不包含任何敏感信息。我们希望对此保持高度透明,您可以在这里找到我们收集的确切数据。

您可以通过设置选择退出TELEMETRY_ENABLED=false

langfuse-cn's People

Contributors

marcklingen avatar maxdeichmann avatar dependabot[bot] avatar clemra avatar tameemasim avatar richardkruemmel avatar flxwu avatar diwakarkashyap avatar yuanzhongqiao avatar frankendeba avatar jhlopen avatar khareyash05 avatar p5 avatar gokuljs avatar strernd avatar dev-khant avatar gyliu513 avatar singhcoder avatar eltociear avatar ushuz avatar tonoy30 avatar simonstorms avatar knok16 avatar yarikoptic avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.