Final commit
This commit is contained in:
parent
91fffb3294
commit
c35e0716af
372 changed files with 16591 additions and 1 deletions
18
backend/routes/get-song.ts
Normal file
18
backend/routes/get-song.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { generateSongs } from "../ai-selector.ts";
|
||||
import { searchSpotifyTracks } from "../spotify-api.ts";
|
||||
import { GetSongsTextOutput, GetSongsTextParams } from "../types/api.ts";
|
||||
|
||||
export async function getSong(
|
||||
params: GetSongsTextParams,
|
||||
): Promise<GetSongsTextOutput> {
|
||||
const ai_response = await generateSongs(params.prompt, params.rules);
|
||||
if (ai_response.type == "error") {
|
||||
return ai_response;
|
||||
}
|
||||
|
||||
const spotifyResults = await searchSpotifyTracks(
|
||||
ai_response.songs,
|
||||
);
|
||||
|
||||
return { type: "success", songs: spotifyResults };
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue