https://github.com/langfuse/langfuse Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Resources + Customer Stories + White papers, Ebooks, Webinars + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. {{ message }} langfuse / langfuse Public * Notifications * Fork 24 * Star 466 Open source observability and analytics for LLM applications langfuse.com License View license 466 stars 24 forks Activity Star Notifications * Code * Issues 3 * Pull requests 3 * Actions * Security * Insights More * Code * Issues * Pull requests * Actions * Security * Insights langfuse/langfuse This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 7 branches 0 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/l] Use Git or checkout with SVN using the web URL. [gh repo clone langfu] Work fast with our official CLI. Learn more about the CLI. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @marcklingen marcklingen Readme ... 765f33b Aug 29, 2023 Readme 765f33b Git stats * 301 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .github codespell: workflow to prevent typos, fix some (#82) August 17, 2023 03:15 .vscode Readme (#98) August 23, 2023 19:12 ee Add ee readme May 23, 2023 16:50 fern fix missing name in span update (#101) August 26, 2023 16:12 generated fix missing name in span update (#101) August 26, 2023 16:12 prisma Improve trace UI (#95) August 22, 2023 10:41 public fixes June 1, 2023 23:39 src add filters to traces table param (#106) August 27, 2023 19:20 types Add feature flagging (#47) July 17, 2023 23:16 .codespellrc codespell: workflow to prevent typos, fix some (#82) August 17, 2023 03:15 .dockerignore docerize May 23, 2023 11:31 .env.cloud.example add token calculation for davinci (#96) August 22, 2023 14:09 .env.dev.example env files May 25, 2023 12:16 .env.local.example search traces (#46) July 11, 2023 12:32 .eslintrc.cjs init May 18, 2023 21:08 .gitignore openapi spec in /public July 18, 2023 19:42 .nvmrc add nvmrc May 21, 2023 02:18 Dockerfile Remove middleware from self-host builds August 23, 2023 01:36 LICENSE psuh May 23, 2023 16:33 README.md Readme August 29, 2023 21:08 components.json Add feedback to mobile and upgrade shadcn-ui (#30) June 23, 2023 23:40 demo_thumbnail.jpg Update readme (#13) June 8, 2023 09:43 docker-compose.build.yml Run tests in GH Actions (#87) August 17, 2023 02:54 docker-compose.dev.yml Add trace metadata filters (#104) August 26, 2023 08:49 docker-compose.yml Build docker image, CI seeder, improve docker run instructions (#86) August 16, 2023 22:15 jest.config.mjs add tests (#76) August 10, 2023 20:33 next.config.mjs add tests (#76) August 10, 2023 20:33 package-lock.json Edgeconfig for blocking of ips (cloud) August 23, 2023 01:03 package.json Edgeconfig for blocking of ips (cloud) August 23, 2023 01:03 postcss.config.cjs init May 18, 2023 21:08 prettier.config.cjs init May 18, 2023 21:08 readme_walkthrough_thumbnail.png Update readme (#13) June 8, 2023 09:43 sentry.client.config.ts Capture feedback (#27) June 23, 2023 18:58 sentry.edge.config.ts Add sentry to langfuse cloud (#25) June 23, 2023 12:10 sentry.server.config.ts add prisma client to sentry July 2, 2023 16:30 tailwind.config.ts Add feedback to mobile and upgrade shadcn-ui (#30) June 23, 2023 23:40 tsconfig.json add tests (#76) August 10, 2023 20:33 View code [ ] Langfuse Open source observability & analytics for LLM-based applications What is Langfuse? Observability Analytics Get started Step 1: Run Server Langfuse Cloud Localhost Self-host (Docker) Step 2: Data ingestion Langchain applications SDKs to manually instrument application Add scores/evaluations to traces (optional) API Questions / Feedback Contributing to Langfuse Development setup License Misc Upgrade Langfuse (localhost) Run Langfuse in CI for integration tests README.md Langfuse Open source observability & analytics for LLM-based applications Observability: Explore and debug complex logs & traces in a visual UI Analytics: Measure & improve costs, latency and response quality Join the Langfuse Discord >> langfuse.com * Docs * Report Bug * Feature Request MIT License Discord Github Repo Stars CI test status Checkly Status Y Combinator W23 Docker Image langfuse npm package langfuse Python package on PyPi What is Langfuse? Langfuse is an open source observability & analytics solution for LLM-based applications. It is mostly geared towards production usage but some users also use it for local development of their LLM applications. Langfuse is focused on applications built on top of LLMs. Many new abstractions and common best practices evolved recently, e.g. agents, chained prompts, embedding-based retrieval, LLM access to REPLs & APIs. These make applications more powerful but also unpredictable for developers as they cannot fully anticipate how changes impact the quality, cost and overall latency of their application. Thus Langfuse helps to monitor and debug these applications. Demo (2 min) langfuse_demo_2_min.mp4 Muted by default, enable sound for voice-over Explore demo project in Langfuse here (free account required): https: //langfuse.com/demo Observability Langfuse offers an admin UI to explore the ingested data. * Nested view of LLM app executions; detailed information along the traces on: latency, cost, scores * Segment execution traces by user feedback, to e.g. identify production issues Analytics Reporting on * Token usage by model * Volume of traces * Scores/evals Broken down by * Users * Releases * Prompt/chain versions * Prompt/chain types * Time - Expect releases with more ways to analyze the data over the next weeks. Get started Step 1: Run Server Langfuse Cloud Managed deployment by the Langfuse team, generous free-tier (hobby plan) available, no credit card required. Links: Create account, learn more Localhost Requirements: Docker, Node.js >=18, npm # Clone repository git clone git@github.com:langfuse/langfuse.git cd langfuse # Run server and database docker compose up -d # Apply db migrations DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres DIRECT_URL=postgresql://postgres:postgres@localhost:5432/postgres npx prisma migrate deploy Self-host (Docker) - Instructions Step 2: Data ingestion Langchain applications The Langfuse callback handler automatically instruments Langchain applications. Currently available for Python, JS/TS support is in progress (add +1 to issue here). 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="= 18, Edge runtimes docs, repo npm package JS/TS: Node <18 docs, repo Add scores/evaluations to traces (optional) Quality/evaluation of traces is tracked via scores (docs). Scores are related to traces and optionally to observations. Scores can be added via: * Backend SDKs (see docs above): {trace, event, span, generation}.score() * API (see docs below): POST /api/public/scores * Client-side using Web SDK, e.g. to capture user feedback or other user-based quality metrics: 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 (
); } API Api reference * POST/PATCH routes to ingest data * GET routes to use data in downstream applications (e.g. embedded analytics) Questions / Feedback The maintainers are very active in the Langfuse Discord and are happy to answer questions or discuss feedback/ideas regarding the future of the project. Contributing to Langfuse Join the community on Discord. To contribute, send us a PR, raise a github issue, or email at contributing@langfuse.com Development setup Requirements: Node.js >=18, npm, Docker # Install dependencies npm install # Run the db docker-compose -f docker-compose.dev.yml up -d # create an env file cp .env.dev.example .env # Migration npm run db:migrate # Optional: seed the database # npm run db:seed # npm run db:seed:examples # Start the server npm run dev License Langfuse is MIT licensed, except for ee/ folder. See LICENSE and docs for more details. Misc Upgrade Langfuse (localhost) # Stop server and db docker compose down # Pull latest changes git pull docker-compose pull # Run server and db docker compose up -d # Apply db migrations DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres DIRECT_URL=postgresql://postgres:postgres@localhost:5432/postgres npx prisma migrate deploy Run Langfuse in CI for integration tests Checkout GitHub Actions workflows of Python SDK and JS/TS SDK. About Open source observability and analytics for LLM applications langfuse.com Resources Readme License View license Activity Stars 466 stars Watchers 5 watching Forks 24 forks Report repository Releases No releases published Packages 1 Contributors 5 * @marcklingen * @maxdeichmann * @clemra * @yarikoptic * @tonoy30 Languages * TypeScript 97.3% * JavaScript 1.5% * Other 1.2% Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time.