60 lines
2.1 KiB
TypeScript
60 lines
2.1 KiB
TypeScript
import type { VoiceTool } from './_types'
|
||
import { tabletGet, tabletJson } from './_http'
|
||
|
||
const getNowPlaying: VoiceTool = {
|
||
schema: {
|
||
type: 'function',
|
||
function: {
|
||
name: 'get_now_playing',
|
||
description:
|
||
'Узнать что сейчас играет в Spotify: название трека, исполнитель, статус воспроизведения. ' +
|
||
'Используй для вопросов «что сейчас играет», «какая музыка», «кто поёт».',
|
||
parameters: { type: 'object', properties: {} },
|
||
},
|
||
},
|
||
async execute() {
|
||
return tabletGet('/api/voice/tools/spotify')
|
||
},
|
||
}
|
||
|
||
const controlSpotify: VoiceTool = {
|
||
schema: {
|
||
type: 'function',
|
||
function: {
|
||
name: 'control_spotify',
|
||
description:
|
||
'Управление Spotify: включить музыку (можно с поиском), поставить на паузу, следующий/предыдущий трек, громкость. ' +
|
||
'Используй для команд «включи музыку», «поставь паузу», «следующий трек», «громкость 50%», ' +
|
||
'«включи The Weeknd», «поставь джаз».',
|
||
parameters: {
|
||
type: 'object',
|
||
properties: {
|
||
action: {
|
||
type: 'string',
|
||
enum: ['play', 'pause', 'next', 'previous', 'volume'],
|
||
description: 'Действие: play, pause, next, previous, volume',
|
||
},
|
||
query: {
|
||
type: 'string',
|
||
description: 'Поисковый запрос для action=play: исполнитель, трек или жанр',
|
||
},
|
||
volume: {
|
||
type: 'number',
|
||
description: 'Громкость 0-100 для action=volume',
|
||
},
|
||
},
|
||
required: ['action'],
|
||
},
|
||
},
|
||
},
|
||
async execute(args) {
|
||
return tabletJson('POST', '/api/voice/tools/spotify', {
|
||
action: args.action,
|
||
query: args.query,
|
||
volume: args.volume,
|
||
})
|
||
},
|
||
}
|
||
|
||
export const tools: VoiceTool[] = [getNowPlaying, controlSpotify]
|