feat: resolve conflict
This commit is contained in:
commit
d229d741f4
2188
package-lock.json
generated
2188
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@
|
||||
"url": "https://github.com/gcui-art/"
|
||||
},
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"version": "0.1.0",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
@ -18,10 +18,12 @@
|
||||
"axios": "^1.6.8",
|
||||
"axios-cookiejar-support": "^5.0.0",
|
||||
"next": "14.1.4",
|
||||
"next-swagger-doc": "^0.4.0",
|
||||
"pino": "^8.19.0",
|
||||
"pino-pretty": "^11.0.0",
|
||||
"react": "^18",
|
||||
"react-dom": "^18",
|
||||
"swagger-ui-react": "^5.12.3",
|
||||
"tough-cookie": "^4.1.3",
|
||||
"user-agents": "^1.1.156"
|
||||
},
|
||||
@ -29,6 +31,7 @@
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^18",
|
||||
"@types/react-dom": "^18",
|
||||
"@types/swagger-ui-react": "^4.18.3",
|
||||
"@types/tough-cookie": "^4.0.5",
|
||||
"@types/user-agents": "^1.0.4",
|
||||
"autoprefixer": "^10.0.1",
|
||||
|
1592
pnpm-lock.yaml
1592
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
1
public/swagger-suno-api.json
Normal file
1
public/swagger-suno-api.json
Normal file
File diff suppressed because one or more lines are too long
13
src/app/docs/Swagger.tsx
Normal file
13
src/app/docs/Swagger.tsx
Normal file
@ -0,0 +1,13 @@
|
||||
'use client';
|
||||
import SwaggerUI from 'swagger-ui-react';
|
||||
import 'swagger-ui-react/swagger-ui.css';
|
||||
|
||||
type Props = {
|
||||
spec: Record<string, any>,
|
||||
};
|
||||
|
||||
function Swagger({ spec }: Props) {
|
||||
return <SwaggerUI spec={spec} />;
|
||||
}
|
||||
|
||||
export default Swagger;
|
14
src/app/docs/page.tsx
Normal file
14
src/app/docs/page.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import React from 'react';
|
||||
import Swagger from './Swagger';
|
||||
import spec from './swagger-suno-api.json'; // 直接导入JSON文件
|
||||
|
||||
|
||||
export default async function Docs() {
|
||||
// const spec = await getApiDocs();
|
||||
return (
|
||||
<main className="flex min-h-screen flex-col items-center p-24 bg-white">
|
||||
|
||||
<Swagger spec={spec} />
|
||||
</main>
|
||||
);
|
||||
}
|
285
src/app/docs/swagger-suno-api.json
Normal file
285
src/app/docs/swagger-suno-api.json
Normal file
@ -0,0 +1,285 @@
|
||||
{
|
||||
"openapi": "3.0.3",
|
||||
"info": {
|
||||
"title": "suno-api",
|
||||
"description": "Use API to call the music generation service of Suno.ai and easily integrate it into agents like GPTs.",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"tags": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/api/custom_generate": {
|
||||
"post": {
|
||||
"summary": "Generate Audio - Custom Mode",
|
||||
"description": "The custom mode enables users to provide additional details about the music, such as music genre, lyrics, and more.2 audio files will be generated for each request, consuming a total of 10 credits.wait_audio can be set to API mode:\u2022 By default, it is set to false, which indicates the background mode. It will only return audio task information, and you will need to call the get API to retrieve detailed audio information.\u2022 If set to true, it simulates synchronous mode. The API will wait for a maximum of 100s until the audio is generated, and will directly return the audio link and other information. Recommend using in GPTs and other agents.",
|
||||
"tags": ["default"],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": ["prompt", "tags", "title"],
|
||||
"properties": {
|
||||
"prompt": {
|
||||
"type": "string",
|
||||
"description": "Detailed prompt, including information such as music lyrics.",
|
||||
"example": "[Verse 1]\nCruel flames of war engulf this land\nBattlefields filled with death and dread\nInnocent souls in darkness, they rest\nMy heart trembles in this silent test\n\n[Verse 2]\nPeople weep for loved ones lost\nBattered bodies bear the cost\nSeeking peace and hope once known\nOur grief transforms to hearts of stone\n\n[Chorus]\nSilent battlegrounds, no birds' song\nShadows of war, where we don't belong\nMay flowers of peace bloom in this place\nLet's guard this precious dream with grace\n\n[Bridge]\nThrough the ashes, we will rise\nHand in hand, towards peaceful skies\nNo more sorrow, no more pain\nTogether, we'll break these chains\n\n[Chorus]\nSilent battlegrounds, no birds' song\nShadows of war, where we don't belong\nMay flowers of peace bloom in this place\nLet's guard this precious dream with grace\n\n[Outro]\nIn unity, our strength will grow\nA brighter future, we'll soon know\nFrom the ruins, hope will spring\nA new dawn, we'll together bring"
|
||||
},
|
||||
"tags": {
|
||||
"type": "string",
|
||||
"description": "Music genre",
|
||||
"example": "pop metal male melancholic"
|
||||
},
|
||||
"title": {
|
||||
"type": "string",
|
||||
"description": "Music title",
|
||||
"example": "Silent Battlefield"
|
||||
},
|
||||
"make_instrumental": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to generate instrumental music",
|
||||
"example": "false"
|
||||
},
|
||||
"wait_audio": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to wait for music generation, default is false, directly return audio task information; set to true, will wait for up to 100s until the audio is generated.",
|
||||
"example": "false"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "success",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["0", "1"],
|
||||
"properties": [
|
||||
{
|
||||
"$ref": "#/components/schemas/audio_info"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/schemas/audio_info"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/generate": {
|
||||
"post": {
|
||||
"summary": "Generate audio based on Prompt.",
|
||||
"description": "It will automatically fill in the lyrics.2 audio files will be generated for each request, consuming a total of 10 credits.wait_audio can be set to API mode:\u2022 By default, it is set to false, which indicates the background mode. It will only return audio task information, and you will need to call the get API to retrieve detailed audio information.\u2022 If set to true, it simulates synchronous mode. The API will wait for a maximum of 100s until the audio is generated, and will directly return the audio link and other information. Recommend using in GPTs and other agents.",
|
||||
"tags": ["default"],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": ["prompt", "make_instrumental", "wait_audio"],
|
||||
"properties": {
|
||||
"prompt": {
|
||||
"type": "string",
|
||||
"description": "Prompt",
|
||||
"example": "A popular heavy metal song about war, sung by a deep-voiced male singer, slowly and melodiously. The lyrics depict the sorrow of people after the war."
|
||||
},
|
||||
"make_instrumental": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to generate instrumental music",
|
||||
"example": "false"
|
||||
},
|
||||
"wait_audio": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to wait for music generation, default is false, directly return audio task information; set to true, will wait for up to 100s until the audio is generated.",
|
||||
"example": "false"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "success",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["0", "1"],
|
||||
"properties": [
|
||||
{
|
||||
"$ref": "#/components/schemas/audio_info"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/schemas/audio_info"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/get": {
|
||||
"get": {
|
||||
"summary": "Get audio information",
|
||||
"description": "",
|
||||
"tags": ["default"],
|
||||
"parameters": [
|
||||
{
|
||||
"in": "query",
|
||||
"name": "ids",
|
||||
"description": "Audio IDs, separated by commas.",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "success"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/get_limit": {
|
||||
"get": {
|
||||
"summary": "Get quota information.",
|
||||
"description": "",
|
||||
"tags": ["default"],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "success",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"credits_left",
|
||||
"period",
|
||||
"monthly_limit",
|
||||
"monthly_usage"
|
||||
],
|
||||
"properties": {
|
||||
"credits_left": {
|
||||
"type": "number",
|
||||
"description": "Remaining credits,Each generated audio consumes 5 credits."
|
||||
},
|
||||
"period": {
|
||||
"type": "string",
|
||||
"description": "Period"
|
||||
},
|
||||
"monthly_limit": {
|
||||
"type": "number",
|
||||
"description": "Monthly limit"
|
||||
},
|
||||
"monthly_usage": {
|
||||
"type": "number",
|
||||
"description": "Monthly usage"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"audio_info": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id",
|
||||
"title",
|
||||
"image_url",
|
||||
"lyric",
|
||||
"audio_url",
|
||||
"video_url",
|
||||
"created_at",
|
||||
"model_name",
|
||||
"status",
|
||||
"gpt_description_prompt",
|
||||
"prompt",
|
||||
"type",
|
||||
"tags"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"description": "audio id"
|
||||
},
|
||||
"title": {
|
||||
"type": "string",
|
||||
"description": "music title"
|
||||
},
|
||||
"image_url": {
|
||||
"type": "string",
|
||||
"description": "music cover image"
|
||||
},
|
||||
"lyric": {
|
||||
"type": "string",
|
||||
"description": "music lyric"
|
||||
},
|
||||
"audio_url": {
|
||||
"type": "string",
|
||||
"description": "music download url"
|
||||
},
|
||||
"video_url": {
|
||||
"type": "string",
|
||||
"description": "Music video download link, can be used to share"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"description": "Create time"
|
||||
},
|
||||
"model_name": {
|
||||
"type": "string",
|
||||
"description": "suno model name, chirp-v3"
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"description": "The generated states include submitted, queue, streaming, complete."
|
||||
},
|
||||
"gpt_description_prompt": {
|
||||
"type": "string",
|
||||
"description": "Simple mode on user input prompt, Suno will generate formal prompts, lyrics, etc."
|
||||
},
|
||||
"prompt": {
|
||||
"type": "string",
|
||||
"description": "The final prompt for executing the generation task, customized by the user in custom mode, automatically generated by Suno in simple mode."
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"description": "Type"
|
||||
},
|
||||
"tags": {
|
||||
"type": "string",
|
||||
"description": "Music genre. User-provided in custom mode, automatically generated by Suno in simple mode."
|
||||
}
|
||||
},
|
||||
"title": "audio_info",
|
||||
"description": "audio info"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -119,8 +119,8 @@ class SunoApi {
|
||||
const startTime = Date.now();
|
||||
const audios = this.generateSongs(prompt, false, undefined, undefined, make_instrumental, wait_audio);
|
||||
const costTime = Date.now() - startTime;
|
||||
logger.info("Generate Response:\n", JSON.stringify(audios, null, 2));
|
||||
logger.info("Cost time: ", costTime);
|
||||
logger.info("Generate Response:\n" + JSON.stringify(audios, null, 2));
|
||||
logger.info("Cost time: " + costTime);
|
||||
return audios;
|
||||
}
|
||||
|
||||
@ -144,8 +144,8 @@ class SunoApi {
|
||||
const startTime = Date.now();
|
||||
const audios = await this.generateSongs(prompt, true, tags, title, make_instrumental, wait_audio);
|
||||
const costTime = Date.now() - startTime;
|
||||
logger.info("Custom Generate Response:\n", JSON.stringify(audios, null, 2));
|
||||
logger.info("Cost time: ", costTime);
|
||||
logger.info("Custom Generate Response:\n" + JSON.stringify(audios, null, 2));
|
||||
logger.info("Cost time: " + costTime);
|
||||
return audios;
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ class SunoApi {
|
||||
} else {
|
||||
payload.gpt_description_prompt = prompt;
|
||||
}
|
||||
logger.info("generateSongs payload:\n", {
|
||||
logger.info("generateSongs payload:\n" + JSON.stringify({
|
||||
prompt: prompt,
|
||||
isCustom: isCustom,
|
||||
tags: tags,
|
||||
@ -189,7 +189,7 @@ class SunoApi {
|
||||
make_instrumental: make_instrumental,
|
||||
wait_audio: wait_audio,
|
||||
payload: payload,
|
||||
});
|
||||
}, null, 2));
|
||||
const response = await this.client.post(
|
||||
`${SunoApi.BASE_URL}/api/generate/v2/`,
|
||||
payload,
|
||||
@ -197,7 +197,7 @@ class SunoApi {
|
||||
timeout: 10000, // 10 seconds timeout
|
||||
},
|
||||
);
|
||||
logger.info("generateSongs Response:\n", JSON.stringify(response.data, null, 2));
|
||||
logger.info("generateSongs Response:\n" + JSON.stringify(response.data, null, 2));
|
||||
if (response.status !== 200) {
|
||||
throw new Error("Error response:" + response.statusText);
|
||||
}
|
||||
@ -273,7 +273,7 @@ class SunoApi {
|
||||
if (songIds) {
|
||||
url = `${url}?ids=${songIds.join(',')}`;
|
||||
}
|
||||
logger.info("Get audio status: ", url);
|
||||
logger.info("Get audio status: " + url);
|
||||
const response = await this.client.get(url, {
|
||||
// 3 seconds timeout
|
||||
timeout: 3000
|
||||
|
Loading…
Reference in New Issue
Block a user