Files
smart-home-tablet/lib/tools/spotify.ts
Cosmo 9bea298687
Some checks failed
Deploy / deploy (push) Failing after 1m40s
feat: Spotify integration (OAuth + voice tools)
2026-05-01 11:02:11 +00:00

60 lines
2.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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]