From 3d4ec68d70499d8aed9a1565a1f0947f5696eb77 Mon Sep 17 00:00:00 2001 From: Alex Strick van Linschoten Date: Mon, 23 Jun 2025 17:40:29 +0200 Subject: [PATCH 1/5] Add OPENROUTER_API_KEY to installation instructions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default configuration uses OpenRouter models which require the OPENROUTER_API_KEY environment variable to be set. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- deep_research/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deep_research/README.md b/deep_research/README.md index 5f2b66bb..aa03937c 100644 --- a/deep_research/README.md +++ b/deep_research/README.md @@ -88,7 +88,8 @@ cd zenml_deep_research pip install -r requirements.txt # Set up API keys -export OPENAI_API_KEY=your_openai_key # Or another LLM provider key +export OPENAI_API_KEY=your_openai_key # If using OpenAI models +export OPENROUTER_API_KEY=your_openrouter_key # If using OpenRouter models (default configuration uses OpenRouter) export TAVILY_API_KEY=your_tavily_key # For Tavily search (default) export EXA_API_KEY=your_exa_key # For Exa search and MCP integration (required for MCP) export ANTHROPIC_API_KEY=your_anthropic_key # For MCP integration (required) From d4dbfe6495b5a6e613eb8f8cf481e115fbf1e35a Mon Sep 17 00:00:00 2001 From: Alex Strick van Linschoten Date: Mon, 23 Jun 2025 17:46:58 +0200 Subject: [PATCH 2/5] Fix imports in tracing_metadata_utils.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use TYPE_CHECKING to avoid runtime imports and fix import issues with langfuse client types. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- deep_research/utils/tracing_metadata_utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/deep_research/utils/tracing_metadata_utils.py b/deep_research/utils/tracing_metadata_utils.py index 59c7b37e..b5043eb8 100644 --- a/deep_research/utils/tracing_metadata_utils.py +++ b/deep_research/utils/tracing_metadata_utils.py @@ -3,15 +3,17 @@ import time from datetime import datetime, timedelta, timezone from functools import wraps -from typing import Any, Dict, List, Optional, Tuple +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple from langfuse import Langfuse from langfuse.api.core import ApiError -from langfuse.client import ObservationsView, TraceWithDetails from rich import print from rich.console import Console from rich.table import Table +if TYPE_CHECKING: + from langfuse.client import ObservationsView, TraceWithDetails + console = Console() langfuse = Langfuse() From 9e0682881ef7084b0484d0014e8568dc91722ca5 Mon Sep 17 00:00:00 2001 From: Alex Strick van Linschoten Date: Mon, 23 Jun 2025 17:52:16 +0200 Subject: [PATCH 3/5] Update dependencies and revert import changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update litellm to >=1.73.0 (remove upper bound) - Update langfuse to <3.0.0 (compatible version constraint) - Revert TYPE_CHECKING import pattern in tracing_metadata_utils.py 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- deep_research/requirements.txt | 4 ++-- deep_research/utils/tracing_metadata_utils.py | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/deep_research/requirements.txt b/deep_research/requirements.txt index a925bd6d..14df4abf 100644 --- a/deep_research/requirements.txt +++ b/deep_research/requirements.txt @@ -1,5 +1,5 @@ zenml>=0.82.0 -litellm>=1.70.0,<2.0.0 +litellm>=1.73.0 tavily-python>=0.2.8 exa-py>=1.0.0 PyYAML>=6.0 @@ -7,5 +7,5 @@ click>=8.0.0 pydantic>=2.0.0 typing_extensions>=4.0.0 requests -langfuse>=2.0.0 +langfuse<3.0.0 anthropic>=0.52.2 diff --git a/deep_research/utils/tracing_metadata_utils.py b/deep_research/utils/tracing_metadata_utils.py index b5043eb8..59c7b37e 100644 --- a/deep_research/utils/tracing_metadata_utils.py +++ b/deep_research/utils/tracing_metadata_utils.py @@ -3,17 +3,15 @@ import time from datetime import datetime, timedelta, timezone from functools import wraps -from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple +from typing import Any, Dict, List, Optional, Tuple from langfuse import Langfuse from langfuse.api.core import ApiError +from langfuse.client import ObservationsView, TraceWithDetails from rich import print from rich.console import Console from rich.table import Table -if TYPE_CHECKING: - from langfuse.client import ObservationsView, TraceWithDetails - console = Console() langfuse = Langfuse() From d7bfd078cc5203f0f8abfe6c3fb484e02fe8c333 Mon Sep 17 00:00:00 2001 From: Alex Strick van Linschoten Date: Mon, 23 Jun 2025 18:14:50 +0200 Subject: [PATCH 4/5] Hard pin litellm and langfuse --- deep_research/requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deep_research/requirements.txt b/deep_research/requirements.txt index 14df4abf..64fabdb7 100644 --- a/deep_research/requirements.txt +++ b/deep_research/requirements.txt @@ -1,5 +1,4 @@ -zenml>=0.82.0 -litellm>=1.73.0 +zenml>=0.83.1 tavily-python>=0.2.8 exa-py>=1.0.0 PyYAML>=6.0 @@ -7,5 +6,6 @@ click>=8.0.0 pydantic>=2.0.0 typing_extensions>=4.0.0 requests -langfuse<3.0.0 anthropic>=0.52.2 +litellm==1.69.1 +langfuse==2.60.8 From 9c81c0bb9a965e4bccf25dfe4803a7335d3df012 Mon Sep 17 00:00:00 2001 From: Alex Strick van Linschoten Date: Mon, 23 Jun 2025 18:15:04 +0200 Subject: [PATCH 5/5] Remove type hints --- deep_research/utils/tracing_metadata_utils.py | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/deep_research/utils/tracing_metadata_utils.py b/deep_research/utils/tracing_metadata_utils.py index 59c7b37e..aadca468 100644 --- a/deep_research/utils/tracing_metadata_utils.py +++ b/deep_research/utils/tracing_metadata_utils.py @@ -7,7 +7,6 @@ from langfuse import Langfuse from langfuse.api.core import ApiError -from langfuse.client import ObservationsView, TraceWithDetails from rich import print from rich.console import Console from rich.table import Table @@ -106,14 +105,14 @@ def wrapper(*args, **kwargs): @rate_limited @retry_with_backoff -def fetch_traces_safe(limit: Optional[int] = None) -> List[TraceWithDetails]: +def fetch_traces_safe(limit: Optional[int] = None) -> List: """Safely fetch traces with rate limiting and retry logic.""" return langfuse.fetch_traces(limit=limit).data @rate_limited @retry_with_backoff -def fetch_observations_safe(trace_id: str) -> List[ObservationsView]: +def fetch_observations_safe(trace_id: str) -> List: """Safely fetch observations with rate limiting and retry logic.""" return langfuse.fetch_observations(trace_id=trace_id).data @@ -193,7 +192,7 @@ def get_total_tokens_used(trace_id: str) -> Tuple[int, int]: return 0, 0 -def get_trace_stats(trace: TraceWithDetails) -> Dict[str, Any]: +def get_trace_stats(trace) -> Dict[str, Any]: """Get comprehensive statistics for a trace. Args: @@ -251,7 +250,7 @@ def get_trace_stats(trace: TraceWithDetails) -> Dict[str, Any]: return {} -def get_traces_by_name(name: str, limit: int = 1) -> List[TraceWithDetails]: +def get_traces_by_name(name: str, limit: int = 1) -> List: """Get traces by name using Langfuse API. Args: @@ -270,7 +269,7 @@ def get_traces_by_name(name: str, limit: int = 1) -> List[TraceWithDetails]: return [] -def get_observations_for_trace(trace_id: str) -> List[ObservationsView]: +def get_observations_for_trace(trace_id: str) -> List: """Get all observations for a specific trace. Args: @@ -289,7 +288,7 @@ def get_observations_for_trace(trace_id: str) -> List[ObservationsView]: def filter_traces_by_date_range( start_date: datetime, end_date: datetime, limit: Optional[int] = None -) -> List[TraceWithDetails]: +) -> List: """Filter traces within a specific date range. Args: @@ -330,9 +329,7 @@ def filter_traces_by_date_range( return [] -def get_traces_last_n_days( - days: int, limit: Optional[int] = None -) -> List[TraceWithDetails]: +def get_traces_last_n_days(days: int, limit: Optional[int] = None) -> List: """Get traces from the last N days. Args: @@ -349,7 +346,7 @@ def get_traces_last_n_days( def get_trace_stats_batch( - traces: List[TraceWithDetails], show_progress: bool = True + traces: List, show_progress: bool = True ) -> List[Dict[str, Any]]: """Get statistics for multiple traces efficiently with progress tracking. @@ -375,7 +372,7 @@ def get_trace_stats_batch( def get_aggregate_stats_for_traces( - traces: List[TraceWithDetails], + traces: List, ) -> Dict[str, Any]: """Calculate aggregate statistics for a list of traces. @@ -428,9 +425,7 @@ def get_aggregate_stats_for_traces( } -def display_trace_stats_table( - traces: List[TraceWithDetails], title: str = "Trace Statistics" -): +def display_trace_stats_table(traces: List, title: str = "Trace Statistics"): """Display trace statistics in a formatted table. Args: @@ -459,7 +454,7 @@ def display_trace_stats_table( console.print(table) -def identify_prompt_type(observation: ObservationsView) -> str: +def identify_prompt_type(observation) -> str: """Identify the prompt type based on keywords in the observation's input. Examines the system prompt in observation.input['messages'][0]['content']