Skip to content

Commit

Permalink
Merge pull request raga-ai-hub#65 from aristotle-ai/source_hashid_fix
Browse files Browse the repository at this point in the history
fix for source hash_id
  • Loading branch information
pakhale-2012 authored Jan 17, 2025
2 parents 06bdd4c + 9c68e39 commit d7c8c43
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
12 changes: 6 additions & 6 deletions ragaai_catalyst/tracers/agentic_tracing/data/data_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,16 @@ def to_dict(self):
}

class LLMComponent(Component):
def __init__(self, id: str, hash_id: str, type: str, name: str, start_time: str, end_time: str, parent_id: int, info: Dict[str, Any], data: Dict[str, Any], network_calls: Optional[List[NetworkCall]] = None, interactions: Optional[List[Union[Interaction, Dict]]] = None, error: Optional[Dict[str, Any]] = None):
super().__init__(id, hash_id, type, name, start_time, end_time, parent_id, info, data, network_calls, interactions, error)
def __init__(self, id: str, hash_id: str, source_hash_id: str, type: str, name: str, start_time: str, end_time: str, parent_id: int, info: Dict[str, Any], data: Dict[str, Any], network_calls: Optional[List[NetworkCall]] = None, interactions: Optional[List[Union[Interaction, Dict]]] = None, error: Optional[Dict[str, Any]] = None):
super().__init__(id, hash_id, source_hash_id, type, name, start_time, end_time, parent_id, info, data, network_calls, interactions, error)

class AgentComponent(Component):
def __init__(self, id: str, hash_id: str, type: str, name: str, start_time: str, end_time: str, parent_id: int, info: Dict[str, Any], data: Dict[str, Any], network_calls: Optional[List[NetworkCall]] = None, interactions: Optional[List[Union[Interaction, Dict]]] = None, error: Optional[Dict[str, Any]] = None):
super().__init__(id, hash_id, type, name, start_time, end_time, parent_id, info, data, network_calls, interactions, error)
def __init__(self, id: str, hash_id: str, source_hash_id: str, type: str, name: str, start_time: str, end_time: str, parent_id: int, info: Dict[str, Any], data: Dict[str, Any], network_calls: Optional[List[NetworkCall]] = None, interactions: Optional[List[Union[Interaction, Dict]]] = None, error: Optional[Dict[str, Any]] = None):
super().__init__(id, hash_id, source_hash_id, type, name, start_time, end_time, parent_id, info, data, network_calls, interactions, error)

class ToolComponent(Component):
def __init__(self, id: str, hash_id: str, type: str, name: str, start_time: str, end_time: str, parent_id: int, info: Dict[str, Any], data: Dict[str, Any], network_calls: Optional[List[NetworkCall]] = None, interactions: Optional[List[Union[Interaction, Dict]]] = None, error: Optional[Dict[str, Any]] = None):
super().__init__(id, hash_id, type, name, start_time, end_time, parent_id, info, data, network_calls, interactions, error)
def __init__(self, id: str, hash_id: str, source_hash_id: str, type: str, name: str, start_time: str, end_time: str, parent_id: int, info: Dict[str, Any], data: Dict[str, Any], network_calls: Optional[List[NetworkCall]] = None, interactions: Optional[List[Union[Interaction, Dict]]] = None, error: Optional[Dict[str, Any]] = None):
super().__init__(id, hash_id, source_hash_id, type, name, start_time, end_time, parent_id, info, data, network_calls, interactions, error)

@dataclass
class ComponentInfo:
Expand Down
8 changes: 5 additions & 3 deletions ragaai_catalyst/tracers/agentic_tracing/tracers/base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import imp
import json
import os
import platform
Expand Down Expand Up @@ -633,7 +634,7 @@ def format_interactions(self) -> dict:
if span.interactions:
for span_interaction in span.interactions:
interaction = {}
interaction["id"] = str(span_interaction.id)
interaction["id"] = str(interaction_id)
interaction["span_id"] = span.id
interaction["interaction_type"] = span_interaction.type
interaction["content"] = span_interaction.content
Expand All @@ -644,8 +645,9 @@ def format_interactions(self) -> dict:

if span.network_calls:
for span_network_call in span.network_calls:
import pdb; pdb.set_trace()
network_call = {}
network_call["id"] = str(span_interaction.id)
network_call["id"] = str(interaction_id)
network_call['span_id'] = span.id
network_call["interaction_type"] = "network_call"
network_call["name"] = None
Expand All @@ -661,7 +663,7 @@ def format_interactions(self) -> dict:
"body": span_network_call.get("response_body"),
}
}
network_call["timestamp"] = span_network_call['start_time']
network_call["timestamp"] = span_network_call.get('timestamp')
network_call["error"] = span_network_call.get('error')
interactions.append(network_call)
interaction_id += 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def process_component(component):
def add_component(self, component_data: dict, is_error: bool = False):
"""Add a component to the trace data"""
# Convert dict to appropriate Component type
filtered_data = {k: v for k, v in component_data.items() if k in ["id", "hash_id", "type", "name", "start_time", "end_time", "parent_id", "info", "data", "network_calls", "interactions", "error"]}
filtered_data = {k: v for k, v in component_data.items() if k in ["id", "hash_id", "source_hash_id", "type", "name", "start_time", "end_time", "parent_id", "info", "data", "network_calls", "interactions", "error"]}

if component_data["type"] == "llm":
component = LLMComponent(**filtered_data)
Expand Down

0 comments on commit d7c8c43

Please sign in to comment.