Skip to content

Commit

Permalink
Merge pull request #2 from gavinmorrisseau/secondary
Browse files Browse the repository at this point in the history
Alpha 1.0.0
  • Loading branch information
gavinmorrisseau committed Dec 11, 2023
2 parents 5b51936 + 4beb541 commit 1882375
Show file tree
Hide file tree
Showing 23 changed files with 883 additions and 2 deletions.
1 change: 0 additions & 1 deletion .cache

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.cache
playground.py
.gitignore
.DS_Store
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"open-in-browser.default": "fde"
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# AI-music-recommendation
# AI-music-recommendation
> Music Recommendations Python app utilziing Spotify and OpenAI API.
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added assets/images/OriginalLogoSymbolSquare.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
289 changes: 289 additions & 0 deletions assets/images/OriginalLogoSymbolSquare.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/OriginalLogoTransparent.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added assets/images/favicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
274 changes: 274 additions & 0 deletions assets/images/favicon.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
120 changes: 120 additions & 0 deletions index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/* FILEPATH: /workspaces/AI-music-recommendation/web/index.css */


/* Enable noselect for major browsers */
.noselect {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Old versions of Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
supported by Chrome, Edge, Opera and Firefox */
}

/* Reset default browser styles */
html, body {
margin: 0;
padding: 0;
}

/* Set a base font size and family */
body {
font-size: 16px;
font-family: Arial, sans-serif;
}

/* Add styles for the header */
header {
background-color: #333;
color: #fff;
padding: 20px;
}

/* Add styles for the main content */
main {
padding: 20px;
}

/* Add styles for links */
a {
color: #007bff;
text-decoration: none;
}

a:hover {
text-decoration: underline;
}

/* Add styles for forms */
form {
margin-bottom: 20px;
}

textarea {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
}

#header * {
background-color: #fff;
color: #141214;
text-align: center;
}

#headertext {
font-size: 2.5rem;
font-weight: 800;
margin-top: 16rem;
color: #555555;
}

#subtext {
position: relative;
font-size: 1rem;
font-weight: 400;
margin-bottom: 4rem;
color: #555555;
}

.chat * {
text-align: center;
}

input {
width: 20%;
height: 1.7rem;
text-align: left;
}

input::placeholder {
text-align: center;

}

.button {
padding: 10px 20px;
text-align: left;
color: #fff;
background-color: #515151;
border: none;
border-radius: 4px;
}

.button:hover {
background-color:#000;
color: #fff
}

#headerlogo {
position: relative;
display: inline;
margin-left: auto;
margin-right: auto;
width: 6rem;
height: 6rem;
top: 1.6rem;
}

30 changes: 30 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="icon" type="image/svg+xml" href="../assets/images/favicon.svg">
<link rel="icon" type="image/png" href="../assets/images/favicon.png">
<meta name="theme-color" content="#fdf7f2">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Add to Source Later-->
<script type="module" src="https://md-block.verou.me/md-block.js"></script>
<title>aijukebox.net</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<div class="noselect" id="header">
<h1 id="headertext">hey, boss<img id="headerlogo" src="/assets/images/OriginalLogoTransparent.png" alt="logo"></h1>
<p id="subtext">what's the mood today?</p>
</div>
<div= class="chat">
<div class="chatbox">
<div class="chatbox__messages">
</div>
<div class="chatbox__input">
<input type="text" placeholder="type a message ...">
<button onclick="runGPT()" class="button">send</button>
</div>
</div>
</div>
</body>
</html>
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function runGPT() {
// Get the path to the Python script.
var pythonScriptPath = "/src/GPT.py";

// Run the Python script.
subprocess.run(["python", pythonScriptPath]);
}
6 changes: 6 additions & 0 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
51 changes: 51 additions & 0 deletions src/gpt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import time
import json
import sys
from openai import OpenAI

# ~ Docs ~
# https://cookbook.openai.com/examples/assistants_api_overview_python
# https://platform.openai.com/docs/assistants/how-it-works/managing-threads-and-messages

def wait_on_run(run, thread):
while run.status == "queued" or run.status == "in_progress":
run = client.beta.threads.runs.retrieve(
thread_id=thread.id,
run_id=run.id,
)
time.sleep(0.5)
return run

client = OpenAI(
organization='org-1VoooiSLTr711Aax6i6A5nUT',
)

thread = client.beta.threads.create()
PROMPT = input("[*]: ")
ASSISTANT_ID = "asst_Z8EJORrugfSAMUgxKXWNAaXw"

message = client.beta.threads.messages.create(
thread_id=thread.id,
role="user",
content=PROMPT,
)

run = client.beta.threads.runs.create(
thread_id=thread.id,
assistant_id=ASSISTANT_ID,
)

run = wait_on_run(run, thread)
messages = client.beta.threads.messages.list(thread_id=thread.id)
message_object = messages.data[0].content[0].text.value

try:
message_parsed = json.loads(message_object)
except json.decoder.JSONDecodeError:
print(f'FAILED: \n{message}')
sys.exit()

for count in range(1,6):
artist = str(message_parsed[str(count)]['artist'])
track = str(message_parsed[str(count)]['track'])
print(f'{track} by {artist}')
51 changes: 51 additions & 0 deletions src/gpt_for_web.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import time
import json
import sys
from openai import OpenAI

# ~ Docs ~
# https://cookbook.openai.com/examples/assistants_api_overview_python
# https://platform.openai.com/docs/assistants/how-it-works/managing-threads-and-messages

def wait_on_run(run, thread):
while run.status == "queued" or run.status == "in_progress":
run = client.beta.threads.runs.retrieve(
thread_id=thread.id,
run_id=run.id,
)
time.sleep(0.5)
return run

client = OpenAI(
organization='org-1VoooiSLTr711Aax6i6A5nUT',
)

thread = client.beta.threads.create()
PROMPT = input("[*]: ")
ASSISTANT_ID = "asst_Z8EJORrugfSAMUgxKXWNAaXw"

message = client.beta.threads.messages.create(
thread_id=thread.id,
role="user",
content=PROMPT,
)

run = client.beta.threads.runs.create(
thread_id=thread.id,
assistant_id=ASSISTANT_ID,
)

run = wait_on_run(run, thread)
messages = client.beta.threads.messages.list(thread_id=thread.id)
message_object = messages.data[0].content[0].text.value

try:
message_parsed = json.loads(message_object)
except json.decoder.JSONDecodeError:
print(f'FAILED: \n{message}')
sys.exit()

for count in range(1,6):
artist = str(message_parsed[str(count)]['artist'])
track = str(message_parsed[str(count)]['track'])
print(f'{track} by {artist}')
File renamed without changes.

0 comments on commit 1882375

Please sign in to comment.