Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerkn1 committed Jun 17, 2023
1 parent 19131a8 commit 45807fc
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ FLASK_APP=app
FLASK_ENV=development

# Once you add your API key below, make sure to not share it with anyone! The API key should remain private.
OPENAI_API_KEY=
OPENAI_API_KEY="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"
60 changes: 47 additions & 13 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
from flask import Flask, redirect, render_template, request, url_for

app = Flask(__name__)
openai.api_key = os.getenv("OPENAI_API_KEY")

# openai.api_key = os.getenv("OPENAI_API_KEY")
openai.api_key = "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"

@app.route("/", methods=("GET", "POST"))
def index():
if request.method == "POST":
animal = request.form["animal"]
# animal = request.form["animal"]
todo = request.form["name","duration","priority"]
print(todo)
#busy = get from google calendar

response = openai.Completion.create(
model="text-davinci-003",
prompt=generate_prompt(animal),
prompt=generate_prompt(todo),
temperature=0.6,
)
return redirect(url_for("index", result=response.choices[0].text))
Expand All @@ -22,14 +26,44 @@ def index():
return render_template("index.html", result=result)


def generate_prompt(animal):
return """Suggest three names for an animal that is a superhero.
'''
todo qualities: [(name, duration, priority), (name, duration, priority), (name, duration, priority)]
-name
-duration
-priority
maybe
-fatigue
-location
'''

Animal: Cat
Names: Captain Sharpclaw, Agent Fluffball, The Incredible Feline
Animal: Dog
Names: Ruff the Protector, Wonder Canine, Sir Barks-a-Lot
Animal: {}
Names:""".format(
animal.capitalize()
def generate_prompt(todo):
return """repeat what i typed""".format(
todo.capitalize()
)




# def generate_prompt(todo):
# return """Create a schedule for me that puts 'todo tasks' at times when I am not also busy with 'busy tasks' ".

# todo:
# schedule: Captain Sharpclaw, Agent Fluffball, The Incredible Feline
# todo: Dog
# schedule: Ruff the Protector, Wonder Canine, Sir Barks-a-Lot
# todo: {}
# schedule:""".format(
# todo.capitalize()
# )

# def generate_prompt(animal):
# return """Suggest three names for an animal that is a superhero.

# Animal: Cat
# Names: Captain Sharpclaw, Agent Fluffball, The Incredible Feline
# Animal: Dog
# Names: Ruff the Protector, Wonder Canine, Sir Barks-a-Lot
# Animal: {}
# Names:""".format(animal.capitalize())

1 change: 1 addition & 0 deletions credentials.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"installed":{"client_id":"1006500282925-uhjgrvbv4tvi73aq65thehfa1khpi594.apps.googleusercontent.com","project_id":"calendarai-390120","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"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","redirect_uris":["http:https://localhost"]}}
10 changes: 10 additions & 0 deletions locations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import geocoder

locationDict

#test code, we need to return data back from flask after this point
locationDict = {['2333 piedmont ave, Berkeley, CA'], ['Birge Path, Berkeley, CA 94704']}

g = geocoder.bing(locationDict, method='batch')
for results in g:
print(results.city)
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ toml==0.10.2
tqdm==4.62.3
urllib3==1.26.7
Werkzeug==2.0.2
google-api-python-client==2.89.0
google-auth-httplib2==0.1.0
google-auth-oauthlib==1.0.0
44 changes: 41 additions & 3 deletions static/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,36 @@ h3 {
}
form {
display: flex;
flex-direction: column;
width: 320px;
flex-direction: row;
align-items: center;
justify-content: center;
padding: 20px;
width: 500px;
flex-wrap: wrap;
border: 1px solid #353740;
border-radius: 4px;
}
input[type="text"] {
padding: 12px 16px;
border: 1px solid #10a37f;
border-radius: 4px;
padding: 12px 16px;
margin-bottom: 24px;
flex-basis: 100%;
width: 100%;
height: 25px;
}
input[type="number"] {
padding: 12px 16px;
border: 1px solid #10a37f;
border-radius: 4px;
width: 105px;
height: 19px;
margin-right: 10px;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
::placeholder {
color: #8e8ea0;
Expand All @@ -64,3 +86,19 @@ input[type="submit"] {
font-weight: bold;
margin-top: 40px;
}

select {
padding: 12px 16px;
border: 1px solid #10a37f;
border-radius: 4px;
width: 200px;
height: 45px;
margin-right: 10px;
}
form>button {
padding: 12px 16px;
border: 1px solid #10a37f;
border-radius: 4px;
width: 60px;
height: 45px;
}
85 changes: 82 additions & 3 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<head>
<title>OpenAI Quickstart</title>
<title>OpenAI ToDo List Scheduler Of Awesomeness</title>
<link
rel="shortcut icon"
href="{{ url_for('static', filename='dog.png') }}"
Expand All @@ -9,13 +9,92 @@
</head>

<body>
<img src="{{ url_for('static', filename='dog.png') }}" class="icon" />
<!--<img src="{{ url_for('static', filename='dog.png') }}" class="icon" />
<h3>Name my pet</h3>
<form action="/" method="post">
<input type="text" name="animal" placeholder="Enter an animal" required />
<input type="submit" value="Generate names" />
</form>
{% if result %}
<div class="result">{{ result }}</div>
{% endif %}
{% endif %}-->

<form action="/" method="post" id="todo-form">
<h1>Todo List</h1>
<input type="text" name = "name" id="todo-input-name" placeholder="Enter a task" required/>
<input type="number" name = "duration" id="todo-input-dur" placeholder="Duration (Min)"/>
<select name="priority" id="todo-input-pri" placeholder="Priority">
<option disabled selected value=""> -- Select a priority level -- </option>
<option value="Highest">Highest</option>
<option value="High">High</option>
<option value="Medium">Medium</option>
<option value="Low">Low</option>
<option value="Lowest">Lowest</option>
</select>
<button type="submit">Add</button>
</form>

<ul id="todo-list">
<!-- Todo items will be dynamically added here -->
</ul>

<button onclick="generate()">Generate Schedule</button>

<text id="result">hello</text>

<script>
var tasks = []; // Array to store the tasks

// dont change this is for adding tasks
document.getElementById("todo-form").addEventListener("submit", function(event) {
event.preventDefault();

var name = document.getElementById("todo-input-name");
var dur = document.getElementById("todo-input-dur");
if (dur == 0) { dur = 30; }
var pri = document.getElementById("todo-input-pri");
var todoItem = document.createElement("li");
todoItem.textContent = name.value + " " + dur.value + " " + pri.value;
tasks.push([name.value, dur.value, pri.value]);
document.getElementById("todo-list").appendChild(todoItem);

name.value = "";
dur.value = "";
pri.value = "";
});

// this is for generating with ai
function generate() {
var elem = document.getElementById("result");
elem.textContent = tasks;
}


/*var taskIndex = 0;
document.getElementById("add-task").addEventListener("click", function(event) {
event.preventDefault();
taskIndex++;
var taskInputs = document.createElement("div");
taskInputs.className = "task-input";
taskInputs.innerHTML = `
<input type="text" name="name${taskIndex}" placeholder="Enter a task name" required />
<input type="number" name="duration${taskIndex}" placeholder="Enter duration" required />
<select name="priority${taskIndex}">
<option value="Highest">Highest</option>
<option value="High">High</option>
<option value="Medium">Medium</option>
<option value="Low">Low</option>
<option value="Lowest">Lowest</option>
</select>`;
document.getElementById("task-inputs").appendChild(taskInputs);
});*/
</script>




</body>

0 comments on commit 45807fc

Please sign in to comment.