Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: langfuse integration #3530

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies = [
"markupsafe>=2.1.5",
"megaparse-sdk>=0.1.9",
"langchain-mistralai>=0.2.3",
"langfuse>=2.57.0",
]
readme = "README.md"
requires-python = ">= 3.11"
Expand Down
7 changes: 6 additions & 1 deletion core/quivr_core/rag/quivr_rag_langgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
from langgraph.types import Send
from pydantic import BaseModel, Field

from langfuse.callback import CallbackHandler

from quivr_core.llm import LLMEndpoint
from quivr_core.llm_tools.llm_tools import LLMToolFactory
from quivr_core.rag.entities.chat import ChatHistory
Expand All @@ -48,6 +50,9 @@

logger = logging.getLogger("quivr_core")

# Initialize Langfuse CallbackHandler for Langchain (tracing)
langfuse_handler = CallbackHandler()


class SplittedInput(BaseModel):
instructions_reasoning: Optional[str] = Field(
Expand Down Expand Up @@ -943,7 +948,7 @@ async def answer_astream(
"files": concat_list_files,
},
version="v1",
config={"metadata": metadata},
config={"metadata": metadata, "callbacks": [langfuse_handler]},
):
if self._is_final_node_with_docs(event):
tasks = event["data"]["output"]["tasks"]
Expand Down
12 changes: 12 additions & 0 deletions core/requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ anthropic==0.40.0
anyio==4.6.2.post1
# via anthropic
# via httpx
# via langfuse
# via openai
appnope==0.1.4
# via ipykernel
asttokens==2.4.1
# via stack-data
attrs==24.2.0
# via aiohttp
backoff==2.2.1
# via langfuse
black==24.10.0
# via flake8-black
certifi==2024.8.30
Expand Down Expand Up @@ -90,6 +93,7 @@ httpx==0.27.2
# via anthropic
# via cohere
# via langchain-mistralai
# via langfuse
# via langgraph-sdk
# via langsmith
# via megaparse-sdk
Expand All @@ -108,6 +112,7 @@ identify==2.6.1
idna==3.10
# via anyio
# via httpx
# via langfuse
# via requests
# via yarl
iniconfig==2.0.0
Expand Down Expand Up @@ -159,6 +164,8 @@ langchain-openai==0.2.11
# via quivr-core
langchain-text-splitters==0.3.2
# via langchain
langfuse==2.57.0
# via quivr-core
langgraph==0.2.38
# via quivr-core
langgraph-checkpoint==2.0.1
Expand Down Expand Up @@ -219,6 +226,7 @@ packaging==24.1
# via huggingface-hub
# via ipykernel
# via langchain-core
# via langfuse
# via marshmallow
# via pytest
# via transformers
Expand Down Expand Up @@ -266,6 +274,7 @@ pydantic==2.9.2
# via langchain-cohere
# via langchain-core
# via langchain-mistralai
# via langfuse
# via langsmith
# via openai
# via pydantic-settings
Expand Down Expand Up @@ -315,6 +324,7 @@ requests==2.32.3
# via huggingface-hub
# via langchain
# via langchain-community
# via langfuse
# via langsmith
# via requests-toolbelt
# via tiktoken
Expand Down Expand Up @@ -397,5 +407,7 @@ virtualenv==20.26.6
# via pre-commit
wcwidth==0.2.13
# via prompt-toolkit
wrapt==1.17.0
# via langfuse
yarl==1.15.3
# via aiohttp
12 changes: 12 additions & 0 deletions core/requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ anthropic==0.40.0
anyio==4.6.2.post1
# via anthropic
# via httpx
# via langfuse
# via openai
attrs==24.2.0
# via aiohttp
backoff==2.2.1
# via langfuse
certifi==2024.8.30
# via httpcore
# via httpx
Expand Down Expand Up @@ -64,6 +67,7 @@ httpx==0.27.2
# via anthropic
# via cohere
# via langchain-mistralai
# via langfuse
# via langgraph-sdk
# via langsmith
# via megaparse-sdk
Expand All @@ -80,6 +84,7 @@ huggingface-hub==0.25.2
idna==3.10
# via anyio
# via httpx
# via langfuse
# via requests
# via yarl
jiter==0.6.1
Expand Down Expand Up @@ -119,6 +124,8 @@ langchain-openai==0.2.11
# via quivr-core
langchain-text-splitters==0.3.2
# via langchain
langfuse==2.57.0
# via quivr-core
langgraph==0.2.38
# via quivr-core
langgraph-checkpoint==2.0.1
Expand Down Expand Up @@ -165,6 +172,7 @@ packaging==24.1
# via faiss-cpu
# via huggingface-hub
# via langchain-core
# via langfuse
# via marshmallow
# via transformers
pandas==2.2.3
Expand All @@ -187,6 +195,7 @@ pydantic==2.9.2
# via langchain-cohere
# via langchain-core
# via langchain-mistralai
# via langfuse
# via langsmith
# via openai
# via pydantic-settings
Expand Down Expand Up @@ -221,6 +230,7 @@ requests==2.32.3
# via huggingface-hub
# via langchain
# via langchain-community
# via langfuse
# via langsmith
# via requests-toolbelt
# via tiktoken
Expand Down Expand Up @@ -283,5 +293,7 @@ tzdata==2024.2
urllib3==2.2.3
# via requests
# via types-requests
wrapt==1.17.0
# via langfuse
yarl==1.15.3
# via aiohttp
Loading