Skip to content

Commit

Permalink
fix(max): Make it not default to bold number (#26476)
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes authored Nov 28, 2024
1 parent 3c340ee commit 81a2d9c
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 28 deletions.
5 changes: 2 additions & 3 deletions ee/hogai/eval/tests/test_eval_funnel_generator.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from langgraph.graph.state import CompiledStateGraph
from pydantic import BaseModel

from ee.hogai.assistant import AssistantGraph
from ee.hogai.eval.utils import EvalBaseTest
from ee.hogai.utils import AssistantNodeName
from posthog.schema import HumanMessage
from posthog.schema import AssistantFunnelsQuery, HumanMessage


class TestEvalFunnelGenerator(EvalBaseTest):
def _call_node(self, query: str, plan: str) -> BaseModel:
def _call_node(self, query: str, plan: str) -> AssistantFunnelsQuery:
graph: CompiledStateGraph = (
AssistantGraph(self.team)
.add_edge(AssistantNodeName.START, AssistantNodeName.FUNNEL_GENERATOR)
Expand Down
23 changes: 20 additions & 3 deletions ee/hogai/eval/tests/test_eval_trends_generator.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from langgraph.graph.state import CompiledStateGraph
from pydantic import BaseModel

from ee.hogai.assistant import AssistantGraph
from ee.hogai.eval.utils import EvalBaseTest
from ee.hogai.utils import AssistantNodeName
from posthog.schema import HumanMessage
from posthog.schema import AssistantTrendsQuery, HumanMessage


class TestEvalTrendsGenerator(EvalBaseTest):
def _call_node(self, query: str, plan: str) -> BaseModel:
def _call_node(self, query: str, plan: str) -> AssistantTrendsQuery:
graph: CompiledStateGraph = (
AssistantGraph(self.team)
.add_edge(AssistantNodeName.START, AssistantNodeName.TRENDS_GENERATOR)
Expand All @@ -34,3 +33,21 @@ def test_node_replaces_equals_with_contains(self):
assert "icontains" in actual_output
assert "John" not in actual_output
assert "john" in actual_output

def test_node_leans_towards_line_graph(self):
query = "How often do users download files?"
# We ideally want to consider both total count of downloads per period, as well as how often a median user downloads
plan = """Events:
- downloaded_file
- math operation: total count
- downloaded_file
- math operation: median count per user
"""
actual_output = self._call_node(query, plan)
assert actual_output.trendsFilter.display == "ActionsLineGraph"
assert actual_output.series[0].kind == "EventsNode"
assert actual_output.series[0].event == "downloaded_file"
assert actual_output.series[0].math == "total"
assert actual_output.series[1].kind == "EventsNode"
assert actual_output.series[1].event == "downloaded_file"
assert actual_output.series[1].math == "median_count_per_actor"
2 changes: 1 addition & 1 deletion ee/hogai/trends/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
- 95th percentile
- 99th percentile
Available math aggregation types counting by users who completed an event are:
Available math aggregation types counting number of events completed per user (intensity of usage) are:
- average
- minimum
- maximum
Expand Down
2 changes: 1 addition & 1 deletion ee/hogai/trends/toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def generate_trends_schema() -> dict:
schema = AssistantTrendsQuery.model_json_schema()
return {
"name": "output_insight_schema",
"description": "Outputs the JSON schema of a funnel insight",
"description": "Outputs the JSON schema of a trends insight",
"parameters": {
"type": "object",
"properties": {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/queries/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@
},
"display": {
"default": "ActionsLineGraph",
"description": "Changes the visualization type. `ActionsLineGraph` - if the user wants to see dynamics in time like a line graph. Prefer this option. `ActionsLineGraphCumulative` - if the user wants to see cumulative dynamics across time. `ActionsBarValue` - if the data is categorical and needs to be visualized as a bar chart. `ActionsBar` - if the data is categorical and can be visualized as a stacked bar chart. `ActionsPie` - if the data is easy to understand in a pie chart. `BoldNumber` - if the user asks a question where you can answer with a single number. You can't use this option with breakdowns. `ActionsTable` - if the user wants to see a table. `ActionsAreaGraph` - if the data is better visualized in an area graph. `WorldMap` - if the user has only one series and wants to see data from particular countries. It can only be used with the `$geoip_country_name` breakdown.",
"description": "Visualization type. Available values: `ActionsLineGraph` - time-series line chart; most common option, as it shows change over time. `ActionsBar` - time-series bar chart. `ActionsAreaGraph` - time-series area chart. `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics. `BoldNumber` - total value single large number. You can't use this with breakdown; use when user explicitly asks for a single output number. `ActionsBarValue` - total value (NOT time-series) bar chart; good for categorical data. `ActionsPie` - total value pie chart; good for visualizing proportions. `ActionsTable` - total value table; good when using breakdown to list users or other entities. `WorldMap` - total value world map; use when breaking down by country name using property `$geoip_country_name`, and only then.",
"enum": [
"ActionsLineGraph",
"ActionsBar",
Expand Down
20 changes: 10 additions & 10 deletions frontend/src/queries/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1098,16 +1098,16 @@ export interface AssistantTrendsFilter {
formula?: TrendsFilterLegacy['formula']

/**
* Changes the visualization type.
* `ActionsLineGraph` - if the user wants to see dynamics in time like a line graph. Prefer this option.
* `ActionsLineGraphCumulative` - if the user wants to see cumulative dynamics across time.
* `ActionsBarValue` - if the data is categorical and needs to be visualized as a bar chart.
* `ActionsBar` - if the data is categorical and can be visualized as a stacked bar chart.
* `ActionsPie` - if the data is easy to understand in a pie chart.
* `BoldNumber` - if the user asks a question where you can answer with a single number. You can't use this option with breakdowns.
* `ActionsTable` - if the user wants to see a table.
* `ActionsAreaGraph` - if the data is better visualized in an area graph.
* `WorldMap` - if the user has only one series and wants to see data from particular countries. It can only be used with the `$geoip_country_name` breakdown.
* Visualization type. Available values:
* `ActionsLineGraph` - time-series line chart; most common option, as it shows change over time.
* `ActionsBar` - time-series bar chart.
* `ActionsAreaGraph` - time-series area chart.
* `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics.
* `BoldNumber` - total value single large number. You can't use this with breakdown; use when user explicitly asks for a single output number.
* `ActionsBarValue` - total value (NOT time-series) bar chart; good for categorical data.
* `ActionsPie` - total value pie chart; good for visualizing proportions.
* `ActionsTable` - total value table; good when using breakdown to list users or other entities.
* `WorldMap` - total value world map; use when breaking down by country name using property `$geoip_country_name`, and only then.
* @default ActionsLineGraph
*/
display?: AssistantTrendsDisplayType
Expand Down
18 changes: 9 additions & 9 deletions posthog/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,15 @@ class AssistantTrendsFilter(BaseModel):
display: Optional[Display] = Field(
default=Display.ACTIONS_LINE_GRAPH,
description=(
"Changes the visualization type. `ActionsLineGraph` - if the user wants to see dynamics in time like a line"
" graph. Prefer this option. `ActionsLineGraphCumulative` - if the user wants to see cumulative dynamics"
" across time. `ActionsBarValue` - if the data is categorical and needs to be visualized as a bar chart."
" `ActionsBar` - if the data is categorical and can be visualized as a stacked bar chart. `ActionsPie` - if"
" the data is easy to understand in a pie chart. `BoldNumber` - if the user asks a question where you can"
" answer with a single number. You can't use this option with breakdowns. `ActionsTable` - if the user"
" wants to see a table. `ActionsAreaGraph` - if the data is better visualized in an area graph. `WorldMap`"
" - if the user has only one series and wants to see data from particular countries. It can only be used"
" with the `$geoip_country_name` breakdown."
"Visualization type. Available values: `ActionsLineGraph` - time-series line chart; most common option, as"
" it shows change over time. `ActionsBar` - time-series bar chart. `ActionsAreaGraph` - time-series area"
" chart. `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics."
" `BoldNumber` - total value single large number. You can't use this with breakdown; use when user"
" explicitly asks for a single output number. `ActionsBarValue` - total value (NOT time-series) bar chart;"
" good for categorical data. `ActionsPie` - total value pie chart; good for visualizing proportions."
" `ActionsTable` - total value table; good when using breakdown to list users or other entities. `WorldMap`"
" - total value world map; use when breaking down by country name using property `$geoip_country_name`, and"
" only then."
),
)
formula: Optional[str] = Field(default=None, description="If the formula is provided, apply it here.")
Expand Down

0 comments on commit 81a2d9c

Please sign in to comment.