Do not hard code base url of path to automation icon in chat message

This commit is contained in:
Debanjum Singh Solanky
2024-05-04 10:46:01 +05:30
parent a38f3227e2
commit fd2328ab40
2 changed files with 4 additions and 7 deletions

View File

@@ -401,9 +401,7 @@ async def websocket_endpoint(
)
continue
llm_response = construct_automation_created_message(
automation, crontime, query_to_run, subject, websocket.url
)
llm_response = construct_automation_created_message(automation, crontime, query_to_run, subject)
await sync_to_async(save_to_conversation_log)(
q,
llm_response,
@@ -643,7 +641,7 @@ async def chat(
status_code=500,
)
llm_response = construct_automation_created_message(automation, crontime, query_to_run, subject, request.url)
llm_response = construct_automation_created_message(automation, crontime, query_to_run, subject)
await sync_to_async(save_to_conversation_log)(
q,
llm_response,

View File

@@ -1001,15 +1001,14 @@ async def schedule_automation(
return job
def construct_automation_created_message(automation: Job, crontime: str, query_to_run: str, subject: str, url: URL):
def construct_automation_created_message(automation: Job, crontime: str, query_to_run: str, subject: str):
# Display next run time in user timezone instead of UTC
schedule = f'{cron_descriptor.get_description(crontime)} {automation.next_run_time.strftime("%Z")}'
next_run_time = automation.next_run_time.strftime("%Y-%m-%d %I:%M %p %Z")
# Remove /automated_task prefix from inferred_query
unprefixed_query_to_run = re.sub(r"^\/automated_task\s*", "", query_to_run)
# Create the automation response
scheme = "http" if not url.is_secure else "https"
automation_icon_url = f"{scheme}://{url.netloc}/static/assets/icons/automation.svg"
automation_icon_url = f"/static/assets/icons/automation.svg"
return f"""
### ![]({automation_icon_url}) Created Automation
- Subject: **{subject}**