From 4f94ec7659aaff8aad7393071b3c2a2674cbf612 Mon Sep 17 00:00:00 2001 From: Marc Klingen Date: Wed, 10 Jan 2024 01:46:32 +0100 Subject: [PATCH 1/5] feat(langfuse): add sdk_integration for analytics and debugging --- litellm/integrations/langfuse.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/litellm/integrations/langfuse.py b/litellm/integrations/langfuse.py index db410d986..c275e00a1 100644 --- a/litellm/integrations/langfuse.py +++ b/litellm/integrations/langfuse.py @@ -25,13 +25,19 @@ class LangFuseLogger: self.langfuse_host = os.getenv("LANGFUSE_HOST", "https://cloud.langfuse.com") self.langfuse_release = os.getenv("LANGFUSE_RELEASE") self.langfuse_debug = os.getenv("LANGFUSE_DEBUG") - self.Langfuse = Langfuse( - public_key=self.public_key, - secret_key=self.secret_key, - host=self.langfuse_host, - release=self.langfuse_release, - debug=self.langfuse_debug, - ) + + parameters = { + "public_key": self.public_key, + "secret_key": self.secret_key, + "host": self.langfuse_host, + "release": self.langfuse_release, + "debug": self.langfuse_debug, + } + + if Version(langfuse.version.__version__) >= Version("2.6.0"): + parameters["sdk_integration"] = "litellm" + + self.Langfuse = Langfuse(**parameters) def log_event( self, kwargs, response_obj, start_time, end_time, user_id, print_verbose From d05cad295127b3f042cd829f32a2988ffc738dca Mon Sep 17 00:00:00 2001 From: Marc Klingen Date: Thu, 14 Mar 2024 14:51:17 +0100 Subject: [PATCH 2/5] bump langfuse version number --- .circleci/config.yml | 4 ++-- docs/my-website/docs/observability/langfuse_integration.md | 2 +- docs/my-website/docs/proxy/logging.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5f3ed20ac..b8db488ac 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,7 +33,7 @@ jobs: pip install "boto3>=1.28.57" pip install "aioboto3>=12.3.0" pip install langchain - pip install "langfuse>=2.0.0" + pip install "langfuse>=2.6.3" pip install numpydoc pip install traceloop-sdk==0.0.69 pip install openai @@ -155,7 +155,7 @@ jobs: pip install "boto3>=1.28.57" pip install "aioboto3>=12.3.0" pip install langchain - pip install "langfuse>=2.0.0" + pip install "langfuse>=2.6.3" pip install numpydoc pip install prisma pip install fastapi diff --git a/docs/my-website/docs/observability/langfuse_integration.md b/docs/my-website/docs/observability/langfuse_integration.md index 294f3fb38..2c45420ed 100644 --- a/docs/my-website/docs/observability/langfuse_integration.md +++ b/docs/my-website/docs/observability/langfuse_integration.md @@ -15,7 +15,7 @@ join our [discord](https://discord.gg/wuPM9dRgDw) ## Pre-Requisites Ensure you have run `pip install langfuse` for this integration ```shell -pip install langfuse>=2.0.0 litellm +pip install langfuse>=2.6.3 litellm ``` ## Quick Start diff --git a/docs/my-website/docs/proxy/logging.md b/docs/my-website/docs/proxy/logging.md index bdd75d647..bb00172db 100644 --- a/docs/my-website/docs/proxy/logging.md +++ b/docs/my-website/docs/proxy/logging.md @@ -406,7 +406,7 @@ We will use the `--config` to set `litellm.success_callback = ["langfuse"]` this **Step 1** Install langfuse ```shell -pip install langfuse>=2.0.0 +pip install langfuse>=2.6.3 ``` **Step 2**: Create a `config.yaml` file and set `litellm_settings`: `success_callback` From 36cbef538898f629b05fa1672d5a2786f666a9e3 Mon Sep 17 00:00:00 2001 From: Marc Klingen Date: Sun, 24 Mar 2024 16:46:20 +0100 Subject: [PATCH 3/5] revert to langfuse >= 2.0.0 --- .circleci/config.yml | 2 +- docs/my-website/docs/observability/langfuse_integration.md | 2 +- docs/my-website/docs/proxy/logging.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b8db488ac..5897aca9a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,7 +33,7 @@ jobs: pip install "boto3>=1.28.57" pip install "aioboto3>=12.3.0" pip install langchain - pip install "langfuse>=2.6.3" + pip install "langfuse>=2.0.0" pip install numpydoc pip install traceloop-sdk==0.0.69 pip install openai diff --git a/docs/my-website/docs/observability/langfuse_integration.md b/docs/my-website/docs/observability/langfuse_integration.md index 2c45420ed..294f3fb38 100644 --- a/docs/my-website/docs/observability/langfuse_integration.md +++ b/docs/my-website/docs/observability/langfuse_integration.md @@ -15,7 +15,7 @@ join our [discord](https://discord.gg/wuPM9dRgDw) ## Pre-Requisites Ensure you have run `pip install langfuse` for this integration ```shell -pip install langfuse>=2.6.3 litellm +pip install langfuse>=2.0.0 litellm ``` ## Quick Start diff --git a/docs/my-website/docs/proxy/logging.md b/docs/my-website/docs/proxy/logging.md index bb00172db..bdd75d647 100644 --- a/docs/my-website/docs/proxy/logging.md +++ b/docs/my-website/docs/proxy/logging.md @@ -406,7 +406,7 @@ We will use the `--config` to set `litellm.success_callback = ["langfuse"]` this **Step 1** Install langfuse ```shell -pip install langfuse>=2.6.3 +pip install langfuse>=2.0.0 ``` **Step 2**: Create a `config.yaml` file and set `litellm_settings`: `success_callback` From e0ee94d45a7bc0209b0f8e2058e3f34cde01b21b Mon Sep 17 00:00:00 2001 From: Marc Klingen Date: Sun, 24 Mar 2024 16:46:31 +0100 Subject: [PATCH 4/5] conditionally set sdk_integration --- litellm/integrations/langfuse.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/litellm/integrations/langfuse.py b/litellm/integrations/langfuse.py index ff84d171a..af371964f 100644 --- a/litellm/integrations/langfuse.py +++ b/litellm/integrations/langfuse.py @@ -28,15 +28,19 @@ class LangFuseLogger: self.langfuse_release = os.getenv("LANGFUSE_RELEASE") self.langfuse_debug = os.getenv("LANGFUSE_DEBUG") - self.Langfuse = Langfuse( - public_key=self.public_key, - secret_key=self.secret_key, - host=self.langfuse_host, - release=self.langfuse_release, - debug=self.langfuse_debug, - flush_interval=1, # flush interval in seconds - sdk_integration="litellm", - ) + parameters = { + "public_key": self.public_key, + "secret_key": self.secret_key, + "host": self.langfuse_host, + "release": self.langfuse_release, + "debug": self.langfuse_debug, + "flush_interval": 1, + } + + if Version(langfuse.version.__version__) >= Version("2.6.0"): + parameters["sdk_integration"] = "litellm" + + self.Langfuse = Langfuse(**parameters) if os.getenv("UPSTREAM_LANGFUSE_SECRET_KEY") is not None: self.upstream_langfuse_secret_key = os.getenv( From 1167fdde746ae2469da642a8ae179a01ebb72787 Mon Sep 17 00:00:00 2001 From: Marc Klingen Date: Sat, 13 Apr 2024 01:17:02 +0200 Subject: [PATCH 5/5] revert circleci update --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5897aca9a..5f3ed20ac 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -155,7 +155,7 @@ jobs: pip install "boto3>=1.28.57" pip install "aioboto3>=12.3.0" pip install langchain - pip install "langfuse>=2.6.3" + pip install "langfuse>=2.0.0" pip install numpydoc pip install prisma pip install fastapi