Created
October 22, 2024 09:16
-
-
Save sauercrowd/f92135da9dec57d66fbf820232dff87a to your computer and use it in GitHub Desktop.
Langfuse - llamaindex integrations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. https://docs.llamaindex.ai/en/v0.10.23/examples/callbacks/LangfuseCallbackHandler/#option-1-set-global-llamaindex-handler | |
from llama_index.core import global_handler, set_global_handler | |
set_global_handler("langfuse") | |
langfuse_callback_handler = global_handler | |
# 2. https://docs.llamaindex.ai/en/v0.10.23/examples/callbacks/LangfuseCallbackHandler/#option-2-use-langfuse-callback-directly | |
from llama_index.core import Settings | |
from llama_index.core.callbacks import CallbackManager | |
from langfuse.llama_index import LlamaIndexCallbackHandler | |
langfuse_callback_handler = LlamaIndexCallbackHandler() | |
Settings.callback_manager = CallbackManager([langfuse_callback_handler]) | |
# 3. https://langfuse.com/docs/integrations/llama-index/example-python-instrumentation-module | |
from langfuse.llama_index import LlamaIndexInstrumentor | |
instrumentor = LlamaIndexInstrumentor() | |
instrumentor.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment