import { sdk } from '../sdk' import { configFile } from '../file-models/config.json' const { InputSpec, Value } = sdk // Operator's Gemma (or any OpenAI-compatible chat-completions) endpoint // + which model to request. Both fields live-reload so the operator // can pull a different Gemma SKU on Ollama and update the model name // here without restarting the relay. const inputSpec = InputSpec.of({ relay_gemma_base_url: Value.text({ name: 'Gemma Base URL', description: "URL of the operator's Gemma / Ollama / OpenAI-compatible analysis 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:11434", required: false, default: '', minLength: 0, maxLength: 256, patterns: [ { regex: '^(https?://.+)?$', description: 'Must be empty or start with http:// or https://', }, ], }), relay_gemma_model: Value.text({ name: 'Gemma Model Name', description: 'The model identifier sent in upstream chat-completions requests. Match whatever name your Ollama / vLLM / llama.cpp deployment exposes (run `ollama list` to see what you have pulled). Example: gemma3:27b, gemma2:9b, llama3.1:70b', required: true, default: 'gemma3:27b', minLength: 1, maxLength: 128, }), }) export const setGemmaUrl = sdk.Action.withInput( 'set-gemma-url', async ({ effects }) => ({ name: 'Set Gemma URL', description: 'Optional. Where the relay forwards analysis requests once a user exceeds their monthly Gemini cap. Leave URL empty to disable the fallback.', warning: null, allowedStatuses: 'any', group: null, visibility: 'enabled', }), inputSpec, async ({ effects }) => { const config = await configFile.read().once() return { relay_gemma_base_url: config?.relay_gemma_base_url || '', relay_gemma_model: config?.relay_gemma_model || 'gemma3:27b', } }, async ({ effects, input }) => { await configFile.merge(effects, { relay_gemma_base_url: (input.relay_gemma_base_url || '').trim(), relay_gemma_model: (input.relay_gemma_model || 'gemma3:27b').trim(), }) return null }, )