Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Llm add llm events to insights without timeseries #29

Open
wants to merge 2 commits into
base: llm-main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions posthog/api/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,10 +714,20 @@ def extend_actors_with_llm_events(self, filter, serialized_actors, request):
distinct_ids = [di for sa in serialized_actors for di in sa["distinct_ids"]]
ev = json.loads(req_dict["events"])[0].get("name")
req_dict["event"] = ev

if "date_from" in req_dict:
req_dict["after"] = req_dict["date_from"]
if req_dict["date_from"] == "all":
# For insights that do not contain timeseries (piechart, number)
# Insights with no timeseries add 'date_from = all' and no 'date_to' is sent
# we set a date that grabs all events before "now"s
assert "date_to" not in req_dict, "date_to found when 'date_from = all'."
req_dict["before"] = datetime.today().strftime("%Y-%m-%d %H:%M:%S.%f")
else: # -180d, -7d, other timestamps
req_dict["after"] = req_dict["date_from"]

if "date_to" in req_dict:
req_dict["before"] = req_dict["date_to"]

req_dict["distinct_ids"] = distinct_ids

query_result = query_events_list(
Expand Down Expand Up @@ -802,7 +812,6 @@ def trends(self, request: request.Request, *args: Any, **kwargs: Any) -> Respons

return self._respond_with_cached_results(self.calculate_trends_persons(request))

@cached_by_filters
def calculate_trends_persons(
self, request: request.Request
) -> Dict[str, Tuple[List, Optional[str], Optional[str], int]]:
Expand Down
Loading