You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.4 KiB

6 months ago
import { invoke } from '@tauri-apps/api/core';
5 months ago
import { fetch } from '@tauri-apps/plugin-http';
export const OSC_ADDRESS={
LIGHT: '/light',
STATUS: '/status',
INPUT: '/input',
COUNTDOWN: '/countdown',
VOLUME: '/volume',
SCRIPT: '/script',
SUMMARY: '/summary',
PROMPT: '/prompt',
4 months ago
SAVE: '/save',
5 months ago
}
6 months ago
export async function sendOsc(key, message){
5 months ago
if(message === undefined || message === null || message === '') {
console.warn('sendOsc: message is empty, skipping');
return;
}
try{
console.log(`Sending OSC message: ${key} -> ${message}`);
await invoke('send_osc_message', {
key: key,
message: message.toString(),
host:`0.0.0.0:0`,
target: '127.0.0.1:9000',
});
}catch (error){
console.error('Error sending OSC message:', error);
}
5 months ago
}
// send to python fastapi
export async function updatePrompt(prompt) {
console.log(`Updating prompt: ${prompt}`);
try{
await fetch('http://localhost:34800/api/update/prompt', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ prompt })
});
}catch(error){
console.error('Error updating prompt:', error);
5 months ago
}
6 months ago
}