Skip to content

Commit 8eb9a7d

Browse files
author
kappa90
committed
refactor(ph-ai): clean up scaffolding
1 parent 38cdc20 commit 8eb9a7d

File tree

245 files changed

+654
-733
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

245 files changed

+654
-733
lines changed

ee/hogai/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ class MaxToolTaxonomyOutput(BaseModel):
234234

235235
```python
236236
from pydantic import BaseModel, Field
237-
from ee.hogai.graph.taxonomy.toolkit import TaxonomyAgentToolkit
238-
from ee.hogai.graph.taxonomy.tools import base_final_answer
237+
from ee.hogai.chat_agent.taxonomy.toolkit import TaxonomyAgentToolkit
238+
from ee.hogai.chat_agent.taxonomy.tools import base_final_answer
239239
from posthog.models import Team
240240
241241
@@ -276,9 +276,9 @@ class YourToolkit(TaxonomyAgentToolkit):
276276
```python
277277
from langchain_core.prompts import ChatPromptTemplate
278278
from posthog.models import Team, User
279-
from ee.hogai.graph.taxonomy.nodes import TaxonomyAgentNode, TaxonomyAgentToolsNode
280-
from ee.hogai.graph.taxonomy.agent import TaxonomyAgent
281-
from ee.hogai.graph.taxonomy.types import TaxonomyAgentState
279+
from ee.hogai.chat_agent.taxonomy.nodes import TaxonomyAgentNode, TaxonomyAgentToolsNode
280+
from ee.hogai.chat_agent.taxonomy.agent import TaxonomyAgent
281+
from ee.hogai.chat_agent.taxonomy.types import TaxonomyAgentState
282282
283283
class LoopNode(TaxonomyAgentNode[TaxonomyAgentState, TaxonomyAgentState[MaxToolTaxonomyOutput]]):
284284
def __init__(self, team: Team, user: User, toolkit_class: type[YourToolkit]):

ee/hogai/api/serializers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
from posthog.api.shared import UserBasicSerializer
99
from posthog.exceptions_capture import capture_exception
1010

11-
from ee.hogai.chat_agent.graph import AssistantGraph
12-
from ee.hogai.graph.deep_research.graph import DeepResearchAssistantGraph
13-
from ee.hogai.graph.deep_research.types import DeepResearchState
11+
from ee.hogai.chat_agent import AssistantGraph
12+
from ee.hogai.research_agent.graph import DeepResearchAssistantGraph
13+
from ee.hogai.research_agent.types import DeepResearchState
1414
from ee.hogai.utils.helpers import should_output_assistant_message
1515
from ee.hogai.utils.types import AssistantState
1616
from ee.hogai.utils.types.composed import AssistantMaxGraphState

ee/hogai/api/test/test_serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from posthog.schema import AssistantMessage, AssistantToolCallMessage, ContextMessage
55

66
from ee.hogai.api.serializers import ConversationSerializer
7-
from ee.hogai.chat_agent.graph import AssistantGraph
7+
from ee.hogai.chat_agent import AssistantGraph
88
from ee.hogai.utils.types import AssistantState
99
from ee.models.assistant import Conversation
1010

ee/hogai/chat_agent/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .graph import AssistantGraph
2+
3+
__all__ = ["AssistantGraph"]

ee/hogai/graph/dashboards/nodes.py renamed to ee/hogai/chat_agent/dashboards/nodes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
from posthog.sync import database_sync_to_async
2121
from posthog.utils import pluralize
2222

23-
from ee.hogai.graph.base import AssistantNode
24-
from ee.hogai.graph.parallel_task_execution.mixins import (
23+
from ee.hogai.chat_agent.parallel_task_execution.mixins import (
2524
WithInsightCreationTaskExecution,
2625
WithInsightSearchTaskExecution,
2726
)
28-
from ee.hogai.graph.parallel_task_execution.nodes import BaseTaskExecutorNode, TaskExecutionInputTuple
29-
from ee.hogai.graph.shared_prompts import HYPERLINK_USAGE_INSTRUCTIONS
27+
from ee.hogai.chat_agent.parallel_task_execution.nodes import BaseTaskExecutorNode, TaskExecutionInputTuple
28+
from ee.hogai.core.node import AssistantNode
29+
from ee.hogai.core.shared_prompts import HYPERLINK_USAGE_INSTRUCTIONS
3030
from ee.hogai.llm import MaxChatOpenAI
3131
from ee.hogai.utils.helpers import build_dashboard_url, build_insight_url, cast_assistant_query
3232
from ee.hogai.utils.types import AssistantState, PartialAssistantState
File renamed without changes.
File renamed without changes.

ee/hogai/graph/dashboards/test/test_nodes.py renamed to ee/hogai/chat_agent/dashboards/test/test_nodes.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from posthog.models import Dashboard, Insight, Team, User
1010

11-
from ee.hogai.graph.dashboards.nodes import DashboardCreationExecutorNode, DashboardCreationNode, QueryMetadata
11+
from ee.hogai.chat_agent.dashboards.nodes import DashboardCreationExecutorNode, DashboardCreationNode, QueryMetadata
1212
from ee.hogai.utils.helpers import build_dashboard_url, build_insight_url
1313
from ee.hogai.utils.types import AssistantState, PartialAssistantState
1414
from ee.hogai.utils.types.base import (
@@ -163,7 +163,7 @@ def test_build_dashboard_url(self):
163163
expected_url = f"/project/{self.mock_team.id}/dashboard/{dashboard_id}"
164164
assert url == expected_url
165165

166-
@patch("ee.hogai.graph.dashboards.nodes.DashboardCreationExecutorNode")
166+
@patch("ee.hogai.chat_agent.dashboards.nodes.DashboardCreationExecutorNode")
167167
async def test_arun_missing_search_insights_queries(self, mock_executor_node_class):
168168
"""Test arun returns error when search_insights_queries is missing."""
169169
mock_executor_node = MagicMock()
@@ -183,7 +183,7 @@ async def test_arun_missing_search_insights_queries(self, mock_executor_node_cla
183183
assert isinstance(result.messages[0], AssistantToolCallMessage)
184184
assert "Search insights queries are required" in result.messages[0].content
185185

186-
@patch("ee.hogai.graph.dashboards.nodes.DashboardCreationExecutorNode")
186+
@patch("ee.hogai.chat_agent.dashboards.nodes.DashboardCreationExecutorNode")
187187
@patch.object(DashboardCreationNode, "_search_insights")
188188
@patch.object(DashboardCreationNode, "_create_insights")
189189
@patch.object(DashboardCreationNode, "_create_dashboard_with_insights")
@@ -238,7 +238,7 @@ async def test_arun_successful_flow(
238238
assert "Dashboard Created" in result.messages[0].content
239239
assert "Test Dashboard" in result.messages[0].content
240240

241-
@patch("ee.hogai.graph.dashboards.nodes.DashboardCreationExecutorNode")
241+
@patch("ee.hogai.chat_agent.dashboards.nodes.DashboardCreationExecutorNode")
242242
@patch.object(DashboardCreationNode, "_search_insights")
243243
@patch.object(DashboardCreationNode, "_create_insights")
244244
async def test_arun_no_insights_found_or_created(
@@ -275,9 +275,9 @@ async def test_arun_no_insights_found_or_created(
275275
assert isinstance(result.messages[0], AssistantToolCallMessage)
276276
assert "No existing insights matched" in result.messages[0].content
277277

278-
@patch("ee.hogai.graph.dashboards.nodes.DashboardCreationExecutorNode")
278+
@patch("ee.hogai.chat_agent.dashboards.nodes.DashboardCreationExecutorNode")
279279
@patch.object(DashboardCreationNode, "_search_insights")
280-
@patch("ee.hogai.graph.dashboards.nodes.logger")
280+
@patch("ee.hogai.chat_agent.dashboards.nodes.logger")
281281
async def test_arun_exception_handling(self, mock_logger, mock_search_insights, mock_executor_node_class):
282282
"""Test arun handles exceptions properly."""
283283
mock_executor_node = MagicMock()
@@ -338,7 +338,7 @@ def test_create_no_insights_response(self):
338338

339339
def test_create_error_response(self):
340340
"""Test _create_error_response creates correct error message."""
341-
with patch("ee.hogai.graph.dashboards.nodes.capture_exception") as mock_capture:
341+
with patch("ee.hogai.chat_agent.dashboards.nodes.capture_exception") as mock_capture:
342342
result = self.node._create_error_response("Test error", "test_tool_call_id")
343343

344344
assert isinstance(result, PartialAssistantState)
@@ -363,7 +363,7 @@ def setUp(self):
363363
node_path=(NodePath(name="test_node", message_id="test-id", tool_call_id="test_tool_call_id"),),
364364
)
365365

366-
@patch("ee.hogai.graph.dashboards.nodes.DashboardCreationExecutorNode")
366+
@patch("ee.hogai.chat_agent.dashboards.nodes.DashboardCreationExecutorNode")
367367
async def test_create_insights(self, mock_executor_node_class):
368368
"""Test _create_insights method."""
369369
# Setup mocks
@@ -411,7 +411,7 @@ async def mock_process_insight_creation_results(tool_calls, task_results, query_
411411
assert len(result["task_1"].created_insight_ids) == 2
412412
assert len(result["task_1"].created_insight_messages) == 1
413413

414-
@patch("ee.hogai.graph.dashboards.nodes.DashboardCreationExecutorNode")
414+
@patch("ee.hogai.chat_agent.dashboards.nodes.DashboardCreationExecutorNode")
415415
async def test_search_insights(self, mock_executor_node_class):
416416
"""Test _search_insights method."""
417417
# Setup mocks
@@ -451,7 +451,7 @@ async def test_search_insights(self, mock_executor_node_class):
451451
assert len(result["task_1"].found_insight_ids) == 2
452452
assert len(result["task_1"].found_insight_messages) == 2
453453

454-
@patch("ee.hogai.graph.dashboards.nodes.database_sync_to_async")
454+
@patch("ee.hogai.chat_agent.dashboards.nodes.database_sync_to_async")
455455
async def test_create_dashboard_with_insights(self, mock_db_sync):
456456
"""Test _create_dashboard_with_insights method."""
457457

File renamed without changes.

0 commit comments

Comments
 (0)