60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
import { sdk } from '../sdk'
|
|
import { configFile } from '../file-models/config.json'
|
|
|
|
const { InputSpec, Value } = sdk
|
|
|
|
// Optional Parakeet endpoint for the operator-hardware fallback path.
|
|
// When a Pro/Max user exceeds their Gemini monthly cap, the relay
|
|
// routes transcribe requests here instead. Empty disables the fallback
|
|
// — over-cap users get 402.
|
|
//
|
|
// In a typical setup this points at the operator's NVIDIA Spark or
|
|
// similar local GPU box running the NeMo / Parakeet HTTP wrapper.
|
|
const inputSpec = InputSpec.of({
|
|
relay_parakeet_base_url: Value.text({
|
|
name: 'Parakeet Base URL',
|
|
description:
|
|
'URL of the operator\'s Parakeet (or any Whisper-API-compatible) transcription endpoint. Used as the overflow path once a user exceeds their monthly Gemini cap. Leave empty to hard-cap at the Gemini limit. Example: http://192.168.1.87:8000',
|
|
required: false,
|
|
default: '',
|
|
minLength: 0,
|
|
maxLength: 256,
|
|
patterns: [
|
|
{
|
|
regex: '^(https?://.+)?$',
|
|
description: 'Must be empty or start with http:// or https://',
|
|
},
|
|
],
|
|
}),
|
|
})
|
|
|
|
export const setParakeetUrl = sdk.Action.withInput(
|
|
'set-parakeet-url',
|
|
|
|
async ({ effects }) => ({
|
|
name: 'Set Parakeet URL',
|
|
description:
|
|
"Optional. Where the relay forwards transcription requests once a user exceeds their monthly Gemini cap. Leave empty to disable the operator-hardware fallback.",
|
|
warning: null,
|
|
allowedStatuses: 'any',
|
|
group: null,
|
|
visibility: 'enabled',
|
|
}),
|
|
|
|
inputSpec,
|
|
|
|
async ({ effects }) => {
|
|
const config = await configFile.read().once()
|
|
return {
|
|
relay_parakeet_base_url: config?.relay_parakeet_base_url || '',
|
|
}
|
|
},
|
|
|
|
async ({ effects, input }) => {
|
|
await configFile.merge(effects, {
|
|
relay_parakeet_base_url: (input.relay_parakeet_base_url || '').trim(),
|
|
})
|
|
return null
|
|
},
|
|
)
|