@elizaos/plugin-suno 1.0.6-alpha.2 → 1.0.6-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{biome.json.bak → biome.json} +8 -7
- package/dist/index.js +72 -6
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
- package/src/actions/customGenerate.ts +182 -182
- package/src/actions/extend.ts +160 -160
- package/src/actions/generate.ts +171 -171
- package/src/providers/suno.ts +9 -49
- package/tsup.config.ts +1 -1
package/src/actions/extend.ts
CHANGED
|
@@ -1,164 +1,164 @@
|
|
|
1
|
-
import type { Action, IAgentRuntime, Memory, State, HandlerCallback } from "@elizaos/core";
|
|
2
|
-
import { SunoProvider } from "../providers/suno";
|
|
3
|
-
import type { ExtendParams } from "../types";
|
|
1
|
+
import type { Action, IAgentRuntime, Memory, State, HandlerCallback } from "@elizaos/core";
|
|
2
|
+
import { SunoProvider } from "../providers/suno";
|
|
3
|
+
import type { ExtendParams } from "../types";
|
|
4
|
+
|
|
5
|
+
const extendAudio: Action = {
|
|
6
|
+
name: "extend-audio",
|
|
7
|
+
description: "Extend the duration of an existing audio generation",
|
|
8
|
+
similes: [
|
|
9
|
+
"LENGTHEN_AUDIO",
|
|
10
|
+
"PROLONG_AUDIO",
|
|
11
|
+
"INCREASE_DURATION",
|
|
12
|
+
"MAKE_AUDIO_LONGER"
|
|
13
|
+
],
|
|
14
|
+
|
|
15
|
+
validate: async (runtime: any, message: any, state?: any, options?: any): Promise<boolean> => {
|
|
16
|
+
const __avTextRaw = typeof message?.content?.text === 'string' ? message.content.text : '';
|
|
17
|
+
const __avText = __avTextRaw.toLowerCase();
|
|
18
|
+
const __avKeywords = ['extend', 'audio'];
|
|
19
|
+
const __avKeywordOk =
|
|
20
|
+
__avKeywords.length > 0 &&
|
|
21
|
+
__avKeywords.some((word) => word.length > 0 && __avText.includes(word));
|
|
22
|
+
const __avRegex = new RegExp('\\b(?:extend|audio)\\b', 'i');
|
|
23
|
+
const __avRegexOk = __avRegex.test(__avText);
|
|
24
|
+
const __avSource = String(message?.content?.source ?? message?.source ?? '');
|
|
25
|
+
const __avExpectedSource = '';
|
|
26
|
+
const __avSourceOk = __avExpectedSource
|
|
27
|
+
? __avSource === __avExpectedSource
|
|
28
|
+
: Boolean(__avSource || state || runtime?.agentId || runtime?.getService || runtime?.getSetting);
|
|
29
|
+
const __avOptions = options && typeof options === 'object' ? options : {};
|
|
30
|
+
const __avInputOk =
|
|
31
|
+
__avText.trim().length > 0 ||
|
|
32
|
+
Object.keys(__avOptions as Record<string, unknown>).length > 0 ||
|
|
33
|
+
Boolean(message?.content && typeof message.content === 'object');
|
|
4
34
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
similes: [
|
|
9
|
-
"LENGTHEN_AUDIO",
|
|
10
|
-
"PROLONG_AUDIO",
|
|
11
|
-
"INCREASE_DURATION",
|
|
12
|
-
"MAKE_AUDIO_LONGER"
|
|
13
|
-
],
|
|
35
|
+
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
14
38
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const __avText = __avTextRaw.toLowerCase();
|
|
18
|
-
const __avKeywords = ['extend', 'audio'];
|
|
19
|
-
const __avKeywordOk =
|
|
20
|
-
__avKeywords.length > 0 &&
|
|
21
|
-
__avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
|
|
22
|
-
const __avRegex = new RegExp('\\b(?:extend|audio)\\b', 'i');
|
|
23
|
-
const __avRegexOk = __avRegex.test(__avText);
|
|
24
|
-
const __avSource = String(message?.content?.source ?? message?.source ?? '');
|
|
25
|
-
const __avExpectedSource = '';
|
|
26
|
-
const __avSourceOk = __avExpectedSource
|
|
27
|
-
? __avSource === __avExpectedSource
|
|
28
|
-
: Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
|
|
29
|
-
const __avOptions = options && typeof options === 'object' ? options : {};
|
|
30
|
-
const __avInputOk =
|
|
31
|
-
__avText.trim().length > 0 ||
|
|
32
|
-
Object.keys(__avOptions as Record<string, unknown>).length > 0 ||
|
|
33
|
-
Boolean(message?.content && typeof message.content === 'object');
|
|
34
|
-
|
|
35
|
-
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const __avLegacyValidate = async (runtime: IAgentRuntime, _message: Memory) => {
|
|
40
|
-
return !!runtime.getSetting("SUNO_API_KEY");
|
|
39
|
+
const __avLegacyValidate = async (runtime: IAgentRuntime, _message: Memory) => {
|
|
40
|
+
return !!runtime.getSetting("SUNO_API_KEY");
|
|
41
41
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
handler: async (
|
|
50
|
-
runtime: IAgentRuntime,
|
|
51
|
-
message: Memory,
|
|
52
|
-
state: State,
|
|
53
|
-
_options: { [key: string]: unknown },
|
|
54
|
-
callback?: HandlerCallback
|
|
55
|
-
): Promise<boolean> => {
|
|
56
|
-
try {
|
|
57
|
-
const provider = await SunoProvider.get(runtime, message, state);
|
|
58
|
-
const content = message.content as unknown as ExtendParams;
|
|
59
|
-
|
|
60
|
-
if (!content.audio_id || !content.duration) {
|
|
61
|
-
throw new Error("Missing required parameters: audio_id and duration");
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const response = await provider.request('/extend', {
|
|
65
|
-
method: 'POST',
|
|
66
|
-
body: JSON.stringify({
|
|
67
|
-
audio_id: content.audio_id,
|
|
68
|
-
duration: content.duration
|
|
69
|
-
})
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
if (callback) {
|
|
73
|
-
callback({
|
|
74
|
-
text: `Successfully extended audio ${content.audio_id}`,
|
|
75
|
-
content: response
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return true;
|
|
80
|
-
} catch (error) {
|
|
81
|
-
if (callback) {
|
|
82
|
-
callback({
|
|
83
|
-
text: `Failed to extend audio: ${(error as Error).message}`,
|
|
84
|
-
error: error
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
examples: [
|
|
92
|
-
[
|
|
93
|
-
{
|
|
94
|
-
user: "{{user1}}",
|
|
95
|
-
content: {
|
|
96
|
-
text: "Make this song longer by 30 seconds",
|
|
97
|
-
audio_id: "abc123",
|
|
98
|
-
duration: 30
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
user: "{{agent}}",
|
|
103
|
-
content: {
|
|
104
|
-
text: "I'll extend your song by 30 seconds.",
|
|
105
|
-
action: "extend-audio"
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
user: "{{agent}}",
|
|
110
|
-
content: {
|
|
111
|
-
text: "Successfully extended your song by 30 seconds."
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
],
|
|
115
|
-
[
|
|
116
|
-
{
|
|
117
|
-
user: "{{user1}}",
|
|
118
|
-
content: {
|
|
119
|
-
text: "Double the length of this track",
|
|
120
|
-
audio_id: "xyz789",
|
|
121
|
-
duration: 60
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
user: "{{agent}}",
|
|
126
|
-
content: {
|
|
127
|
-
text: "I'll double the duration of your track.",
|
|
128
|
-
action: "extend-audio"
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
user: "{{agent}}",
|
|
133
|
-
content: {
|
|
134
|
-
text: "Successfully doubled the length of your track to 60 seconds."
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
],
|
|
138
|
-
[
|
|
139
|
-
{
|
|
140
|
-
user: "{{user1}}",
|
|
141
|
-
content: {
|
|
142
|
-
text: "Add 15 more seconds to this melody",
|
|
143
|
-
audio_id: "def456",
|
|
144
|
-
duration: 15
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
user: "{{agent}}",
|
|
149
|
-
content: {
|
|
150
|
-
text: "I'll add 15 seconds to your melody.",
|
|
151
|
-
action: "extend-audio"
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
user: "{{agent}}",
|
|
156
|
-
content: {
|
|
157
|
-
text: "Successfully added 15 seconds to your melody."
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
]
|
|
161
|
-
]
|
|
162
|
-
};
|
|
163
|
-
|
|
42
|
+
try {
|
|
43
|
+
return Boolean(await (__avLegacyValidate as any)(runtime, message, state, options));
|
|
44
|
+
} catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
handler: async (
|
|
50
|
+
runtime: IAgentRuntime,
|
|
51
|
+
message: Memory,
|
|
52
|
+
state: State,
|
|
53
|
+
_options: { [key: string]: unknown },
|
|
54
|
+
callback?: HandlerCallback
|
|
55
|
+
): Promise<boolean> => {
|
|
56
|
+
try {
|
|
57
|
+
const provider = await SunoProvider.get(runtime, message, state);
|
|
58
|
+
const content = message.content as unknown as ExtendParams;
|
|
59
|
+
|
|
60
|
+
if (!content.audio_id || !content.duration) {
|
|
61
|
+
throw new Error("Missing required parameters: audio_id and duration");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const response = await provider.request('/extend', {
|
|
65
|
+
method: 'POST',
|
|
66
|
+
body: JSON.stringify({
|
|
67
|
+
audio_id: content.audio_id,
|
|
68
|
+
duration: content.duration
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
if (callback) {
|
|
73
|
+
callback({
|
|
74
|
+
text: `Successfully extended audio ${content.audio_id}`,
|
|
75
|
+
content: response
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return true;
|
|
80
|
+
} catch (error) {
|
|
81
|
+
if (callback) {
|
|
82
|
+
callback({
|
|
83
|
+
text: `Failed to extend audio: ${(error as Error).message}`,
|
|
84
|
+
error: error
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
examples: [
|
|
92
|
+
[
|
|
93
|
+
{
|
|
94
|
+
user: "{{user1}}",
|
|
95
|
+
content: {
|
|
96
|
+
text: "Make this song longer by 30 seconds",
|
|
97
|
+
audio_id: "abc123",
|
|
98
|
+
duration: 30
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
user: "{{agent}}",
|
|
103
|
+
content: {
|
|
104
|
+
text: "I'll extend your song by 30 seconds.",
|
|
105
|
+
action: "extend-audio"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
user: "{{agent}}",
|
|
110
|
+
content: {
|
|
111
|
+
text: "Successfully extended your song by 30 seconds."
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
[
|
|
116
|
+
{
|
|
117
|
+
user: "{{user1}}",
|
|
118
|
+
content: {
|
|
119
|
+
text: "Double the length of this track",
|
|
120
|
+
audio_id: "xyz789",
|
|
121
|
+
duration: 60
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
user: "{{agent}}",
|
|
126
|
+
content: {
|
|
127
|
+
text: "I'll double the duration of your track.",
|
|
128
|
+
action: "extend-audio"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
user: "{{agent}}",
|
|
133
|
+
content: {
|
|
134
|
+
text: "Successfully doubled the length of your track to 60 seconds."
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
[
|
|
139
|
+
{
|
|
140
|
+
user: "{{user1}}",
|
|
141
|
+
content: {
|
|
142
|
+
text: "Add 15 more seconds to this melody",
|
|
143
|
+
audio_id: "def456",
|
|
144
|
+
duration: 15
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
user: "{{agent}}",
|
|
149
|
+
content: {
|
|
150
|
+
text: "I'll add 15 seconds to your melody.",
|
|
151
|
+
action: "extend-audio"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
user: "{{agent}}",
|
|
156
|
+
content: {
|
|
157
|
+
text: "Successfully added 15 seconds to your melody."
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
]
|
|
162
|
+
};
|
|
163
|
+
|
|
164
164
|
export default extendAudio;
|
package/src/actions/generate.ts
CHANGED
|
@@ -1,175 +1,175 @@
|
|
|
1
|
-
import type { Action, IAgentRuntime, Memory, State, HandlerCallback } from "@elizaos/core";
|
|
2
|
-
import { SunoProvider } from "../providers/suno";
|
|
3
|
-
import type { GenerateParams } from "../types";
|
|
1
|
+
import type { Action, IAgentRuntime, Memory, State, HandlerCallback } from "@elizaos/core";
|
|
2
|
+
import { SunoProvider } from "../providers/suno";
|
|
3
|
+
import type { GenerateParams } from "../types";
|
|
4
|
+
|
|
5
|
+
const generateMusic: Action = {
|
|
6
|
+
name: "generate-music",
|
|
7
|
+
description: "Generate music using Suno AI",
|
|
8
|
+
similes: [
|
|
9
|
+
"CREATE_MUSIC",
|
|
10
|
+
"MAKE_MUSIC",
|
|
11
|
+
"COMPOSE_MUSIC",
|
|
12
|
+
"GENERATE_AUDIO",
|
|
13
|
+
"CREATE_SONG",
|
|
14
|
+
"MAKE_SONG"
|
|
15
|
+
],
|
|
16
|
+
|
|
17
|
+
validate: async (runtime: any, message: any, state?: any, options?: any): Promise<boolean> => {
|
|
18
|
+
const __avTextRaw = typeof message?.content?.text === 'string' ? message.content.text : '';
|
|
19
|
+
const __avText = __avTextRaw.toLowerCase();
|
|
20
|
+
const __avKeywords = ['generate', 'music'];
|
|
21
|
+
const __avKeywordOk =
|
|
22
|
+
__avKeywords.length > 0 &&
|
|
23
|
+
__avKeywords.some((word) => word.length > 0 && __avText.includes(word));
|
|
24
|
+
const __avRegex = new RegExp('\\b(?:generate|music)\\b', 'i');
|
|
25
|
+
const __avRegexOk = __avRegex.test(__avText);
|
|
26
|
+
const __avSource = String(message?.content?.source ?? message?.source ?? '');
|
|
27
|
+
const __avExpectedSource = '';
|
|
28
|
+
const __avSourceOk = __avExpectedSource
|
|
29
|
+
? __avSource === __avExpectedSource
|
|
30
|
+
: Boolean(__avSource || state || runtime?.agentId || runtime?.getService || runtime?.getSetting);
|
|
31
|
+
const __avOptions = options && typeof options === 'object' ? options : {};
|
|
32
|
+
const __avInputOk =
|
|
33
|
+
__avText.trim().length > 0 ||
|
|
34
|
+
Object.keys(__avOptions as Record<string, unknown>).length > 0 ||
|
|
35
|
+
Boolean(message?.content && typeof message.content === 'object');
|
|
4
36
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
similes: [
|
|
9
|
-
"CREATE_MUSIC",
|
|
10
|
-
"MAKE_MUSIC",
|
|
11
|
-
"COMPOSE_MUSIC",
|
|
12
|
-
"GENERATE_AUDIO",
|
|
13
|
-
"CREATE_SONG",
|
|
14
|
-
"MAKE_SONG"
|
|
15
|
-
],
|
|
37
|
+
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
16
40
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const __avText = __avTextRaw.toLowerCase();
|
|
20
|
-
const __avKeywords = ['generate', 'music'];
|
|
21
|
-
const __avKeywordOk =
|
|
22
|
-
__avKeywords.length > 0 &&
|
|
23
|
-
__avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
|
|
24
|
-
const __avRegex = new RegExp('\\b(?:generate|music)\\b', 'i');
|
|
25
|
-
const __avRegexOk = __avRegex.test(__avText);
|
|
26
|
-
const __avSource = String(message?.content?.source ?? message?.source ?? '');
|
|
27
|
-
const __avExpectedSource = '';
|
|
28
|
-
const __avSourceOk = __avExpectedSource
|
|
29
|
-
? __avSource === __avExpectedSource
|
|
30
|
-
: Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
|
|
31
|
-
const __avOptions = options && typeof options === 'object' ? options : {};
|
|
32
|
-
const __avInputOk =
|
|
33
|
-
__avText.trim().length > 0 ||
|
|
34
|
-
Object.keys(__avOptions as Record<string, unknown>).length > 0 ||
|
|
35
|
-
Boolean(message?.content && typeof message.content === 'object');
|
|
36
|
-
|
|
37
|
-
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const __avLegacyValidate = async (runtime: IAgentRuntime, _message: Memory) => {
|
|
42
|
-
return !!runtime.getSetting("SUNO_API_KEY");
|
|
41
|
+
const __avLegacyValidate = async (runtime: IAgentRuntime, _message: Memory) => {
|
|
42
|
+
return !!runtime.getSetting("SUNO_API_KEY");
|
|
43
43
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
handler: async (
|
|
52
|
-
runtime: IAgentRuntime,
|
|
53
|
-
message: Memory,
|
|
54
|
-
state: State,
|
|
55
|
-
_options: { [key: string]: unknown },
|
|
56
|
-
callback?: HandlerCallback
|
|
57
|
-
): Promise<boolean> => {
|
|
58
|
-
try {
|
|
59
|
-
const provider = await SunoProvider.get(runtime, message, state);
|
|
60
|
-
const content = message.content as unknown as GenerateParams;
|
|
61
|
-
|
|
62
|
-
if (!content.prompt) {
|
|
63
|
-
throw new Error("Missing required parameter: prompt");
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const response = await provider.request('/generate', {
|
|
67
|
-
method: 'POST',
|
|
68
|
-
body: JSON.stringify({
|
|
69
|
-
prompt: content.prompt,
|
|
70
|
-
duration: content.duration || 30,
|
|
71
|
-
temperature: content.temperature || 1.0,
|
|
72
|
-
top_k: content.topK || 250,
|
|
73
|
-
top_p: content.topP || 0.95,
|
|
74
|
-
classifier_free_guidance: content.classifier_free_guidance || 3.0
|
|
75
|
-
})
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
if (callback) {
|
|
79
|
-
callback({
|
|
80
|
-
text: 'Successfully generated music based on your prompt',
|
|
81
|
-
content: response
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return true;
|
|
86
|
-
} catch (error) {
|
|
87
|
-
if (callback) {
|
|
88
|
-
callback({
|
|
89
|
-
text: `Failed to extend audio: ${(error as Error).message}`,
|
|
90
|
-
error: error
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
examples: [
|
|
98
|
-
[
|
|
99
|
-
{
|
|
100
|
-
user: "{{user1}}",
|
|
101
|
-
content: {
|
|
102
|
-
text: "Create a happy and energetic song",
|
|
103
|
-
prompt: "A cheerful and energetic melody with upbeat rhythm",
|
|
104
|
-
duration: 30,
|
|
105
|
-
temperature: 1.0
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
user: "{{agent}}",
|
|
110
|
-
content: {
|
|
111
|
-
text: "I'll generate a happy and energetic song for you.",
|
|
112
|
-
action: "generate-music"
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
user: "{{agent}}",
|
|
117
|
-
content: {
|
|
118
|
-
text: "Successfully generated your upbeat and energetic song."
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
],
|
|
122
|
-
[
|
|
123
|
-
{
|
|
124
|
-
user: "{{user1}}",
|
|
125
|
-
content: {
|
|
126
|
-
text: "Generate a relaxing ambient track",
|
|
127
|
-
prompt: "A peaceful ambient soundscape with gentle waves and soft pads",
|
|
128
|
-
duration: 45,
|
|
129
|
-
temperature: 0.8,
|
|
130
|
-
classifier_free_guidance: 4.0
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
user: "{{agent}}",
|
|
135
|
-
content: {
|
|
136
|
-
text: "I'll create a calming ambient piece for you.",
|
|
137
|
-
action: "generate-music"
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
user: "{{agent}}",
|
|
142
|
-
content: {
|
|
143
|
-
text: "Successfully generated your relaxing ambient soundscape."
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
],
|
|
147
|
-
[
|
|
148
|
-
{
|
|
149
|
-
user: "{{user1}}",
|
|
150
|
-
content: {
|
|
151
|
-
text: "Make a short jingle for my podcast",
|
|
152
|
-
prompt: "A catchy and professional podcast intro jingle",
|
|
153
|
-
duration: 15,
|
|
154
|
-
temperature: 1.2,
|
|
155
|
-
top_k: 300
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
user: "{{agent}}",
|
|
160
|
-
content: {
|
|
161
|
-
text: "I'll generate a podcast jingle for you.",
|
|
162
|
-
action: "generate-music"
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
user: "{{agent}}",
|
|
167
|
-
content: {
|
|
168
|
-
text: "Successfully generated your podcast jingle."
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
]
|
|
172
|
-
]
|
|
173
|
-
};
|
|
174
|
-
|
|
44
|
+
try {
|
|
45
|
+
return Boolean(await (__avLegacyValidate as any)(runtime, message, state, options));
|
|
46
|
+
} catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
handler: async (
|
|
52
|
+
runtime: IAgentRuntime,
|
|
53
|
+
message: Memory,
|
|
54
|
+
state: State,
|
|
55
|
+
_options: { [key: string]: unknown },
|
|
56
|
+
callback?: HandlerCallback
|
|
57
|
+
): Promise<boolean> => {
|
|
58
|
+
try {
|
|
59
|
+
const provider = await SunoProvider.get(runtime, message, state);
|
|
60
|
+
const content = message.content as unknown as GenerateParams;
|
|
61
|
+
|
|
62
|
+
if (!content.prompt) {
|
|
63
|
+
throw new Error("Missing required parameter: prompt");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const response = await provider.request('/generate', {
|
|
67
|
+
method: 'POST',
|
|
68
|
+
body: JSON.stringify({
|
|
69
|
+
prompt: content.prompt,
|
|
70
|
+
duration: content.duration || 30,
|
|
71
|
+
temperature: content.temperature || 1.0,
|
|
72
|
+
top_k: content.topK || 250,
|
|
73
|
+
top_p: content.topP || 0.95,
|
|
74
|
+
classifier_free_guidance: content.classifier_free_guidance || 3.0
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if (callback) {
|
|
79
|
+
callback({
|
|
80
|
+
text: 'Successfully generated music based on your prompt',
|
|
81
|
+
content: response
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return true;
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if (callback) {
|
|
88
|
+
callback({
|
|
89
|
+
text: `Failed to extend audio: ${(error as Error).message}`,
|
|
90
|
+
error: error
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
examples: [
|
|
98
|
+
[
|
|
99
|
+
{
|
|
100
|
+
user: "{{user1}}",
|
|
101
|
+
content: {
|
|
102
|
+
text: "Create a happy and energetic song",
|
|
103
|
+
prompt: "A cheerful and energetic melody with upbeat rhythm",
|
|
104
|
+
duration: 30,
|
|
105
|
+
temperature: 1.0
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
user: "{{agent}}",
|
|
110
|
+
content: {
|
|
111
|
+
text: "I'll generate a happy and energetic song for you.",
|
|
112
|
+
action: "generate-music"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
user: "{{agent}}",
|
|
117
|
+
content: {
|
|
118
|
+
text: "Successfully generated your upbeat and energetic song."
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
[
|
|
123
|
+
{
|
|
124
|
+
user: "{{user1}}",
|
|
125
|
+
content: {
|
|
126
|
+
text: "Generate a relaxing ambient track",
|
|
127
|
+
prompt: "A peaceful ambient soundscape with gentle waves and soft pads",
|
|
128
|
+
duration: 45,
|
|
129
|
+
temperature: 0.8,
|
|
130
|
+
classifier_free_guidance: 4.0
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
user: "{{agent}}",
|
|
135
|
+
content: {
|
|
136
|
+
text: "I'll create a calming ambient piece for you.",
|
|
137
|
+
action: "generate-music"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
user: "{{agent}}",
|
|
142
|
+
content: {
|
|
143
|
+
text: "Successfully generated your relaxing ambient soundscape."
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
],
|
|
147
|
+
[
|
|
148
|
+
{
|
|
149
|
+
user: "{{user1}}",
|
|
150
|
+
content: {
|
|
151
|
+
text: "Make a short jingle for my podcast",
|
|
152
|
+
prompt: "A catchy and professional podcast intro jingle",
|
|
153
|
+
duration: 15,
|
|
154
|
+
temperature: 1.2,
|
|
155
|
+
top_k: 300
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
user: "{{agent}}",
|
|
160
|
+
content: {
|
|
161
|
+
text: "I'll generate a podcast jingle for you.",
|
|
162
|
+
action: "generate-music"
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
user: "{{agent}}",
|
|
167
|
+
content: {
|
|
168
|
+
text: "Successfully generated your podcast jingle."
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
]
|
|
173
|
+
};
|
|
174
|
+
|
|
175
175
|
export default generateMusic;
|