initial relay scaffold
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import { sdk } from '../sdk'
|
||||
import { configFile } from '../file-models/config.json'
|
||||
|
||||
const { InputSpec, Value } = sdk
|
||||
|
||||
// The operator's Gemini API key. This is the relay's primary backend
|
||||
// — Recap requests for both transcribe and analyze go to Gemini first,
|
||||
// and only spill to the optional Parakeet/Gemma backends once a user
|
||||
// exceeds their tier's monthly Gemini cap.
|
||||
//
|
||||
// Free key from https://aistudio.google.com/apikey. Track usage in
|
||||
// the Google AI Studio dashboard to know what tier pricing should be.
|
||||
const inputSpec = InputSpec.of({
|
||||
relay_gemini_api_key: Value.text({
|
||||
name: 'Gemini API Key',
|
||||
description:
|
||||
'The relay\'s Google Gemini API key. Used for transcribe + analyze forwarding. Get one at https://aistudio.google.com/apikey',
|
||||
required: true,
|
||||
default: null,
|
||||
masked: true,
|
||||
minLength: 1,
|
||||
maxLength: 256,
|
||||
}),
|
||||
})
|
||||
|
||||
export const setGeminiKey = sdk.Action.withInput(
|
||||
'set-gemini-key',
|
||||
|
||||
async ({ effects }) => ({
|
||||
name: 'Set Gemini API Key',
|
||||
description:
|
||||
"The operator's Gemini key. Required — the relay will refuse to serve traffic until this is set.",
|
||||
warning: null,
|
||||
allowedStatuses: 'any',
|
||||
group: null,
|
||||
visibility: 'enabled',
|
||||
}),
|
||||
|
||||
inputSpec,
|
||||
|
||||
async ({ effects }) => {
|
||||
const config = await configFile.read().once()
|
||||
return {
|
||||
relay_gemini_api_key: config?.relay_gemini_api_key || undefined,
|
||||
}
|
||||
},
|
||||
|
||||
async ({ effects, input }) => {
|
||||
await configFile.merge(effects, {
|
||||
relay_gemini_api_key: input.relay_gemini_api_key,
|
||||
})
|
||||
return null
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user