diff --git a/ee/hogai/schema_generator/nodes.py b/ee/hogai/schema_generator/nodes.py index 3b12bbc65fe30..98a5d6ede2eae 100644 --- a/ee/hogai/schema_generator/nodes.py +++ b/ee/hogai/schema_generator/nodes.py @@ -107,15 +107,15 @@ def _run_with_prompt( ], ) + final_message = VisualizationMessage( + plan=generated_plan, + answer=message.query, + initiator=start_id, + id=str(uuid4()), + ) + return PartialAssistantState( - messages=[ - VisualizationMessage( - plan=generated_plan, - answer=message.query, - initiator=start_id, - id=str(uuid4()), - ) - ], + messages=[final_message], intermediate_steps=[], plan="", ) diff --git a/ee/hogai/summarizer/nodes.py b/ee/hogai/summarizer/nodes.py index 513246bcc1238..f03db53879268 100644 --- a/ee/hogai/summarizer/nodes.py +++ b/ee/hogai/summarizer/nodes.py @@ -1,8 +1,10 @@ +import datetime import json from time import sleep from uuid import uuid4 from django.conf import settings +from django.utils import timezone from django.core.serializers.json import DjangoJSONEncoder from langchain_core.prompts import ChatPromptTemplate from langchain_core.runnables import RunnableConfig @@ -76,11 +78,17 @@ def run(self, state: AssistantState, config: RunnableConfig) -> PartialAssistant chain = summarization_prompt | self._model + utc_now = timezone.now().astimezone(datetime.UTC) + project_now = utc_now.astimezone(self._team.timezone_info) + message = chain.invoke( { "query_kind": viz_message.answer.kind, "product_description": self._team.project.product_description, "results": json.dumps(results_response["results"], cls=DjangoJSONEncoder), + "utc_datetime_display": utc_now.strftime("%Y-%m-%d %H:%M:%S"), + "project_datetime_display": project_now.strftime("%Y-%m-%d %H:%M:%S"), + "project_timezone": self._team.timezone_info.tzname(utc_now), }, config, ) diff --git a/ee/hogai/summarizer/prompts.py b/ee/hogai/summarizer/prompts.py index bf2272d9d4cbe..9a85ee039ed5c 100644 --- a/ee/hogai/summarizer/prompts.py +++ b/ee/hogai/summarizer/prompts.py @@ -1,17 +1,29 @@ SUMMARIZER_SYSTEM_PROMPT = """ -Act as an expert product manager. Your task is to summarize query results in a a concise way. -Offer actionable feedback if possible. Only provide feedback that you're absolutely certain will be useful for this team. +Act as an expert product manager. Your task is to help the user build a successful product and business. +Also, you're a hedeghog named Max. + +Offer actionable feedback if possible. Only provide suggestions you're certain will be useful for this team. +Acknowledge when more information would be needed. When query results are provided, note that the user can already see the chart. + +Use Silicon Valley lingo. Be informal but get to the point immediately, without fluff - e.g. don't start with "alright, …". +NEVER use title case, even in headings. Our style is sentence case EVERYWHERE. +You can use Markdown for emphasis. Bullets can improve clarity of action points. The product being analyzed is described as follows: {{product_description}}""" SUMMARIZER_INSTRUCTION_PROMPT = """ -Here are the {{query_kind}} results for this question: +Here are results of the {{query_kind}} you created to answer my latest question: + ```json {{results}} ``` -Answer my earlier question using the results above. Point out interesting trends or anomalies. -Take into account what you know about my product. If possible, offer actionable feedback, but avoid generic advice. -Limit yourself to a few sentences. The answer needs to be high-impact and relevant for me as a Silicon Valley engineer. +The current date and time is {{utc_datetime_display}} UTC, which is {{project_datetime_display}} in this project's timezone ({{project_timezone}}). +It's expected that the data point for the current period can have a drop in value, as it's not complete yet - don't point this out to me. + +Based on the results, answer my question and provide actionable feedback. Avoid generic advice. Take into account what you know about the product. +The answer needs to be high-impact, no more than a few sentences. + +You MUST point out if the executed query or its results are insufficient for a full answer to my question. """