langfuse.langfuse¶
Integration with Langfuse
handle_after_call(cls, fn, result, before_call, **kwargs)
¶
Adds the response to the Mirascope Langfuse observation.
handle_before_call(self, fn, *args, **kwargs)
¶
Adds metadata to the Mirascope Langfuse observation.
Source code in mirascope/langfuse/langfuse.py
langfuse_generation(fn, model_name, **kwargs)
¶
Adds metadata to the Langfuse observation.
Source code in mirascope/langfuse/langfuse.py
langfuse_generation_end(response_type=None, result=None, tool_types=None)
¶
Adds the response to the Langfuse observation.
Source code in mirascope/langfuse/langfuse.py
mirascope_langfuse_generation()
¶
Wraps a function with a Langfuse generation.
Source code in mirascope/langfuse/langfuse.py
record_streaming()
¶
Langfuse record_streaming with Mirascope providers
Source code in mirascope/langfuse/langfuse.py
with_langfuse(cls)
¶
Wraps base classes to automatically use langfuse.
Supported base classes: BaseCall
, BaseExtractor
, BaseVectorStore
,
BaseChunker
, BaseEmbedder
Example:
from mirascope.openai import OpenAICall
from mirascope.langfuse import with_langfuse
@with_langfuse
class BookRecommender(OpenAICall):
prompt_template = "Please recommend some {genre} books"
genre: str
recommender = BookRecommender(genre="fantasy")
response = recommender.call() # this will automatically get logged with Langfuse
print(response.content)