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

Changes langfuse LLM API call tracing to generation #397

Merged
merged 2 commits into from
Dec 20, 2024
Merged
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
5 changes: 3 additions & 2 deletions cognee/infrastructure/llm/openai/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from cognee.infrastructure.llm.prompts import read_query_prompt
from cognee.base_config import get_base_config

if MonitoringTool.LANGFUSE:
monitoring = get_base_config().monitoring_tool
if monitoring == MonitoringTool.LANGFUSE:
from langfuse.decorators import observe
Comment on lines +15 to 17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Inconsistent monitoring configuration pattern needs attention

The configuration-based approach for monitoring tool selection is not consistently implemented across the codebase:

  • cognee/infrastructure/llm/openai/adapter.py (reviewed file): Uses configuration with conditional import at module level
  • cognee/infrastructure/llm/generic_llm_api/adapter.py: Uses configuration check inside a method with inline import
  • cognee/api/v1/cognify/code_graph_pipeline.py: Uses direct configuration check at module level similar to reviewed file
  • cognee/base_config.py: Sets LANGFUSE as default monitoring tool

The codebase shows three different patterns for handling the monitoring tool configuration and imports. These should be unified for better maintainability.

🔗 Analysis chain

LGTM! Verify consistent usage of monitoring configuration.

Good improvement moving from hardcoded check to configuration-based approach for monitoring tool selection.

Let's verify consistent usage of monitoring configuration across the codebase:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other direct MonitoringTool.LANGFUSE checks that might need similar updates
rg -l "MonitoringTool\.LANGFUSE"

# Search for other langfuse imports that might need to be conditional
rg "from langfuse"

Length of output: 505


Script:

#!/bin/bash
# Check how MonitoringTool.LANGFUSE is used in other files
rg -A 5 "MonitoringTool\.LANGFUSE" cognee/infrastructure/llm/generic_llm_api/adapter.py cognee/base_config.py cognee/api/v1/cognify/code_graph_pipeline.py

# Check the context of langfuse imports in other files
rg -B 2 -A 2 "from langfuse" cognee/infrastructure/llm/generic_llm_api/adapter.py cognee/api/v1/cognify/code_graph_pipeline.py

Length of output: 2938


class OpenAIAdapter(LLMInterface):
Expand Down Expand Up @@ -43,7 +44,7 @@ def __init__(
base_config = get_base_config()


@observe()
@observe(as_type='generation')
async def acreate_structured_output(self, text_input: str, system_prompt: str,
response_model: Type[BaseModel]) -> BaseModel:

Expand Down
Loading