Git Product home page Git Product logo

langfuse-js's Issues

Langchain integration

Describe the solution you'd like

Add Langchain Integration to the JS/TS SDKs which currently only exists in the Python SDKs.

Why is this important? Reducing the integration effort is key to help more people use Langfuse for their project. The Langchain intgeration (Python only) is currently the fastest way to integrate. It would be awesome if this was also usable for JS/TS Langchain projects.

I'm happy to support on this, dm on Discord

Additional context

JS SDKs: take env variables for instantiation

Currently, the Langfuse SDK is not able to take environment variables for configuration. Instead, it relies on options on the constructor.

We want to have one function, which takes params: { publicKey?: string; secretKey?: string } & LangfuseCoreOptions and returns the same type.

  • This function should have the following behavior:
    • check if values for publicKey, secretKey, or variables within LangfuseCoreOptions were provided.
    • If not, check the environment variables and take values from there.
    • If still no variable was defined, log an error if the input param was required but not provided by either the constructor or the env variable. No exception is thrown.
  • use existing getEnv utility to access environment variables
  • the following variables are available:
    • LANGFUSE_RELEASE
    • LANGFUSE_PUBLIC_KEY
    • LANGFUSE_SECRET_KEY
    • LANGFUSE_DEBUG
    • LANGFUSE_HOST
  • Please adjust all environment variables in the CI and tests to reflect the change.
  • The function should be called as first action in the two Langfuse objects (
    export class Langfuse extends LangfuseCore {
    , https://github.com/langfuse/langfuse-js/blob/04a75b406010368326bf3e12336f2a9bb9d4c210/langfuse-node/src/langfuse-node.ts#L28) and LangfuseWeb (
    export class LangfuseWeb extends LangfuseWebStateless {
    private _storage: LangfuseStorage;
    )
    • As of there, the values returned from that function will be used internally

Overview over all constructors:

  • Langfuse: constructor(params: { publicKey: string; secretKey: string } & LangfuseOptions)
  • Langfuse (node): constructor(params: { publicKey: string; secretKey: string } & LangfuseOptions)
  • LangfuseCore: constructor(params: { publicKey: string; secretKey: string } & LangfuseCoreOptions)
    • extends LangfuseCoreStateless
    • Contains additional logic to the LangfuseCoreStateless class to improve developer experience
  • LangfuseWeb: constructor(params: { publicKey: string } & LangfuseOptions)
    • export class LangfuseWeb extends LangfuseWebStateless {
      private _storage: LangfuseStorage;
    • extends LangfuseWebStateless
    • This is the SDK which our users can use in react applications
  • LangfuseWebStateless: constructor(params: { publicKey: string } & LangfuseCoreOptions)
    • extends LangfuseCoreStateless
  • LangfuseCoreStateless: constructor(params: { publicKey: string; secretKey?: string } & LangfuseCoreOptions)
    • constructor(params: { publicKey: string; secretKey?: string } & LangfuseCoreOptions) {
    • LangfuseCoreStateless is extended by LangfuseCore
    • LangfuseCoreStateless contains all API calls to our server

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.