:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnableConfig
from posthog.schema import AssistantRetentionQuery
from ee.hogai.utils.types import AssistantState, PartialAssistantState
from ..schema_generator.nodes import SchemaGeneratorNode, SchemaGeneratorToolsNode
from ..schema_generator.utils import SchemaGeneratorOutput
from .prompts import RETENTION_SYSTEM_PROMPT
from .toolkit import RETENTION_SCHEMA
RetentionSchemaGeneratorOutput = SchemaGeneratorOutput[AssistantRetentionQuery]
class RetentionGeneratorNode(SchemaGeneratorNode[AssistantRetentionQuery]):
INSIGHT_NAME = "Retention"
OUTPUT_MODEL = RetentionSchemaGeneratorOutput
OUTPUT_SCHEMA = RETENTION_SCHEMA
async def arun(self, state: AssistantState, config: RunnableConfig) -> PartialAssistantState:
prompt = ChatPromptTemplate.from_messages(
[
("system", RETENTION_SYSTEM_PROMPT),
],
template_format="mustache",
)
return await super()._run_with_prompt(state, prompt, config=config)
class RetentionGeneratorToolsNode(SchemaGeneratorToolsNode):
pass