From 130f57ec90d5d93fc6c492e68705889d6d96c2c9 Mon Sep 17 00:00:00 2001 From: craisin Date: Mon, 1 Dec 2025 10:11:40 -0800 Subject: [PATCH] Initial Commit --- .gitignore | 13 ++ README.md | 24 +++ source/app.py | 33 ++++ source/calendar_connection.py | 199 ++++++++++++++++++++ source/prompt.txt | 300 ++++++++++++++++++++++++++++++ source/static/script.js | 59 ++++++ source/static/style.css | 99 ++++++++++ source/templates/index.html | 30 +++ source/templates/requirements.txt | 2 + 9 files changed, 759 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 source/app.py create mode 100644 source/calendar_connection.py create mode 100644 source/prompt.txt create mode 100644 source/static/script.js create mode 100644 source/static/style.css create mode 100644 source/templates/index.html create mode 100644 source/templates/requirements.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..66b24e5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +.vercel +*.log +*.pyc +__pycache__ + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..be62f83 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# Jackson Secretary + +Version 0.3 + +## About + +Update your Google Calendar with natural language! + +## Tech + ++ Uses Google Calendar REST API ++ Uses Mistral 7B Instruct V0.2 (up to change) + +## Contributers + +Active (Barely): ++ Craisin (Yappy0) + +Past: ++ Antiquail ++ Something27 ++ EthaEff0 + +Impoved off a project made during Los Altos Hacks \ No newline at end of file diff --git a/source/app.py b/source/app.py new file mode 100644 index 0000000..16a2cd1 --- /dev/null +++ b/source/app.py @@ -0,0 +1,33 @@ +import calendar_connection as cal +import os +from flask import Flask, request, render_template +import json +import requests + +app = Flask(__name__) + +@app.route('/') +def index(): + return render_template("index.html") + +@app.route('/calendar/getCalendarId', methods = ['POST']) +def get_calendar(): + return json.dumps({"calendar_id": cal.get_calendar(request.json["token"], request.json["timezone"])}) + +def get_json(input): + headers = {"Authorization": f"Bearer {os.environ['HF_TOKEN']}"} + with open("prompt.txt", "r") as promptFile: + payload = { + "inputs": f"Here is a set of sample prompts, which are only to be used for reference:\n{promptFile.read()}\nWhat is the output to {input}? Only return one line of output.\nOutput: ", + "parameters": {"temperature": 1, "return_full_text": False, "top_k": 1} + } + url = "https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.2" + response = requests.post(url = url, headers=headers, json=payload).json()[0]["generated_text"] + return response + +@app.route('/calendar/execute', methods = ['POST']) +def calendar(): + return json.dumps({"output": cal.execute_json(request.json["token"], request.json["calendar_id"], request.json["timezone"], get_json(request.json["input"]))}) + +if __name__ == "__main__": + app.run() diff --git a/source/calendar_connection.py b/source/calendar_connection.py new file mode 100644 index 0000000..7549a5b --- /dev/null +++ b/source/calendar_connection.py @@ -0,0 +1,199 @@ +import requests +import datetime as dt +import json + +def find_event(token, calendar_id,timezone, name): + url = f"https://www.googleapis.com/calendar/v3/calendars/{calendar_id}/events" + params = { + "q": name, + "timeZone": timezone + } + header = {"Authorization": f"Bearer {token}"} + + response = requests.get(url = url, headers = header, params = params) + if response.status_code == 401: + return "verify" + + events_list = response.json()["items"] + for i in events_list: + if i["summary"] == name: + return i + return "not found" + +def create_event(token, calendar_id, event): + + duplicate_check = find_event(token, calendar_id, event["timezone"], event["name"]) + if duplicate_check == "verify": + return "verify" + elif duplicate_check != "not found": + return "duplicate event" + + url = f"https://www.googleapis.com/calendar/v3/calendars/{calendar_id}/events" + payload = { + "summary": event["name"], + "start": { + "dateTime": event["start"].strftime("%Y-%m-%dT%H:%M:%S"), + "timeZone": event["timezone"] + }, + "end": { + "dateTime": event["end"].strftime("%Y-%m-%dT%H:%M:%S"), + "timeZone": event["timezone"] + }, + "description": " ".join([(event["start"] + dt.timedelta(days = i)).strftime("%Y-%m-%d") for i in range((event["end"] - event["start"]).days + 1)]) + } + header = {"Authorization": f"Bearer {token}", "Content-Type": "application/json"} + response = requests.post(url = url, headers = header, json = payload) + if response.status_code == 401: + return "verify" + + return "success" + +def cancel_event(token, calendar_id, timezone, name): + + event = find_event(token, calendar_id, timezone, name) + + if event == "verify": + return "verify" + elif event == "not found": + return "no event" + + url = f"https://www.googleapis.com/calendar/v3/calendars/{calendar_id}/events/{event['id']}" + header = {"Authorization": f"Bearer {token}"} + response = requests.delete(url = url, headers = header) + if response.status_code == 401: + return "verify" + + return "success" + +def shift_event(token, calendar_id, timezone, name, new_start): + + event = find_event(token, calendar_id, timezone, name) + + if event == "verify": + return "verify" + elif event == "not found": + return "no event" + + if event["start"]["dateTime"][-1] == "Z": + event["start"]["dateTime"], event["end"]["dateTime"] = event["start"]["dateTime"][0:-1] + "+00:00", event["end"]["dateTime"][0:-1] + "+00:00" + + event_start, event_end = dt.datetime.strptime(event["start"]["dateTime"][0:-6], "%Y-%m-%dT%H:%M:%S"), dt.datetime.strptime(event["end"]["dateTime"][0:-6], "%Y-%m-%dT%H:%M:%S") + new_end = new_start + (event_end - event_start) + event["start"]["dateTime"], event["end"]["dateTime"] = new_start.strftime("%Y-%m-%dT%H:%M:%S"), new_end.strftime("%Y-%m-%dT%H:%M:%S") + event["description"] = " ".join([(new_start + dt.timedelta(days = i)).strftime("%Y-%m-%d") for i in range((new_end - new_start).days + 1)]) + + url = f"https://www.googleapis.com/calendar/v3/calendars/{calendar_id}/events/{event['id']}" + header = {"Authorization": f"Bearer {token}"} + response = requests.put(url = url, headers = header, json = event) + if response.status_code == 401: + return "verify" + + return "success" + +def find_event_date(token, calendar_id, timezone, name): + + event = find_event(token, calendar_id, timezone, name) + if event == "verify": + return "verify" + elif event == "not found": + return "no event" + + if event["start"]["dateTime"][-1] == "Z": + event["start"]["dateTime"], event["end"]["dateTime"] = event["start"]["dateTime"][0:-1] + "+00:00", event["end"]["dateTime"][0:-1] + "+00:00" + + return dt.datetime.strptime(event["start"]["dateTime"][0:-6], "%Y-%m-%dT%H:%M:%S"), dt.datetime.strptime(event["end"]["dateTime"][0:-6], "%Y-%m-%dT%H:%M:%S") + +def find_date(token, calendar_id, timezone, date): + + url = f"https://www.googleapis.com/calendar/v3/calendars/{calendar_id}/events" + params = { + "q": date.strftime("%Y-%m-%d"), + "timeZone": timezone + } + header = {"Authorization": f"Bearer {token}"} + response = requests.get(url = url, headers = header, params = params) + if response.status_code == 401: + return "verify" + + events_list = response.json()["items"] + names = [f'{i["summary"]}: {i["start"]["dateTime"][11:13]}:{i["start"]["dateTime"][14:16]} - {i["end"]["dateTime"][11:13]}:{i["end"]["dateTime"][14:16]}' for i in events_list if date.strftime("%Y-%m-%d") in i["description"]] + return names + +def get_calendar(token, timezone): + + header = {"Authorization": f"Bearer {token}"} + calendar_response = requests.get(url = "https://www.googleapis.com/calendar/v3/users/me/calendarList", headers = header) + if calendar_response.status_code == 401: + return "verify" + + calendars = calendar_response.json()["items"] + for i in calendars: + if i["summary"] == "Jackson Secretary": + return i["id"] + + header["Content-Type"] = "application/json" + payload = { + "summary": "Jackson Secretary", + } + calendar_response = requests.post(url = "https://www.googleapis.com/calendar/v3/calendars", headers = header, json = payload) + if calendar_response.status_code == 401: + return "verify" + + return calendar_response.json()["id"] + +def execute_json(token, calendar_id, timezone, json_str): + + try: + json_obj = json.loads(json_str) + except: + return "invalid" + + result = { + "schedule": lambda token, calendar_id, timezone, json_obj: create_event(token, calendar_id, { + "name": json_obj[1], + "start": dt.datetime.strptime(json_obj[2], "%Y-%m-%d%H:%M"), + "end": (dt.datetime.strptime(json_obj[2], "%Y-%m-%d%H:%M") + dt.timedelta(hours = 1)) if len(json_obj) == 3 else dt.datetime.strptime(json_obj[3], "%Y-%m-%d%H:%M"), + "timezone": timezone + }), + "cancel": lambda token, calendar_id, timezone, json_obj: cancel_event(token, calendar_id, timezone, json_obj[1]), + "shift": lambda token, calendar_id, timezone, json_obj: shift_event(token, calendar_id, timezone, json_obj[1], dt.datetime.strptime(json_obj[2], "%Y-%m-%d%H:%M")), + "event-query": lambda token, calendar_id, timezone, json_obj: find_event_date(token, calendar_id, timezone, json_obj[1]), + "time-query": lambda token, calendar_id, timezone, json_obj: find_date(token, calendar_id, timezone, dt.datetime.strptime(json_obj[1], "%Y-%m-%d")), + }[json_obj[0]](token, calendar_id, timezone, json_obj) + + if result == "verify": + return "verify" + + if json_obj[0] == "schedule": + + if result == "success": + return f"Event {json_obj[1]} scheduled successfully" + elif result == "duplicate event": + return "Event already exists" + + elif json_obj[0] == "cancel": + + if result == "success": + return f"Event {json_obj[1]} cancelled successfully" + elif result == "no event": + return "Event not found" + + elif json_obj[0] == "shift": + + if result == "success": + return f"Event {json_obj[1]} shifted successfully" + elif result == "no event": + return "Event not found" + + elif json_obj[0] == "event-query": + + if result == "no event": + return "Event not found" + else: + return f"Event {json_obj[1]} is scheduled from {result[0].strftime('%d/%m/%Y at %H:%M')} to {result[1].strftime('%d/%m/%Y at %H:%M')}" + + elif json_obj[0] == "time-query": + + if len(result): + return "Events: \n- " + "\n- ".join(result) + return "No events scheduled for the day" diff --git a/source/prompt.txt b/source/prompt.txt new file mode 100644 index 0000000..ccc7f3f --- /dev/null +++ b/source/prompt.txt @@ -0,0 +1,300 @@ +Prompt: Schedule doctor's appointment on June 3rd, 2024, at 10:45am +Output: ["schedule", "doctor's appointment", "2024-06-0310:45"] +Prompt: Schedule conference call on July 20th, 2024, at 3:00pm +Output: ["schedule", "conference call", "2024-07-2015:00"] +Prompt: Schedule dentist appointment on September 5th, 2024, at 9:15am +Output: ["schedule", "dentist appointment", "2024-09-0509:15"] +Prompt: Schedule team meeting on October 10th, 2024, at 11:30am +Output: ["schedule", "team meeting", "2024-10-1011:30"] +Prompt: Schedule project presentation on December 15th, 2024, at 2:45pm +Output: ["schedule", "project presentation", "2024-12-1514:45"] +Prompt: Schedule job interview on February 8th, 2025, at 10:00am +Output: ["schedule", "job interview", "2025-02-0810:00"] +Prompt: Schedule training session on March 20th, 2025, at 1:30pm +Output: ["schedule", "training session", "2025-03-2013:30"] +Prompt: Schedule lunch with client on May 5th, 2025, at 12:15pm +Output: ["schedule", "lunch with client", "2025-05-0512:15"] +Prompt: Schedule team brainstorming session on June 18th, 2025, at 4:00pm +Output: ["schedule", "team brainstorming session", "2025-06-1816:00"] +Prompt: Schedule webinar on August 7th, 2025, at 3:45pm +Output: ["schedule", "webinar", "2025-08-0715:45"] +Prompt: Schedule staff meeting on September 22nd, 2025, at 10:30am +Output: ["schedule", "staff meeting", "2025-09-2210:30"] +Prompt: Schedule product launch event on November 11th, 2025, at 11:00am +Output: ["schedule", "product launch event", "2025-11-1111:00"] +Prompt: Schedule board meeting on January 15th, 2026, at 2:00pm +Output: ["schedule", "board meeting", "2026-01-152:00"] +Prompt: Schedule team retreat on March 7th, 2026, at 9:30am +Output: ["schedule", "team retreat", "2026-03-0709:30"] +Prompt: Schedule client presentation on April 25th, 2026, at 1:45pm +Output: ["schedule", "client presentation", "2026-04-2513:45"] +Prompt: Schedule team building workshop on August 20th, 2027, at 9:00am to 12:00pm +Output: ["schedule", "team building workshop", "2027-08-2009:00", "2027-08-2012:00"] +Prompt: Schedule coding competition on October 5th, 2028, at 10:00am to 3:00pm +Output: ["schedule", "coding competition", "2028-10-0510:00", "2028-10-0515:00"] +Prompt: Schedule charity fundraiser on April 10th, 2029, at 11:30am to 2:30pm +Output: ["schedule", "charity fundraiser", "2029-04-1011:30", "2029-04-1014:30"] +Prompt: Schedule dance marathon on July 15th, 2030, at 2:00pm to 8:00pm +Output: ["schedule", "dance marathon", "2030-07-1514:00", "2030-07-1520:00"] +Prompt: Schedule hackathon on November 7th, 2031, at 8:00am to 6:00pm +Output: ["schedule", "hackathon", "2031-11-0708:00", "2031-11-0718:00"] +Prompt: Schedule yoga retreat on March 25th, 2032, at 9:30am to 4:30pm +Output: ["schedule", "yoga retreat", "2032-03-2509:30", "2032-03-2516:30"] +Prompt: Schedule cooking class on September 12th, 2033, at 10:00am to 1:00pm +Output: ["schedule", "cooking class", "2033-09-1210:00", "2033-09-1213:00"] +Prompt: Schedule music festival on May 7th, 2034, at 12:00pm to 10:00pm +Output: ["schedule", "music festival", "2034-05-0712:00", "2034-05-0722:00"] +Prompt: Schedule art exhibition on August 20th, 2035, at 11:00am to 5:00pm +Output: ["schedule", "art exhibition", "2035-08-2011:00", "2035-08-2017:00"] +Prompt: Schedule science fair on October 15th, 2036, at 9:00am to 4:00pm +Output: ["schedule", "science fair", "2036-10-1509:00", "2036-10-1516:00"] +Prompt: Schedule film screening on March 8th, 2037, at 6:30pm to 10:30pm +Output: ["schedule", "film screening", "2037-03-0818:30", "2037-03-0822:30"] +Prompt: Schedule fashion show on June 5th, 2038, at 3:00pm to 7:00pm +Output: ["schedule", "fashion show", "2038-06-0515:00", "2038-06-0519:00"] +Prompt: Schedule robotics competition on September 18th, 2039, at 8:00am to 5:00pm +Output: ["schedule", "robotics competition", "2039-09-1808:00", "2039-09-1817:00"] +Prompt: Schedule marathon on November 22nd, 2040, at 7:00am to 12:00pm +Output: ["schedule", "marathon", "2040-11-2207:00", "2040-11-2212:00"] +Prompt: Schedule book fair on April 14th, 2041, at 10:00am to 4:00pm +Output: ["schedule", "book fair", "2041-04-1410:00", "2041-04-1416:00"] +Prompt: Cancel company picnic +Output: ["cancel", "company picnic"] +Prompt: Cancel charity gala +Output: ["cancel", "charity gala"] +Prompt: Cancel music concert +Output: ["cancel", "music concert"] +Prompt: Cancel art exhibition +Output: ["cancel", "art exhibition"] +Prompt: Cancel science fair +Output: ["cancel", "science fair"] +Prompt: Cancel yoga retreat +Output: ["cancel", "yoga retreat"] +Prompt: Cancel book club meeting +Output: ["cancel", "book club meeting"] +Prompt: Cancel film screening +Output: ["cancel", "film screening"] +Prompt: Cancel coding bootcamp +Output: ["cancel", "coding bootcamp"] +Prompt: Cancel marathon +Output: ["cancel", "marathon"] +Prompt: Cancel dance competition +Output: ["cancel", "dance competition"] +Prompt: Cancel job fair +Output: ["cancel", "job fair"] +Prompt: Cancel tech conference +Output: ["cancel", "tech conference"] +Prompt: Cancel cooking class +Output: ["cancel", "cooking class"] +Prompt: Cancel wine tasting event +Output: ["cancel", "wine tasting event"] +Prompt: Cancel theater performance +Output: ["cancel", "theater performance"] +Prompt: Cancel product launch +Output: ["cancel", "product launch"] +Prompt: Cancel team building workshop +Output: ["cancel", "team building workshop"] +Prompt: Cancel hackathon +Output: ["cancel", "hackathon"] +Prompt: Cancel beach cleanup +Output: ["cancel", "beach cleanup"] +Prompt: Cancel job interview +Output: ["cancel", "job interview"] +Prompt: Cancel lecture series +Output: ["cancel", "lecture series"] +Prompt: Cancel volunteer orientation +Output: ["cancel", "volunteer orientation"] +Prompt: Cancel fashion show +Output: ["cancel", "fashion show"] +Prompt: Cancel webinar +Output: ["cancel", "webinar"] +Prompt: Cancel community potluck +Output: ["cancel", "community potluck"] +Prompt: Cancel art workshop +Output: ["cancel", "art workshop"] +Prompt: Cancel TED talk +Output: ["cancel", "TED talk"] +Prompt: Cancel chess tournament +Output: ["cancel", "chess tournament"] +Prompt: Cancel photography exhibition +Output: ["cancel", "photography exhibition"] +Prompt: Shift team meeting to March 10, 2025, 10:30am +Output: ["shift", "team meeting", "2025-03-1010:30"] +Prompt: Shift project presentation to July 5, 2026, 2:00pm +Output: ["shift", "project presentation", "2026-07-0514:00"] +Prompt: Shift doctor's appointment to November 20, 2027, 3:45pm +Output: ["shift", "doctor's appointment", "2027-11-2015:45"] +Prompt: Shift conference call to May 15, 2028, 11:00am +Output: ["shift", "conference call", "2028-05-1511:00"] +Prompt: Shift dentist appointment to September 8, 2029, 9:30am +Output: ["shift", "dentist appointment", "2029-09-0809:30"] +Prompt: Shift team retreat to January 12, 2030, 1:00pm +Output: ["shift", "team retreat", "2030-01-1213:00"] +Prompt: Shift board meeting to April 5, 2031, 3:30pm +Output: ["shift", "board meeting", "2031-04-0515:30"] +Prompt: Shift job interview to August 20, 2032, 10:45am +Output: ["shift", "job interview", "2032-08-2010:45"] +Prompt: Shift training session to December 10, 2033, 2:15pm +Output: ["shift", "training session", "2033-12-1014:15"] +Prompt: Shift webinar to March 28, 2034, 4:30pm +Output: ["shift", "webinar", "2034-03-2816:30"] +Prompt: Shift client presentation to July 19, 2035, 11:15am +Output: ["shift", "client presentation", "2035-07-1911:15"] +Prompt: Shift staff meeting to November 5, 2036, 9:00am +Output: ["shift", "staff meeting", "2036-11-0509:00"] +Prompt: Shift product launch event to February 15, 2038, 2:45pm +Output: ["shift", "product launch event", "2038-02-1514:45"] +Prompt: Shift charity fundraiser to June 22, 2039, 6:00pm +Output: ["shift", "charity fundraiser", "2039-06-2218:00"] +Prompt: Shift team building workshop to October 17, 2040, 10:00am +Output: ["shift", "team building workshop", "2040-10-1710:00"] +Prompt: Shift coding competition to February 8, 2042, 3:30pm +Output: ["shift", "coding competition", "2042-02-0815:30"] +Prompt: Shift dance marathon to June 5, 2043, 1:45pm +Output: ["shift", "dance marathon", "2043-06-0513:45"] +Prompt: Shift hackathon to October 28, 2044, 9:30am +Output: ["shift", "hackathon", "2044-10-2809:30"] +Prompt: Shift yoga retreat to February 20, 2046, 11:00am +Output: ["shift", "yoga retreat", "2046-02-2011:00"] +Prompt: Shift cooking class to July 14, 2047, 4:00pm +Output: ["shift", "cooking class", "2047-07-1416:00"] +Prompt: Shift music festival to November 9, 2048, 7:30pm +Output: ["shift", "music festival", "2048-11-0921:30"] +Prompt: Shift art exhibition to March 3, 2050, 10:15am +Output: ["shift", "art exhibition", "2050-03-0310:15"] +Prompt: Shift science fair to July 28, 2051, 2:45pm +Output: ["shift", "science fair", "2051-07-2814:45"] +Prompt: Shift film screening to November 20, 2052, 6:00pm +Output: ["shift", "film screening", "2052-11-2018:00"] +Prompt: Shift fashion show to April 12, 2054, 12:30pm +Output: ["shift", "fashion show", "2054-04-1212:30"] +Prompt: Shift robotics competition to August 5, 2055, 11:45am +Output: ["shift", "robotics competition", "2055-08-0511:45"] +Prompt: Shift marathon to December 29, 2056, 8:30am +Output: ["shift", "marathon", "2056-12-2908:30"] +Prompt: Shift book fair to April 22, 2058, 3:15pm +Output: ["shift", "book fair", "2058-04-2215:15"] +Prompt: Shift theater performance to August 16, 2059, 7:00pm +Output: ["shift", "theater performance", "2059-08-1621:00"] +Prompt: Shift volunteer orientation to December 9, 2060, 10:00am +Output: ["shift", "volunteer orientation", "2060-12-0910:00"] +Prompt: When is the charity fundraiser? +Output: ["event-query", "charity fundraiser"] +Prompt: When is the team building workshop? +Output: ["event-query", "team building workshop"] +Prompt: When is the coding competition? +Output: ["event-query", "coding competition"] +Prompt: When is the yoga retreat? +Output: ["event-query", "yoga retreat"] +Prompt: When is the art exhibition? +Output: ["event-query", "art exhibition"] +Prompt: When is the science fair? +Output: ["event-query", "science fair"] +Prompt: When is the music festival? +Output: ["event-query", "music festival"] +Prompt: When is the dance marathon? +Output: ["event-query", "dance marathon"] +Prompt: When is the hackathon? +Output: ["event-query", "hackathon"] +Prompt: When is the cooking class? +Output: ["event-query", "cooking class"] +Prompt: When is the webinar? +Output: ["event-query", "webinar"] +Prompt: When is the fashion show? +Output: ["event-query", "fashion show"] +Prompt: When is the robotics competition? +Output: ["event-query", "robotics competition"] +Prompt: When is the marathon? +Output: ["event-query", "marathon"] +Prompt: When is the book fair? +Output: ["event-query", "book fair"] +Prompt: When is the theater performance? +Output: ["event-query", "theater performance"] +Prompt: When is the volunteer orientation? +Output: ["event-query", "volunteer orientation"] +Prompt: When is the TED talk? +Output: ["event-query", "TED talk"] +Prompt: When is the chess tournament? +Output: ["event-query", "chess tournament"] +Prompt: When is the photography exhibition? +Output: ["event-query", "photography exhibition"] +Prompt: When is the job fair? +Output: ["event-query", "job fair"] +Prompt: When is the lecture series? +Output: ["event-query", "lecture series"] +Prompt: When is the product launch? +Output: ["event-query", "product launch"] +Prompt: When is the board meeting? +Output: ["event-query", "board meeting"] +Prompt: When is the job interview? +Output: ["event-query", "job interview"] +Prompt: When is the staff meeting? +Output: ["event-query", "staff meeting"] +Prompt: When is the team retreat? +Output: ["event-query", "team retreat"] +Prompt: When is the webinar? +Output: ["event-query", "webinar"] +Prompt: When is the community potluck? +Output: ["event-query", "community potluck"] +Prompt: When is the wine tasting event? +Output: ["event-query", "wine tasting event"] +Prompt: What do I have on January 3rd, 2027? +Output: ["time-query", "2027-01-03"] +Prompt: What do I have on March 15th, 2028? +Output: ["time-query", "2028-03-15"] +Prompt: What do I have on May 22nd, 2029? +Output: ["time-query", "2029-05-22"] +Prompt: What do I have on August 7th, 2030? +Output: ["time-query", "2030-08-07"] +Prompt: What do I have on October 10th, 2031? +Output: ["time-query", "2031-10-10"] +Prompt: What do I have on December 25th, 2032? +Output: ["time-query", "2032-12-25"] +Prompt: What do I have on February 14th, 2033? +Output: ["time-query", "2033-02-14"] +Prompt: What do I have on April 1st, 2034? +Output: ["time-query", "2034-04-01"] +Prompt: What do I have on June 18th, 2035? +Output: ["time-query", "2035-06-18"] +Prompt: What do I have on August 30th, 2036? +Output: ["time-query", "2036-08-30"] +Prompt: What do I have on November 5th, 2037? +Output: ["time-query", "2037-11-05"] +Prompt: What do I have on January 22nd, 2038? +Output: ["time-query", "2038-01-22"] +Prompt: What do I have on March 10th, 2039? +Output: ["time-query", "2039-03-10"] +Prompt: What do I have on May 3rd, 2040? +Output: ["time-query", "2040-05-03"] +Prompt: What do I have on July 17th, 2041? +Output: ["time-query", "2041-07-17"] +Prompt: What do I have on September 29th, 2042? +Output: ["time-query", "2042-09-29"] +Prompt: What do I have on December 8th, 2043? +Output: ["time-query", "2043-12-08"] +Prompt: What do I have on February 20th, 2044? +Output: ["time-query", "2044-02-20"] +Prompt: What do I have on April 5th, 2045? +Output: ["time-query", "2045-04-05"] +Prompt: What do I have on June 12th, 2046? +Output: ["time-query", "2046-06-12"] +Prompt: What do I have on August 28th, 2047? +Output: ["time-query", "2047-08-28"] +Prompt: What do I have on November 3rd, 2048? +Output: ["time-query", "2048-11-03"] +Prompt: What do I have on January 14th, 2049? +Output: ["time-query", "2049-01-14"] +Prompt: What do I have on March 27th, 2050? +Output: ["time-query", "2050-03-27"] +Prompt: What do I have on May 8th, 2051? +Output: ["time-query", "2051-05-08"] +Prompt: What do I have on July 21st, 2052? +Output: ["time-query", "2052-07-21"] +Prompt: What do I have on September 3rd, 2053? +Output: ["time-query", "2053-09-03"] +Prompt: What do I have on November 16th, 2054? +Output: ["time-query", "2054-11-16"] +Prompt: What do I have on January 28th, 2055? +Output: ["time-query", "2055-01-28"] +Prompt: What do I have on April 7th, 2056? +Output: ["time-query", "2056-04-07"] diff --git a/source/static/script.js b/source/static/script.js new file mode 100644 index 0000000..c036560 --- /dev/null +++ b/source/static/script.js @@ -0,0 +1,59 @@ +let token = "womwpomwp"; +let calendar_id = "wompwomp"; +let timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; + +const client = google.accounts.oauth2.initTokenClient({ + client_id: + "1000685713819-om0gq7bqr3e91f2rok224ooqgae6bojg.apps.googleusercontent.com", + scope: "https://www.googleapis.com/auth/calendar", + callback: (tokenResponse) => { + if (tokenResponse && tokenResponse.access_token) { + token = tokenResponse.access_token; + fetch("/calendar/getCalendarId", { + method: "POST", + body: JSON.stringify({ token: token, timezone: timezone }), + headers: { "Content-type": "application/json" }, + }) + .then((response) => response.json()) + .then((json) => { + calendar_id = json["calendar_id"]; + }) + .then(() => { + send_request(); + }); + } + }, +}); + +function handle_form(event) { + event.preventDefault(); + send_request(); +} + +function send_request() { + let input_value = document.forms["chatbox"]["msg-input"].value; + + content_output = document.getElementById("content"); + + fetch("/calendar/execute", { + method: "POST", + body: JSON.stringify({ + token: token, + calendar_id: calendar_id, + timezone: timezone, + input: input_value, + }), + headers: { "Content-type": "application/json" }, + }) + .then((response) => response.json()) + .then((json) => { + if (json["output"] != "verify") { + content_output.innerHTML += `>>> ${input_value}
>>> ${json["output"]}

`; + document.forms["chatbox"]["msg-input"].value = ""; + } else { + client.requestAccessToken(); + } + }); +} + +document.forms["chatbox"].addEventListener("submit", handle_form); diff --git a/source/static/style.css b/source/static/style.css new file mode 100644 index 0000000..b35e7aa --- /dev/null +++ b/source/static/style.css @@ -0,0 +1,99 @@ +body{ + + margin: 0; + + background-color: #DAC4F7; + + font-family: 'Lexend'; + +} + +.header{ + + position: fixed; + left: 0; + top: 0; + + width: 100%; + height: 60px; + margin: 0; + + color: #F0F3BD; + background-color: #5D5F71; + + text-align: center; +} + +h1{ + + margin: 15px; + +} + +.filler{ + + height: 60px; + width: 100%; + +} + +#content{ + + width: 80%; + margin-left: 10%; + margin-right: 10%; + margin-top: 15px; + margin-bottom: 15px; + +} + +form{ + + position: fixed; + left: 0; + bottom:0; + + width: 100%; + height: 60px; + margin: 0; + + background-color: #5D5F71; + + text-align: center; + +} + +#msg-input{ + + width: 80%; + height: 30px; + margin: 15px; + padding-left: 10px; + + color: #F0F3BD; + background-color: #5D5F71; + + font-family: 'Lexend'; + + border: 2px solid #F0F3BD; + border-radius: 20px; + + outline: none; + +} + +#submit-btn{ + + width: 30px; + height: 30px; + margin: 15px; + margin-left: 0; + + color: #5D5F71; + background-color: #F0F3BD; + font-family: 'Lexend'; + + border: 2px solid #F0F3BD; + border-radius: 50%; + +} diff --git a/source/templates/index.html b/source/templates/index.html new file mode 100644 index 0000000..cd940cc --- /dev/null +++ b/source/templates/index.html @@ -0,0 +1,30 @@ + + + + Jackson Secretary + + + + + +
+

Jackson

+
+
+
+
+
+ + +
+ + + diff --git a/source/templates/requirements.txt b/source/templates/requirements.txt new file mode 100644 index 0000000..b0abe0a --- /dev/null +++ b/source/templates/requirements.txt @@ -0,0 +1,2 @@ +Flask==3.0.0 +requests