-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
370e0be
commit 70c1730
Showing
7 changed files
with
54 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
LASTFM_API_KEY=<your_lastfm_api_key> | ||
LASTFM_API_KEY=<your_lastfm_api_key> | ||
GROQ_API_KEY=<your_groq_api_key> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
fastapi[standard] | ||
requests | ||
pandas | ||
ruff | ||
groq | ||
scikit-learn | ||
ruff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
from dotenv import load_dotenv | ||
from groq import Groq | ||
|
||
load_dotenv() | ||
|
||
GROQ_API_KEY = os.getenv("GROQ_API_KEY") | ||
print(GROQ_API_KEY) | ||
client = Groq( | ||
api_key=GROQ_API_KEY, | ||
) | ||
|
||
|
||
def ai(df): | ||
chat_completion = client.chat.completions.create( | ||
messages=[ | ||
{ | ||
"role": "user", | ||
"content": "Generate 3 quiz questions about the data. Only ask questions about tracks with a cluster of 1 (don't mention cluster in the questions)" | ||
+ df.to_json(), | ||
} | ||
], | ||
model="llama-3.3-70b-versatile", | ||
) | ||
|
||
print(chat_completion.choices[0].message.content) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
from ai import ai | ||
from fetch import fetch | ||
from model import preprocess | ||
from ml import ml | ||
|
||
|
||
def combine(username, period): | ||
metadata = {"username": username, "period": period} | ||
tracks = fetch(username, period) | ||
preprocess(tracks) | ||
df = ml(tracks) | ||
ai(df) | ||
return_data = {"metadata": metadata, "tracks": tracks} | ||
return return_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import pandas as pd | ||
from sklearn.cluster import KMeans | ||
import numpy as np | ||
|
||
|
||
def ml(data): | ||
df = cluster(data) | ||
return df | ||
|
||
|
||
def cluster(data): | ||
df = pd.DataFrame(data) | ||
play_counts = np.array(df["playcount"]).reshape(-1, 1) | ||
kmeans = KMeans(n_clusters=3, random_state=42).fit(play_counts) | ||
df["cluster"] = kmeans.labels_ | ||
print(df) | ||
return df |
This file was deleted.
Oops, something went wrong.