mirror of
https://github.com/mudler/LocalAI.git
synced 2026-11-03 19:14:56 -05:00
* chore(backends): remove the liquid-audio Python backend The backend targets liquid-audio, which loads LFM2 checkpoints only. Remove its directory, the gallery file and the LFM2.5-Audio model entries, the library and generated backend gallery entries, the backend matrix and CI job, the Makefile targets and the golden test fixtures that listed it. Assisted-by: Claude:claude-haiku-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * refactor(config): drop liquid-audio from capabilities, importers and UI With the liquid-audio backend gone, remove its capability entry, its importer, its artifact-gate entry and the realtime_audio heuristic that only matched that backend. realtime_audio is now set only through known_usecases. Update the Talk and fine-tuning pages, the docs and the swagger text that named the backend. Assisted-by: Claude:claude-haiku-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * chore(llama-cpp): bump llama.cpp to e486a4b5 Move the llama.cpp pin to e486a4b559617dc88bf79978996f6c670b6bbc9d, the master head of 2026-10-28. It contains the LFM3-Audio support (ggml-org/llama.cpp#31257) and the realtime server split (ggml-org/llama.cpp#31269). The score task patch is regenerated against the new pin. It applies with git apply and with patch -p1, with no offset and no fuzz. Its hunks in server-task.h and server-context.cpp were rebased by hand next to SERVER_TASK_TYPE_REALTIME and the control dispatch. The C++ backend was built on CPU for this change: the llama, mtmd and server-context libraries and the grpc-server binary link. Assisted-by: Claude:claude-haiku-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(llama-cpp): compile server-realtime.cpp into grpc-server server-context.cpp includes server-realtime.h, and its realtime slot type is defined in server-realtime.cpp. Upstream compiles that file into the server library. The gRPC server is one translation unit, so it must include the file too, or the link fails. The include is guarded by __has_include. Forks that predate the realtime split do not ship the file, so they keep building as before. Assisted-by: Claude:claude-haiku-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * chore(llama-cpp): probe realtime and TTS voice support in prepare.sh prepare.sh writes llama_compat.h from probes on the checkout. Add two: LOCALAI_HAS_REALTIME (SERVER_TASK_TYPE_REALTIME in server-task.h) and LOCALAI_HAS_TTS_VOICE (set_voice in mtmd-helper.h). The probes let the gRPC server choose the realtime and voice code paths per checkout, so forks without them keep compiling. Assisted-by: Claude:claude-haiku-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(llama-cpp): advertise speech recognition and speech-to-speech llama-cpp now registers the AudioTranscription and AudioToAudioStream RPCs, with the transcript and realtime_audio usecases. The default usecase stays chat, so a plain GGUF is still a chat model. The backend implements the RPCs in a follow-up change; until then the calls return UNIMPLEMENTED. Assisted-by: Claude:claude-haiku-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(config): add pipeline.any_to_any for speech-to-speech models A realtime_audio model that serves the whole speech loop itself sets pipeline.any_to_any. The flag is off by default, so chained pipelines and existing realtime_audio configs are unchanged. The realtime_audio heuristic stays explicit: a llama-cpp model is never a Talk-page model unless known_usecases says so. Assisted-by: Claude:claude-haiku-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(config): read the audio encoder and speech-to-speech projector flags Add HasAudioEncoderProjector for clip.has_audio_encoder and HasSpeechToSpeechProjector, which requires the LFM3 audio encoder family together with the gen-audio decoder. Qwen3-TTS sets both encoder flags too, so the flags alone cannot tell it apart from LFM3. Assisted-by: Claude:claude-haiku-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(importer): import LFM3-Audio projectors as speech-to-speech An mmproj that carries the LFM3 audio encoder and the gen-audio decoder now imports with known_usecases realtime_audio, chat, transcript and tts, pipeline.any_to_any: true, the parallel:2 option and the tokenizer template. Other gen-audio projectors keep the TTS-only result, Qwen3-TTS included. The probe runs against a local HTTP server in the tests. Assisted-by: Claude:claude-haiku-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(llama-cpp): named-voice TTS and the LFM3 ASR prompt Models without a speaker reference (LFM3-Audio) take a named voice through their "tts" chat template instead of a reference file. The request is validated with needs_reference=false, the prompt is rendered with common_chat_get_tts_prompt(), and the voice is set on the gen-audio input. Qwen3-TTS Base keeps the reference-file rule. The branch is guarded by LOCALAI_HAS_TTS_VOICE, so forks without named voices keep the old behaviour. Transcription takes its prompt from common_chat_get_asr_prompt(). LFM3 gets a system turn that names the language and an empty user turn. Qwen3-ASR's preset is unchanged: fixed user text, no system turn, and a caller prompt is still appended after a newline. The preset call is guarded by a new LOCALAI_HAS_ASR_PRESET probe. The pure parts sit in tts_request_options.h and transcription_prompt.h, with standalone tests run by backend/cpp/run-unit-tests.sh. Add the test-extra-backend-llama-cpp-lfm3 target. It runs the tts, ttsstream and transcription specs against LFM3-Audio GGUF weights. It is a manual run and is not wired into CI. Assisted-by: Claude:claude-haiku-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * test(e2e): mock AudioToAudioStream and pending realtime S2S specs The mock backend serves AudioToAudioStream deterministically: session created, commit with RMS, a tool call on the first turn with tools, then transcript pieces and paced 24 kHz tone frames, with response.cancel ending a reply as cancelled. The realtime S2S specs cover the mock and real-weights variants. They skip until the /v1/realtime S2S path lands, so the mock suite stays green in CI. Assisted-by: Claude:claude-haiku-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(llama-cpp): speech-to-speech AudioToAudioStream on the realtime slot Implement AudioToAudioStream on upstream's realtime slot, so a model that answers after the audio (LFM3-Audio) can hold a conversation over the existing duplex RPC. The proto schema does not change: tools travel in the config, tool calls leave as function_call_arguments.done and tool results arrive as a function_call_output item. realtime_session.h keeps what needs no model: the turn text derived from the chat template (with a tool turn), the conversation state, a filter that keeps <tool_call> blocks out of the transcript and drops audio produced inside them, and the translation of slot results into events. grpc-server.cpp wires it to the slot with control tasks and parses calls with the parser the chat template selects. The unit test uses a fake renderer. A ctest-only check renders the real LFM3 template and compares the slot text with the full render. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(gallery): add the LFM3-Audio-2B entries Two llama-cpp entries for LiquidAI/LFM3-Audio-2B-GGUF, the Q4_K_M default (lfm3-audio-2b) and the Q8_0 build (lfm3-audio-2b-q8), both with the Q8_0 audio projector. Each declares pipeline.any_to_any and the realtime_audio, chat, transcript and tts usecases the importer writes for an LFM3 projector, with parallel:2 and the tokenizer template. The Q4 entry lists the Q8 one as a variant. File sizes and sha256 come from the Hugging Face API for the pinned repo revision. Speaker reference files and the VAD model are not part of the entries: VAD stays optional. Assisted-by: Claude:claude-haiku-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * docs: describe LFM3-Audio speech-to-speech and its gallery entries Adds a speech-to-speech section to the Realtime API page (any_to_any configuration, VAD versus manual commit, tools, transcripts, barge-in, limits), a pipeline.any_to_any row, a llama.cpp speech-to-speech row in the compatibility table, and LFM3-Audio mentions on the TTS and ASR pages. The feature is marked experimental: the behaviour follows the backend session contract and has not been run with real weights. Assisted-by: Claude:claude-haiku-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(realtime): run any-to-any models on AudioToAudioStream A realtime_audio model with pipeline.any_to_any now opens one duplex stream to the backend and keeps it for the session, replacing the "any-to-any models not implemented" branch. The chained pipeline is unchanged. The endpoint forwards input audio (with a pre-roll from speech start when a VAD model is set, otherwise every chunk and a client commit), sends response.create, and turns the backend's events into the usual realtime events: audio and transcript deltas, tool calls through the existing function_call items, and a single response.done. A function call output is forwarded before the next response. Barge-in sends response.cancel ahead of the new speech and stops forwarding audio at once. The user's speech is transcribed on the side and reported on the user item; a failure there does not touch the response. Server VAD is on only when pipeline.vad is set. Classifier mode, compaction, streaming.llm, voice gating, sound detection and semantic_vad are rejected for these models. The mock backend now matches the llama.cpp contract (session.updated, the cancel error when idle) and its VAD reports the loud stretches of the audio, so the S2S e2e specs run a VAD turn. The specs are enabled. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * test(e2e): add the real-weights realtime S2S variant and the gRPC s2s spec The realtime S2S specs now check reply audio on real models: duration, loudness, clipping, and keywords found in the model transcript or in a separate ASR of the output audio. run-realtime-lfm3.sh stages the llama-cpp and sherpa-onnx backends, the LFM3-Audio files and the sherpa VAD, ASR and TTS models, then runs the real variant. It is manual and never part of CI: `make test-realtime` still filters out real-models. The backend suite gains an s2s capability (spoken turn, tool call, tool result, spoken answer over AudioToAudioStream) and optional TTS duration and RMS bounds plus a transcript keyword check, all enabled for test-extra-backend-llama-cpp-lfm3. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * test(e2e): expect the idle-cancel error from the mock S2S The mock now answers a response.cancel with no reply running with response_cancel_not_active, as the llama.cpp backend does. The cancel spec still treated that cancel as a no-op and read the error as extra data after the stream ended. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(talk): show any-to-any models as one speech-to-speech model /api/pipeline-models lists a pipeline.any_to_any model with any_to_any set and its optional VAD. A realtime_audio model that is not any-to-any is listed only when it has the four pipeline slots, since the session takes the chained path for it. The Talk page shows a speech-to-speech model as one model: no four-slot view, the VAD slot only when a VAD model is set, and the female and male voices offered. Without a VAD model the server does not detect turns, so the page offers Done speaking, which sends input_audio_buffer.commit and then response.create. Text-only replies stream through response.output_text.delta and .done. self_contained stays in the response for clients built before any_to_any. Assisted-by: Claude:claude-haiku-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(realtime): refuse a llama-cpp realtime model without pipeline.any_to_any llama.cpp has no VAD, transcription or TTS RPCs, so filling the empty pipeline slots with the model name failed later with UNIMPLEMENTED. Fail at session start and name the missing setting instead. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(realtime): hold manual-commit S2S audio until the commit In manual-commit mode the endpoint streamed every appended chunk to the backend, so input_audio_buffer.clear only emptied the Go buffer while the model kept the audio, and idle audio filled its context between turns. Keep the audio in the input buffer and send it, behind pending text and tool-result items, when the client commits or asks for a response. Frames and controls now go through one ordered write queue, so no gRPC send happens under the audio buffer lock. A tool result created while a VAD turn is open is refused with a clear error. When the stream ends outside a response the session reports it and closes, and a bare EOF from Send reports the status that Recv holds. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * test(e2e): drop the S2S readiness gate and stale comments The gate was always true. Some comments referred to work items that readers of the repository cannot see. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * docs(realtime): add the liquid-audio migration note and the clear semantics Say that the Python liquid-audio backend is gone, which gallery entries replace it and that LFM2.5-Audio has no replacement. Describe what input_audio_buffer.clear drops for speech-to-speech sessions now that manual-commit audio is held back until the commit. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(talk): do not promise turn detection when no VAD model is set The idle note said the server notices when you stop talking. A speech-to-speech model without a VAD model needs Done speaking, so the note now says that. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * test(e2e): make the mock S2S backend keep the llama-cpp session limits The mock accepted what the real backend refuses and hid two endpoint bugs. It now treats output_modalities from the config as a fixed session mode and picks the default per response from the tools set at that time. A fixed text plus audio mode with tools reads the tool call out loud. After the first commit or message, session.update of instructions, voice or tools is an error that does not belong to a response, committing an empty buffer is an error, and response.create while a reply runs is refused. Errors of a refused response.create carry response_scoped in their meta. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(realtime): leave the S2S output mode to the backend unless the client sets one The stream config sent text plus audio when the session had no tools yet. The llama-cpp backend keeps a mode from the config as a fixed session mode, and tools added later by session.update never cleared it. The model then read tool calls out loud. Send output_modalities only when the client chose them. The backend picks the default of each response from the tools it has when the response starts. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(llama-cpp): mark the realtime errors that answer a response.create The error event now carries response_scoped: true when it ends the request for a response (a refused response.create, a failed commit made by it, or a stream failure). Other errors, such as a refused session.update or a commit of an empty buffer, are not about a response and one that runs keeps generating. The client needs the difference to know whether a response.done is still coming. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(realtime): end an S2S response only on the errors that belong to it Every backend error ended the response in flight, although the backend also reports errors about other things (a refused session.update, a commit of an empty buffer) and goes on generating. The rest of the reply was lost and the next response.create met either a refusal or the leftover events of the old reply. End the response only on an error marked response_scoped, forward the others to the client and keep waiting for response.done. Drop the events buffered by an earlier response when a new one starts, and skip the commit of a turn that forwarded no audio. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(realtime): run the S2S input transcription detached from the commit slot The commit waited for the side transcription of the user audio while it held the commit slot, and response.create waits for that slot. The ASR latency was added before every reply, and on a backend with few slots a busy ASR task could stall the reply. The model already has the audio, so run the transcription detached under the session context and release the slot at once. The transcript is still reported on the user item. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * test(realtime): do not pin the place of the input transcript in the S2S order The transcript of the user audio is reported on the side and may land before or after the first response events. Check the order of the response events without it. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(realtime): stop an S2S reader leak and a cancel that waits on the write queue The reader waited on a channel it closes itself when the events buffer was full, so it outlived the session after a turn ended on an error or timed out. It now also stops when the session closes. Stopping a response sent the cancel through the write queue and waited for it before the grace timer started. With backpressure on the stream the wait never ended and nothing read the events meanwhile. The timer now starts first and the cancel is only queued. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(realtime): let a chained pipeline run without a VAD model A pipeline that names no pipeline.vad failed to build, because the VAD slot was always loaded, and a new session still started with server_vad. The slot is now optional for chained pipelines as it already is for any-to-any models: the session starts with turn detection off and the client commits each turn. Turning server_vad on for such a session is refused, and a switch to a pipeline without a VAD drops turn detection. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(gallery): add LFM3-Audio VAD and chained-pipeline entries Add lfm3-audio-2b-vad and -q8-vad (any-to-any with silero-vad-ggml as the turn detector), and lfm3-audio-2b-pipeline, -pipeline-vad and the -q8 forms (the model chained through its own transcription, chat and speech slots, with and without the VAD). The gallery has no dependencies between models, so the VAD entries state that silero-vad-ggml must be installed first. Drop the variants list from lfm3-audio-2b: it let the installer pick the larger Q8 build on any host with enough memory, so a plain install of the Q4 entry did not get Q4. All entries are now independent. Tests cover the entry shapes, the single-build install and their acceptance by the realtime endpoint. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * test(e2e): run the realtime specs for any-to-any and chained shapes The realtime specs covered one any-to-any model with a VAD. They now run for any-to-any and for a chained pipeline, each with and without a VAD, on the mock backend in CI. VAD-less shapes also check that turn detection starts off and that server_vad is refused. The manual real-weights script writes one config per shape that mirrors the gallery entries and runs the four shapes in turn (LFM3_MATRIX picks a subset). Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * docs(realtime): document the LFM3-Audio VAD and chained-pipeline entries List the eight LFM3-Audio gallery entries, explain that silero-vad-ggml must be installed before the -vad entries, describe the chained pipeline on one model and the behaviour of a pipeline without a VAD, and describe the shape matrix of the e2e specs. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * test(realtime): wait for the detached input transcription in the S2S specs The input transcription runs in its own goroutine, so the transcription completed and failed events can arrive after the response ends. Poll for them instead of reading the event list right after the response. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(realtime): release the S2S stream before running server-side tool calls A response held the stream slot until it returned, and it ran the tool calls from inside that scope. A server-side tool starts a follow-up response on the same stream, which then waited for the slot its parent still held, so the client never got response.done. Run the tool calls once the slot is free; the event order is unchanged. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(realtime): end an S2S session whose stream dies, and stop queuing after close A stream that died during a response left the session open: later requests failed one by one and VAD frames kept being forwarded. The response now ends the session through the transport, and enqueue drops requests once the session is closed so the write queue cannot grow. The writer is now the only caller of Send and of CloseSend. close() used to call CloseSend while the writer could be inside Send, which gRPC does not allow. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(realtime): close the open S2S turn when the VAD stops Switching turn detection to manual in the middle of a VAD turn left the turn forwarding, and the next client commit sent the whole buffer a second time. Stopping the VAD now commits the forwarded audio on the backend and drops it from the input buffer. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(realtime): keep a tool result pending while an S2S user turn is open The check that refuses a tool result during a user turn ran when the item arrived, but the item was forwarded later, and the result was marked as sent before the backend took it. If the user spoke in between, the backend refused it and it was never retried. The result is now claimed and queued under the audio lock only when no turn is open, and otherwise stays pending for the next commit or response. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(talk): empty the input buffer for models without a VAD Without voice detection the microphone fills the server's input buffer for the whole session, so Done speaking committed idle silence and the echo of the previous reply. Clear the buffer when the session starts and when a reply ends. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(importer): keep an existing parallel option on LFM3-Audio imports The speech-to-speech import added parallel:2 even when the options already carried another parallel value. Use the same check as the hardware defaults, which also covers n_parallel. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(talk): list chained pipelines that have no VAD /api/pipeline-models required a VAD for a chained pipeline, so the VAD-less LFM3-Audio pipeline entries never showed up on the Talk page. Any pipeline with transcription, LLM and speech slots now qualifies. The Talk page treats every model without a VAD as manual-turn, and the session sheet says so for chained pipelines too. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * chore(llama-cpp): bump llama.cpp to 0ac1a7fd Move the llama.cpp pin to 0ac1a7fd35c127a18c0cbc6c57d12e256a6a385b, the master head of 2026-10-29. It contains tool calls in the realtime server (ggml-org/llama.cpp#31287). The score task patch is regenerated so that it applies with no offset and no fuzz. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(functions): keep a null tool argument null A tagged parameter whose text was "null" came out as an empty string: unmarshalling JSON null into a string succeeds and leaves it empty, so the value was taken for a string. Check the first byte of the JSON value instead. A parameter with the text "null" now becomes JSON null, as in llama.cpp. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(functions): add an lfm3 XML format preset The LFM3 chat template writes a call as <tool_call>, <function=NAME>, one <parameter=KEY> block per argument, then the closing tags. The qwen3-coder format has the same shape and auto-detection already found it, but xml_format_preset: lfm3 was not a known name. Add the preset, with tests for one call, a call without arguments, two calls, string and non-string values (numbers, booleans, null, arrays, objects), a call between text, and unfinished input. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(realtime): parse tool calls with the chat template, as upstream Since ggml-org/llama.cpp#31287 the realtime server handles tools with the parser and grammar of the chat template. Do the same in the speech-to-speech stream instead of a hard-coded tag filter and a parse of the whole text at the end. - Each response gets a common_chat_session with the tools of the session and parallel calls. Its grammar and preserved tokens go into the sampling of the response, so the slot keeps the call tokens in the text and constrains the call. - The text of the response is fed to the session piece by piece (task_result_state::update_chat_msg). Content deltas become the transcript; tool-call deltas are collected into one function_call_arguments.done per call at the end. Audio after the start of a call is dropped. - A tool_choice of auto, none or required is accepted in the params of the config, in session.update and in response.create, with the response overriding the session. - The tool turn is derived from a conversation in which the assistant called a tool, like upstream, not from a plain reply. - response.done carries raw_text, everything the model wrote with the call markup, for a caller that parses it another way. If the parser throws, the rest of the response is content and the raw text is the way out. ToolCallFilter is no longer used and goes in the next commit. The unit tests cover the splitter contract (content, call deltas, the final piece, whole characters only). realtime_chat_check feeds LFM3-format text through the session in pieces of 1, 7 and all bytes and checks the call, the transcript and the grammar. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * refactor(realtime): drop the tool-call text filter The parser of the chat template now splits content from tool calls, so ToolCallFilter, which looked for the literal <tool_call> tags, has no caller. Remove it with its tests. Every case it covered (a call between text, split tags, several calls, an unfinished call, text after a call) is handled by the parser, and realtime_chat_check runs the LFM3 format through it in pieces of different sizes. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(realtime): fall back to the raw text for S2S tool calls For an any-to-any model, the calls the backend parsed still win. When there are none and the request had tools, parse the raw text that response.done now carries the way the chained pipeline parses the text of its LLM (CleanupLLMResult, ParseFunctionCall, ParseTextContent), so a call format the backend parser does not know can still be served with function.xml_format_preset or the other function settings of the model. The content around the calls replaces the streamed transcript only if the config captures it, as in the chained path. Also pass tool_choice to the backend: the session mode with the stream config and with session.update, and the mode of a response.create override with that event. A named function cannot be forced, so it is not sent. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * test(e2e): carry raw_text in the mock S2S response.done Match the llama-cpp session: with tools set, response.done has raw_text, the call markup of the LFM3 template for a tool turn and the transcript for any other reply. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(functions): parse tool blocks that have text between them The iterative XML parser stopped at the first scope block that was preceded by text, so "<tool_call>A</tool_call> then <tool_call>B" gave one call. Skip text between blocks once a call was found; text before the first block still ends the parse as before. Blocks that follow each other, or only whitespace, already worked. Tests cover three calls back to back and with text between them, with the lfm3 preset and with auto-detection. They also pin the current reading of argument values: the parser has no tool schema, so a value such as 42 or true is read as JSON even when the schema types it as a string. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(gallery): read LFM3-Audio tool calls with the lfm3 preset Set function.xml_format_preset: lfm3 on the eight LFM3-Audio-2B entries and in the config the importer writes for a speech-to-speech projector, so the server parses the call format of the LFM3 chat template when the backend returns no call (and in the chained pipeline entries, which use the regular chat path). gallery/index.yaml is regenerated from the library. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * docs(realtime): describe how S2S tool calls are read Replace the description of the hard-coded tag filter with the parser and grammar of the chat template, tool_choice, and the raw-text fallback in the server. Document function.xml_format_preset, and set it in the real-weights e2e model configs like the gallery entries do. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(functions): keep earlier calls when a later block does not parse After a valid call, text that holds the opening tag again (a prose mention, a markdown example, a malformed second block) made the parser treat it as a new block, fail, and return no calls at all. Remember the state after each complete block and fall back to it when a later one fails: the calls found so far are kept, parsing stops there and the remaining text stays in the content. Text skipped between two valid blocks now goes to the content instead of being dropped, so StripToolCallMarkup keeps it. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(realtime): do not drop audio after a tool call started In mixed mode the speech for text written before a call can still be pending when the call starts, so dropping every audio frame after the first call delta cut the speech while its transcript was sent. The llama.cpp server never drops audio when it reads a result; do the same. If a model speaks the call markup aloud, that is model behaviour to observe on real weights, not something to filter here. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(realtime): flush held-back text when a response is cancelled The parser got is_partial=true on a cancelled response, so text it held back (a possible start of a tag) never reached the transcript. The llama.cpp server parses a cancelled response with is_partial=false; do the same. A cancelled response still makes no tool call. The path where the parser throws already sends the text as content and needs no change. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * test(realtime): stop the fake S2S stream from sending after Close The barge-in spec failed now and then with a data race and "send on closed channel": its script pushes audio from a goroutine, and the session closes the stream while that goroutine still runs. A push now does nothing once the stream is closed, and Close waits for a push in flight. The production close order is right: the writer closes the stream only after it stops sending. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(realtime): align the S2S tool-call fallback with the backend Four gaps in how the Go side reads the tool calls of an any-to-any reply: - With tool_choice none (the response value wins over the session value) the backend builds no tool parser, yet the raw-text fallback still turned a call the model wrote into a function_call item. Skip it. - Without a capture regex the fallback never cleaned the transcript, so the stored item and transcript.done kept the raw call markup. When the call is XML, use the text left after the markup is cut out; a reply that is only a call now has an empty transcript. - A named function as tool_choice mapped to nothing, so the backend kept the previous mode. Refuse it with an error in session.update and response.create. - A response-level tools list changed what the fallback looked for, but the backend only has the tools of the session. Use those in both. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * docs(realtime): say how S2S tool_choice and response tools behave Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(e2e): use the real llama-cpp backend in the real realtime run The suite always registered the mock backend under the name llama-cpp, so a run with REALTIME_S2S_MODEL set never reached the llama-cpp backend found in REALTIME_BACKENDS_PATH. Register the mock only when that run is off. The real run converts the input audio with ffmpeg. Check for it in the suite and in run-realtime-lfm3.sh before any download or backend start, with a message that says what to install, and list it as a prerequisite in the script header and the Makefile target. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * test(realtime): cover the tools path of a client session.update to the S2S backend A tool call that never came back from an any-to-any model raised the question whether the tools of the session reach the backend at all. Add a spec that sends the session.update of the real-weights e2e (flat Responses API tool, no session type) and checks that the backend gets the tool in the chat-completions form. Log the number of tools sent when the stream opens and when a session.update carries them, so a run log shows it without reading the wire. The "No tools received" line of the llama-cpp backend does not show it: the server prints it for the input transcription request, which has no tools by design. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * test(e2e): interrupt the chained pipeline reply while it is in flight With unary stages, the default of the lfm3 pipeline gallery entries, the chained pipeline synthesizes the whole reply and sends it as one audio delta right before response.done. The barge-in spec waited for that delta and then rendered the interruption with the TTS, so the first response was already done when the speech started and ended completed instead of cancelled. Real runs on a GPU showed it with both quantizations. For a pipeline, start the interruption at response.created, which comes before the LLM and TTS stages. Render the interruption audio before the first utterance is sent, so nothing sits between the reply and the interruption. The any-to-any shape still waits for the first audio delta, which that backend streams while it generates. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * test(e2e): accept a number word and its homophone in the spoken-answer check The check that the reply audio says what the transcript says needs a shared word of 4+ letters. A short answer failed it: the model wrote "Four" and the ASR heard "for". Compare numbers in one spoken form, so digits, number words and their homophones match each other. A homophone only counts when the other text has the number itself, so "for" on both sides still shares nothing and the check does not pass on a stop word. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(llama-cpp): ask LFM3-Audio for function calls when a realtime session has tools The default system prompt of a realtime session was "Respond with interleaved text and audio." whatever the tools. Under that prompt LFM3-Audio answers in words ("I'll check the weather ...") and never writes the call. The model card, and the llama.cpp realtime example client, use "Respond with function calls, and interleaved text and audio." when the session has tools, and the model then calls the tool. Pick the default by the tools of the session, and treat the plain default that the LocalAI server sends back as no choice: it follows the tools too, also when they arrive with a session.update before the first audio. A prompt the client wrote is kept as it is. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(realtime): transcribe the input of an any-to-any turn between responses The input transcript of a speech-to-speech turn ran at the same time as the reply, on the same model. llama.cpp serves both from one context: the realtime slot wants embeddings on, the chat slot of the transcript wants them off, and each flip makes it reserve its compute buffers again. In a GB10 run that was two reserves of about 175 ms per step, the reply fell to 2.6 tokens per second and the transcript to 380 ms per token, until the transcript was done. When pipeline.transcription is the model of the stream, run the transcript after the response, or before one that is not started yet, and keep responses out while it runs. A separate transcription model still runs in parallel. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(realtime): send the input transcript of an any-to-any turn before its reply The previous change moved the same-model transcript after the response. A client that reads until response.done then never saw conversation.item.input_audio_transcription.completed: the transcript was made (the log shows it) but sent after the end of the window. Run it in line with the commit instead. A VAD turn transcribes and then responds. A client response.create already waits for the commit slot, so it starts once the transcript is out. The transcript event now comes before any output of the response of its turn, for a manual commit and for a VAD turn, and never overlaps the response on the llama.cpp context. A transcription model of its own still runs in parallel. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(realtime): transcribe the input of an any-to-any model only when asked The stream answers from the audio, so the transcript of the input is for the client only. On the model of the stream it is costly: llama.cpp serves the transcript request and the realtime stream from one context and rebuilds its compute buffers on every step while both are active. On a GB10 that was 26 to 29 reserves of about 175 ms per turn, against 0 to 1 on the llama.cpp server, and the reply ran at a few tokens per second. An any-to-any model no longer fills pipeline.transcription with its own name. Without it the session does not transcribe the input; with another model it does, in parallel with the reply; with the model itself named it does, before the reply. The reply transcript always comes from the stream. The gallery entries set none, so they get the fast path. The mock configs and run-realtime-lfm3.sh name a transcription model, so the real-weights spec still covers the input transcript. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(realtime): end a response as cancelled when a barge-in lands during the LLM call The chained pipeline cancels the response context on a barge-in. When that happens while the model is generating, the backend call fails with the context error, and the response ended as failed: an error event and no response.done. A client that waits for the terminal of the interrupted response then waits forever. On a GB10 the q4 model answered before the barge-in arrived, so only the slower q8 model showed it: the spec read events for 30 s and timed out. When the context is cancelled, a failed Predict call or a failed result is a cancel, as the TTS step and the streamed LLM path already treat it. The response ends with response.done{cancelled} and no error. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * test(e2e): wait for the input transcript that comes from a model of its own An any-to-any model now gets its input transcript from a separate ASR that runs next to the reply. The reply is often over first, so a spec that stops reading at response.done saw no transcript in the VAD shape. Keep reading, up to 30 s, until the transcript arrives. The contract is that it comes, not when. Add a guard spec for what the input transcription is handed: the whole turn, in a WAV that says the rate it was recorded at (the session rate for a client commit, 16 kHz for a VAD turn). Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * test(e2e): check the errors of Close in the realtime specs golangci-lint (errcheck) flagged the unchecked Close of the websocket connections, the response body and the fake stream. Use the `defer func() { _ = x.Close() }()` form the other e2e specs use. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * test(e2e): write the mock S2S specs with Ginkgo and drop the env read forbidigo only allows Ginkgo/Gomega specs and no os.Getenv outside the sanctioned places. Convert the mock S2S tests to Describe/It with a suite bootstrap (the package had none), with the same 11 cases. The mock no longer reads MOCK_S2S_FRAMES: only these specs set it, so the reply length is a package variable they change per spec and restore afterwards. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
1703 lines
66 KiB
Protocol Buffer
1703 lines
66 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
option go_package = "github.com/go-skynet/LocalAI/pkg/grpc/proto";
|
|
option java_multiple_files = true;
|
|
option java_package = "io.skynet.localai.backend";
|
|
option java_outer_classname = "LocalAIBackend";
|
|
|
|
package backend;
|
|
|
|
service Backend {
|
|
rpc Health(HealthMessage) returns (Reply) {}
|
|
rpc Free(HealthMessage) returns (Result) {}
|
|
rpc Predict(PredictOptions) returns (Reply) {}
|
|
rpc LoadModel(ModelOptions) returns (Result) {}
|
|
rpc PredictStream(PredictOptions) returns (stream Reply) {}
|
|
rpc Embedding(PredictOptions) returns (EmbeddingResult) {}
|
|
rpc GenerateImage(GenerateImageRequest) returns (Result) {}
|
|
rpc UpscaleImage(UpscaleImageRequest) returns (Result) {}
|
|
rpc GenerateVideo(GenerateVideoRequest) returns (Result) {}
|
|
rpc Generate3D(Generate3DRequest) returns (Result) {}
|
|
rpc MotionStream(stream MotionRequest) returns (stream MotionResponse) {}
|
|
rpc Animate3D(Animate3DRequest) returns (Result) {}
|
|
rpc AudioTranscription(TranscriptRequest) returns (TranscriptResult) {}
|
|
rpc AudioTranscriptionStream(TranscriptRequest) returns (stream TranscriptStreamResponse) {}
|
|
// AudioTranscriptionLive is the bidirectional live-microphone ASR RPC. The
|
|
// first message MUST carry a Config; subsequent messages carry Audio frames
|
|
// (mono float PCM at config.sample_rate, 16 kHz default). After a
|
|
// successful open the backend replies with a single ready ack
|
|
// (TranscriptLiveResponse{ready:true}); backends or models without
|
|
// cache-aware streaming support return UNIMPLEMENTED instead. Newly
|
|
// finalized text streams back as deltas; eou=true marks the model's
|
|
// end-of-utterance token. One stream spans many utterances (the decoder
|
|
// resets itself after each EOU). Closing the send side finalizes: the
|
|
// backend flushes the decoder tail and emits a terminal message carrying
|
|
// final_result. A second Config mid-stream resets the decode session.
|
|
rpc AudioTranscriptionLive(stream TranscriptLiveRequest) returns (stream TranscriptLiveResponse) {}
|
|
rpc TTS(TTSRequest) returns (Result) {}
|
|
rpc TTSStream(TTSRequest) returns (stream Reply) {}
|
|
// First frame configures a persistent utterance; later frames carry only text.
|
|
// Half-close commits end of text, while audio continues until EOF.
|
|
rpc TTSLive(stream TTSRequest) returns (stream Reply) {}
|
|
rpc SoundGeneration(SoundGenerationRequest) returns (Result) {}
|
|
rpc TokenizeString(PredictOptions) returns (TokenizationResponse) {}
|
|
rpc Detokenize(DetokenizeRequest) returns (DetokenizeResponse) {}
|
|
rpc Status(HealthMessage) returns (StatusResponse) {}
|
|
rpc Detect(DetectOptions) returns (DetectResponse) {}
|
|
// SoundDetection runs an audio-tagging / sound-event-classification model
|
|
// (e.g. CED over the AudioSet ontology) on a clip and returns scored labels.
|
|
rpc SoundDetection(SoundDetectionRequest) returns (SoundDetectionResponse) {}
|
|
rpc Depth(DepthRequest) returns (DepthResponse) {}
|
|
// Forecast runs a time-series forecasting model (timestral.cpp) on one or more
|
|
// numeric series and returns quantile trajectories for the next steps.
|
|
rpc Forecast(ForecastRequest) returns (ForecastResponse) {}
|
|
rpc FaceVerify(FaceVerifyRequest) returns (FaceVerifyResponse) {}
|
|
rpc FaceAnalyze(FaceAnalyzeRequest) returns (FaceAnalyzeResponse) {}
|
|
rpc VoiceVerify(VoiceVerifyRequest) returns (VoiceVerifyResponse) {}
|
|
rpc VoiceAnalyze(VoiceAnalyzeRequest) returns (VoiceAnalyzeResponse) {}
|
|
rpc VoiceEmbed(VoiceEmbedRequest) returns (VoiceEmbedResponse) {}
|
|
|
|
rpc StoresSet(StoresSetOptions) returns (Result) {}
|
|
rpc StoresDelete(StoresDeleteOptions) returns (Result) {}
|
|
rpc StoresGet(StoresGetOptions) returns (StoresGetResult) {}
|
|
rpc StoresFind(StoresFindOptions) returns (StoresFindResult) {}
|
|
|
|
rpc Rerank(RerankRequest) returns (RerankResult) {}
|
|
|
|
// TokenClassify runs a token-classification (NER) model on the
|
|
// supplied text and returns each detected entity span. Used by the
|
|
// PII redactor's optional NER tier — the regex tier still handles
|
|
// formatted hits cheaply, while this catches names, locations, and
|
|
// other unformatted PII that regex misses.
|
|
rpc TokenClassify(TokenClassifyRequest) returns (TokenClassifyResponse) {}
|
|
|
|
// Score evaluates the model's joint log-probability of each
|
|
// supplied candidate continuation given a shared prompt. The
|
|
// prompt's KV cache is computed once and reused across candidates.
|
|
// Used for routing-policy multi-label classification, reranking,
|
|
// calibrated confidence, and reward-model scoring — any task where
|
|
// the consumer wants the model's confidence in a pre-specified
|
|
// continuation rather than a generated one.
|
|
rpc Score(ScoreRequest) returns (ScoreResponse) {}
|
|
|
|
rpc GetMetrics(MetricsRequest) returns (MetricsResponse);
|
|
|
|
// SlotCache saves or restores the backend's per-slot prompt state (KV or
|
|
// session state). On save the backend issues an ID; on restore the client
|
|
// sends an ID the backend issued. The client never names a file. A backend that does not support it returns gRPC UNIMPLEMENTED.
|
|
rpc SlotCache(SlotCacheRequest) returns (SlotCacheResponse) {}
|
|
|
|
rpc VAD(VADRequest) returns (VADResponse) {}
|
|
|
|
rpc Diarize(DiarizeRequest) returns (DiarizeResponse) {}
|
|
|
|
rpc AudioEncode(AudioEncodeRequest) returns (AudioEncodeResult) {}
|
|
rpc AudioDecode(AudioDecodeRequest) returns (AudioDecodeResult) {}
|
|
|
|
rpc AudioTransform(AudioTransformRequest) returns (AudioTransformResult) {}
|
|
rpc AudioTransformStream(stream AudioTransformFrameRequest) returns (stream AudioTransformFrameResponse) {}
|
|
// AudioToAudioStream is the bidirectional any-to-any S2S RPC. Backends
|
|
// that load a speech-to-speech model consume input audio frames and emit
|
|
// interleaved audio + transcript + tool-call deltas as typed events.
|
|
// Backends without S2S support return UNIMPLEMENTED.
|
|
rpc AudioToAudioStream(stream AudioToAudioRequest) returns (stream AudioToAudioResponse) {}
|
|
|
|
rpc ModelMetadata(ModelOptions) returns (ModelMetadataResponse) {}
|
|
|
|
// Fine-tuning RPCs
|
|
rpc StartFineTune(FineTuneRequest) returns (FineTuneJobResult) {}
|
|
rpc FineTuneProgress(FineTuneProgressRequest) returns (stream FineTuneProgressUpdate) {}
|
|
rpc StopFineTune(FineTuneStopRequest) returns (Result) {}
|
|
rpc ListCheckpoints(ListCheckpointsRequest) returns (ListCheckpointsResponse) {}
|
|
rpc ExportModel(ExportModelRequest) returns (Result) {}
|
|
|
|
// Quantization RPCs
|
|
rpc StartQuantization(QuantizationRequest) returns (QuantizationJobResult) {}
|
|
rpc QuantizationProgress(QuantizationProgressRequest) returns (stream QuantizationProgressUpdate) {}
|
|
rpc StopQuantization(QuantizationStopRequest) returns (Result) {}
|
|
|
|
// Forward proxies a raw HTTP request to an upstream provider. The
|
|
// cloud-proxy backend implements this for passthrough-mode model
|
|
// configs: the client wire format is preserved end-to-end (no
|
|
// translation through internal proto), which means new provider
|
|
// fields work the day they ship. Translation-mode proxies use the
|
|
// standard Predict/PredictStream RPCs instead. Backends that don't
|
|
// support this return UNIMPLEMENTED.
|
|
//
|
|
// The request is bidirectionally streamed so large bodies can flow
|
|
// without buffering. In practice the first ForwardRequest carries
|
|
// path, method, headers, and the initial body chunk; subsequent
|
|
// messages append body chunks. The first ForwardReply carries the
|
|
// upstream status and response headers; subsequent messages stream
|
|
// body chunks (SSE frames or chunked transfer). Cancellation of the
|
|
// gRPC context closes the upstream connection.
|
|
rpc Forward(stream ForwardRequest) returns (stream ForwardReply) {}
|
|
|
|
}
|
|
|
|
// Define the empty request
|
|
message MetricsRequest {}
|
|
|
|
message MetricsResponse {
|
|
int32 slot_id = 1;
|
|
string prompt_json_for_slot = 2; // Stores the prompt as a JSON string.
|
|
float tokens_per_second = 3;
|
|
int32 tokens_generated = 4;
|
|
int32 prompt_tokens_processed = 5;
|
|
}
|
|
|
|
// TokenClassifyRequest carries the text to classify plus an optional
|
|
// score threshold. The transformers backend interprets threshold as
|
|
// the minimum confidence to include in the response; 0 = include all.
|
|
message TokenClassifyRequest {
|
|
string text = 1;
|
|
float threshold = 2;
|
|
// ModelIdentity names the model this request is for; see
|
|
// PredictOptions.ModelIdentity for the full rationale. Empty means "no
|
|
// identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 3;
|
|
// Labels overrides the backend's configured entity labels for this
|
|
// request. Empty means "use the model's configured labels" (the
|
|
// default for PII detection, where labels are fixed at load time).
|
|
// Non-empty enables zero-shot per-request label selection (kev /
|
|
// SystemOne: each question type supplies its own labels).
|
|
repeated string labels = 4;
|
|
}
|
|
|
|
// TokenClassifyEntity is one detected entity span. Byte offsets are
|
|
// into the original UTF-8 text — start..end is a half-open range that
|
|
// addresses the substring corresponding to entity_group.
|
|
//
|
|
// entity_group follows HuggingFace's aggregated-tag convention (e.g.
|
|
// "PER", "LOC", "ORG", or a PII-specific label like "EMAIL" /
|
|
// "SSN" depending on the model). The redactor's per-pattern action
|
|
// map keys off this string.
|
|
message TokenClassifyEntity {
|
|
string entity_group = 1;
|
|
int32 start = 2;
|
|
int32 end = 3;
|
|
float score = 4;
|
|
string text = 5;
|
|
}
|
|
|
|
message TokenClassifyResponse {
|
|
repeated TokenClassifyEntity entities = 1;
|
|
}
|
|
|
|
// ScoreRequest carries one shared prompt and one or more continuations
|
|
// to score against it. The backend tokenises the prompt once and reuses
|
|
// the resulting KV cache across all candidates in this request.
|
|
message ScoreRequest {
|
|
string prompt = 1;
|
|
repeated string candidates = 2;
|
|
// Return per-token logprobs for each candidate when true. Default
|
|
// false to keep the wire response small; the joint log_prob field
|
|
// covers the common ranking case.
|
|
bool include_token_logprobs = 3;
|
|
// When true, the response also populates length_normalized_log_prob
|
|
// (joint log-prob divided by candidate token count). Useful when
|
|
// candidates differ in length and the consumer wants a per-token
|
|
// measure comparable across them (PMI-style scoring).
|
|
bool length_normalize = 4;
|
|
// ModelIdentity names the model this request is for; see
|
|
// PredictOptions.ModelIdentity for the full rationale. Empty means "no
|
|
// identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 5;
|
|
// Byte length of the prompt prefix that stays identical across
|
|
// repeated scoring calls (e.g. a classifier's option-list system
|
|
// prompt — everything before the per-turn probe text). Backends that
|
|
// snapshot state (hybrid/recurrent models cannot rewind otherwise)
|
|
// use it to place a reuse point exactly at the boundary, so the next
|
|
// call re-processes only the tokens after it. 0 means unknown.
|
|
int32 stable_prefix_len = 6;
|
|
// question_type signals a decision-pipeline request (kev/laya)
|
|
// rather than plain candidate scoring. When set to "systemone", the
|
|
// backend treats prompt as the raw /v1/systemone request JSON and
|
|
// returns the full response in ScoreResponse.response_json. Empty
|
|
// means plain candidate scoring.
|
|
string question_type = 7;
|
|
}
|
|
|
|
// CandidateScore is one row in the ScoreResponse, matching by index
|
|
// the candidate in ScoreRequest.candidates.
|
|
message CandidateScore {
|
|
// Sum of log P(token_i | prompt, candidate_token_<i) across the
|
|
// candidate's tokens. The primary ranking signal.
|
|
double log_prob = 1;
|
|
// log_prob / num_tokens — populated when length_normalize=true on
|
|
// the request.
|
|
double length_normalized_log_prob = 2;
|
|
// Per-token detail — populated when include_token_logprobs=true.
|
|
repeated TokenLogProb tokens = 3;
|
|
// Number of tokens the backend tokenised this candidate into, after
|
|
// any backend-specific normalisation (e.g. leading-space handling).
|
|
int32 num_tokens = 4;
|
|
}
|
|
|
|
message TokenLogProb {
|
|
string token = 1;
|
|
double log_prob = 2;
|
|
}
|
|
|
|
message ScoreResponse {
|
|
repeated CandidateScore candidates = 1;
|
|
// response_json carries the full decision-pipeline JSON response when
|
|
// question_type is set on the request. Empty for plain scoring.
|
|
string response_json = 2;
|
|
}
|
|
|
|
message RerankRequest {
|
|
string query = 1;
|
|
repeated string documents = 2;
|
|
int32 top_n = 3;
|
|
// ModelIdentity names the model this request is for; see
|
|
// PredictOptions.ModelIdentity for the full rationale. Empty means "no
|
|
// identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 4;
|
|
}
|
|
|
|
message RerankResult {
|
|
Usage usage = 1;
|
|
repeated DocumentResult results = 2;
|
|
}
|
|
|
|
message Usage {
|
|
int32 total_tokens = 1;
|
|
int32 prompt_tokens = 2;
|
|
}
|
|
|
|
message DocumentResult {
|
|
int32 index = 1;
|
|
string text = 2;
|
|
float relevance_score = 3;
|
|
}
|
|
|
|
message StoresKey {
|
|
repeated float Floats = 1;
|
|
}
|
|
|
|
message StoresValue {
|
|
bytes Bytes = 1;
|
|
}
|
|
|
|
message StoresSetOptions {
|
|
repeated StoresKey Keys = 1;
|
|
repeated StoresValue Values = 2;
|
|
}
|
|
|
|
message StoresDeleteOptions {
|
|
repeated StoresKey Keys = 1;
|
|
}
|
|
|
|
message StoresGetOptions {
|
|
repeated StoresKey Keys = 1;
|
|
}
|
|
|
|
message StoresGetResult {
|
|
repeated StoresKey Keys = 1;
|
|
repeated StoresValue Values = 2;
|
|
}
|
|
|
|
message StoresFindOptions {
|
|
StoresKey Key = 1;
|
|
int32 TopK = 2;
|
|
}
|
|
|
|
message StoresFindResult {
|
|
repeated StoresKey Keys = 1;
|
|
repeated StoresValue Values = 2;
|
|
repeated float Similarities = 3;
|
|
}
|
|
|
|
message HealthMessage {}
|
|
|
|
// The request message containing the user's name.
|
|
message PredictOptions {
|
|
string Prompt = 1;
|
|
int32 Seed = 2;
|
|
int32 Threads = 3;
|
|
int32 Tokens = 4;
|
|
int32 TopK = 5;
|
|
int32 Repeat = 6;
|
|
int32 Batch = 7;
|
|
int32 NKeep = 8;
|
|
float Temperature = 9;
|
|
float Penalty = 10;
|
|
bool F16KV = 11;
|
|
bool DebugMode = 12;
|
|
repeated string StopPrompts = 13;
|
|
bool IgnoreEOS = 14;
|
|
float TailFreeSamplingZ = 15;
|
|
float TypicalP = 16;
|
|
float FrequencyPenalty = 17;
|
|
float PresencePenalty = 18;
|
|
int32 Mirostat = 19;
|
|
float MirostatETA = 20;
|
|
float MirostatTAU = 21;
|
|
bool PenalizeNL = 22;
|
|
string LogitBias = 23;
|
|
bool MLock = 25;
|
|
bool MMap = 26;
|
|
bool PromptCacheAll = 27;
|
|
bool PromptCacheRO = 28;
|
|
string Grammar = 29;
|
|
string MainGPU = 30;
|
|
string TensorSplit = 31;
|
|
float TopP = 32;
|
|
string PromptCachePath = 33;
|
|
bool Debug = 34;
|
|
repeated int32 EmbeddingTokens = 35;
|
|
string Embeddings = 36;
|
|
float RopeFreqBase = 37;
|
|
float RopeFreqScale = 38;
|
|
float NegativePromptScale = 39;
|
|
string NegativePrompt = 40;
|
|
int32 NDraft = 41;
|
|
repeated string Images = 42;
|
|
bool UseTokenizerTemplate = 43;
|
|
repeated Message Messages = 44;
|
|
repeated string Videos = 45;
|
|
repeated string Audios = 46;
|
|
string CorrelationId = 47;
|
|
string Tools = 48; // JSON array of available tools/functions for tool calling
|
|
string ToolChoice = 49; // JSON string or object specifying tool choice behavior
|
|
int32 Logprobs = 50; // Number of top logprobs to return (maps to OpenAI logprobs parameter)
|
|
int32 TopLogprobs = 51; // Number of top logprobs to return per token (maps to OpenAI top_logprobs parameter)
|
|
map<string, string> Metadata = 52; // Generic per-request metadata (e.g., enable_thinking)
|
|
float MinP = 53; // Minimum probability sampling threshold (0.0 = disabled)
|
|
|
|
// ModelIdentity names the model this request is for, so a backend can reject
|
|
// a request that reached it by mistake instead of answering from whatever
|
|
// model it happens to hold. In distributed mode a worker can recycle a
|
|
// stopped backend's gRPC port for a different model's backend, and a
|
|
// liveness-only health probe cannot tell that apart from a valid cached
|
|
// route (#10952).
|
|
//
|
|
// The value is the controller's ModelConfig.Model, the SAME expression that
|
|
// produces ModelOptions.Model at LoadModel time, so the two are equal by
|
|
// construction rather than by convention.
|
|
//
|
|
// Empty means "no identity supplied": backends MUST skip the check. That
|
|
// keeps an old controller talking to a new backend working, and covers
|
|
// callers that legitimately synthesize a PredictOptions internally.
|
|
//
|
|
// Do NOT reuse TTSRequest.model or SoundGenerationRequest.model for this
|
|
// purpose. FileStagingClient already rewrites those to worker-local absolute
|
|
// paths (core/services/nodes/file_staging_client.go), so in distributed mode
|
|
// they already differ from the load-time value and comparing them would
|
|
// reject valid requests. Extending identity to those RPCs needs a separate
|
|
// field carrying the untranslated value - which is exactly what
|
|
// TTSRequest.ModelIdentity and SoundGenerationRequest.ModelIdentity are.
|
|
//
|
|
// Every other request message that reaches a backend through the distributed
|
|
// router now carries the same ModelIdentity field, populated from the same
|
|
// ModelConfig.Model. FileStagingClient rewrites Src/Dst/Voice/Model/
|
|
// StartImage/EndImage/Audio and never ModelIdentity, so what the backend
|
|
// compares is always what the controller sent.
|
|
string ModelIdentity = 54;
|
|
|
|
// 24 was never assigned; reserve it so it is not silently reused.
|
|
reserved 24;
|
|
}
|
|
|
|
// ToolCallDelta represents an incremental tool call update from the C++ parser.
|
|
// Used for both streaming (partial diffs) and non-streaming (final tool calls).
|
|
message ToolCallDelta {
|
|
int32 index = 1; // tool call index (0-based)
|
|
string id = 2; // tool call ID (e.g., "call_abc123")
|
|
string name = 3; // function name (set on first appearance)
|
|
string arguments = 4; // arguments chunk (incremental in streaming, full in non-streaming)
|
|
}
|
|
|
|
// ChatDelta represents incremental content/reasoning/tool_call updates parsed by the C++ backend.
|
|
message ChatDelta {
|
|
string content = 1; // content text delta
|
|
string reasoning_content = 2; // reasoning/thinking text delta
|
|
repeated ToolCallDelta tool_calls = 3; // tool call deltas
|
|
}
|
|
|
|
// The response message containing the result
|
|
message Reply {
|
|
bytes message = 1;
|
|
int32 tokens = 2;
|
|
int32 prompt_tokens = 3;
|
|
double timing_prompt_processing = 4;
|
|
double timing_token_generation = 5;
|
|
bytes audio = 6;
|
|
bytes logprobs = 7; // JSON-encoded logprobs data matching OpenAI format
|
|
repeated ChatDelta chat_deltas = 8; // Parsed chat deltas from C++ autoparser (streaming + non-streaming)
|
|
}
|
|
|
|
message GrammarTrigger {
|
|
string word = 1;
|
|
}
|
|
|
|
message ModelOptions {
|
|
string Model = 1;
|
|
int32 ContextSize = 2;
|
|
int32 Seed = 3;
|
|
int32 NBatch = 4;
|
|
bool F16Memory = 5;
|
|
bool MLock = 6;
|
|
bool MMap = 7;
|
|
bool VocabOnly = 8;
|
|
bool LowVRAM = 9;
|
|
bool Embeddings = 10;
|
|
bool NUMA = 11;
|
|
int32 NGPULayers = 12;
|
|
string MainGPU = 13;
|
|
string TensorSplit = 14;
|
|
int32 Threads = 15;
|
|
float RopeFreqBase = 17;
|
|
float RopeFreqScale = 18;
|
|
float RMSNormEps = 19;
|
|
int32 NGQA = 20;
|
|
string ModelFile = 21;
|
|
|
|
|
|
|
|
// Diffusers
|
|
string PipelineType = 26;
|
|
string SchedulerType = 27;
|
|
bool CUDA = 28;
|
|
float CFGScale = 29;
|
|
bool IMG2IMG = 30;
|
|
string CLIPModel = 31;
|
|
string CLIPSubfolder = 32;
|
|
int32 CLIPSkip = 33;
|
|
string ControlNet = 48;
|
|
|
|
string Tokenizer = 34;
|
|
|
|
// LLM (llama.cpp)
|
|
string LoraBase = 35;
|
|
string LoraAdapter = 36;
|
|
float LoraScale = 42;
|
|
|
|
bool NoMulMatQ = 37;
|
|
string DraftModel = 39;
|
|
|
|
string AudioPath = 38;
|
|
|
|
// vllm
|
|
string Quantization = 40;
|
|
float GPUMemoryUtilization = 50;
|
|
bool TrustRemoteCode = 51;
|
|
bool EnforceEager = 52;
|
|
int32 SwapSpace = 53;
|
|
int32 MaxModelLen = 54;
|
|
int32 TensorParallelSize = 55;
|
|
string LoadFormat = 58;
|
|
bool DisableLogStatus = 66;
|
|
string DType = 67;
|
|
int32 LimitImagePerPrompt = 68;
|
|
int32 LimitVideoPerPrompt = 69;
|
|
int32 LimitAudioPerPrompt = 70;
|
|
|
|
string MMProj = 41;
|
|
|
|
string RopeScaling = 43;
|
|
float YarnExtFactor = 44;
|
|
float YarnAttnFactor = 45;
|
|
float YarnBetaFast = 46;
|
|
float YarnBetaSlow = 47;
|
|
|
|
string Type = 49;
|
|
|
|
string FlashAttention = 56;
|
|
bool NoKVOffload = 57;
|
|
|
|
string ModelPath = 59;
|
|
|
|
repeated string LoraAdapters = 60;
|
|
repeated float LoraScales = 61;
|
|
|
|
repeated string Options = 62;
|
|
|
|
string CacheTypeKey = 63;
|
|
string CacheTypeValue = 64;
|
|
|
|
repeated GrammarTrigger GrammarTriggers = 65;
|
|
|
|
bool Reranking = 71;
|
|
|
|
repeated string Overrides = 72;
|
|
|
|
// EngineArgs carries a JSON-encoded map of backend-native engine arguments
|
|
// applied verbatim to the backend's engine constructor (e.g. vLLM AsyncEngineArgs).
|
|
// Unknown keys produce an error at LoadModel time.
|
|
string EngineArgs = 73;
|
|
string OriginalConfigFile = 77;
|
|
|
|
// EnvVars carries environment variables to be passed to the backend process.
|
|
map<string, string> EnvVars = 76;
|
|
|
|
// Proxy carries the cloud-proxy backend's per-model configuration.
|
|
// Empty for non-proxy backends.
|
|
ProxyOptions Proxy = 74;
|
|
|
|
// EnableScore reserves backend resources for the Score RPC. It is derived
|
|
// from the model's explicit `known_usecases: [score]` declaration so models
|
|
// that never score retain their ordinary serving footprint.
|
|
bool EnableScore = 75;
|
|
}
|
|
|
|
// ProxyOptions configures the cloud-proxy backend. UpstreamURL and
|
|
// Mode are always meaningful; Provider only matters in translate mode.
|
|
// The api_key, api_key_env and api_key_file fields are mutually exclusive
|
|
// and resolved by the backend at LoadModel. api_key is plaintext admin config.
|
|
message ProxyOptions {
|
|
string upstream_url = 1;
|
|
string mode = 2;
|
|
string provider = 3;
|
|
string api_key_env = 4;
|
|
string api_key_file = 5;
|
|
string upstream_model = 6;
|
|
int32 request_timeout_seconds = 7;
|
|
// cache_prompt enables automatic Anthropic prompt-cache breakpoints
|
|
// (cache_control: ephemeral) on the stable prefix — system, tools, and
|
|
// the last message block — when translating to the Anthropic provider.
|
|
// Cuts input cost on repeated/agentic calls (cache read = 0.1x). Only
|
|
// meaningful for mode=translate + provider=anthropic; ignored otherwise.
|
|
bool cache_prompt = 8;
|
|
string api_key = 9;
|
|
}
|
|
|
|
message Result {
|
|
string message = 1;
|
|
bool success = 2;
|
|
// JSON object containing arbitrary backend response metadata. Application
|
|
// conventions (such as metadata.usage) are independent of this schema.
|
|
bytes metadata = 4;
|
|
}
|
|
|
|
// EmbeddingLayout describes whether embeddings contains one final vector or
|
|
// a matrix of per-token vectors. Go-side pooling must never infer this from
|
|
// tokens/dim alone: a one-token raw matrix and a final vector have the same
|
|
// shape.
|
|
enum EmbeddingLayout {
|
|
EMBEDDING_LAYOUT_UNSPECIFIED = 0;
|
|
EMBEDDING_LAYOUT_FINAL = 1;
|
|
EMBEDDING_LAYOUT_PER_TOKEN = 2;
|
|
}
|
|
|
|
message EmbeddingResult {
|
|
repeated float embeddings = 1;
|
|
// Shape of the payload above: dim is the embedding width, tokens is the
|
|
// number of vectors packed into `embeddings` (1 when the backend pooled
|
|
// server-side, N with pooling:none; total across prompts if a request
|
|
// carried several). tokens=0/dim=0 means the backend predates shape
|
|
// reporting. prompt_tokens is the number of prompt tokens evaluated, for
|
|
// usage accounting.
|
|
int32 tokens = 2;
|
|
int32 dim = 3;
|
|
int32 prompt_tokens = 4;
|
|
EmbeddingLayout layout = 5;
|
|
}
|
|
|
|
message TranscriptRequest {
|
|
string dst = 2;
|
|
string language = 3;
|
|
uint32 threads = 4;
|
|
bool translate = 5;
|
|
bool diarize = 6;
|
|
string prompt = 7;
|
|
float temperature = 8;
|
|
repeated string timestamp_granularities = 9;
|
|
bool stream = 10;
|
|
// ModelIdentity names the model this request is for; see
|
|
// PredictOptions.ModelIdentity for the full rationale. Empty means "no
|
|
// identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 11;
|
|
}
|
|
|
|
message TranscriptResult {
|
|
repeated TranscriptSegment segments = 1;
|
|
string text = 2;
|
|
string language = 3;
|
|
float duration = 4;
|
|
// True when the decode ended on the model's end-of-utterance special token
|
|
// (<EOU>/<EOB>, emitted by cache-aware streaming models such as
|
|
// parakeet_realtime_eou_120m-v1). The marker itself is stripped from text.
|
|
bool eou = 5;
|
|
}
|
|
|
|
message TranscriptStreamResponse {
|
|
string delta = 1;
|
|
TranscriptResult final_result = 2;
|
|
}
|
|
|
|
// === AudioTranscriptionLive messages =====================================
|
|
|
|
message TranscriptLiveRequest {
|
|
oneof payload {
|
|
TranscriptLiveConfig config = 1;
|
|
TranscriptLiveAudio audio = 2;
|
|
}
|
|
}
|
|
|
|
message TranscriptLiveConfig {
|
|
string language = 1; // "" => model default
|
|
int32 sample_rate = 2; // 0 => 16000; backends may reject others
|
|
map<string, string> params = 3; // backend-specific tuning
|
|
repeated KnownVoice known_voices = 4; // see DiarizeRequest.known_voices
|
|
}
|
|
|
|
message TranscriptLiveAudio {
|
|
repeated float pcm = 1; // mono PCM in [-1,1] at config.sample_rate
|
|
}
|
|
|
|
message TranscriptLiveResponse {
|
|
bool ready = 1; // open ack: sent once, before any delta
|
|
string delta = 2; // newly-finalized text since previous response
|
|
bool eou = 3; // <EOU> fired during this feed (the user yielded the turn)
|
|
repeated TranscriptWord words = 4; // words finalized by this feed (stream-relative ns)
|
|
TranscriptResult final_result = 5; // terminal message only, after the send side closes
|
|
bool eob = 6; // <EOB> fired: a backchannel ("uh-huh") ended — NOT a turn boundary
|
|
repeated LiveSpeakerSegment speakers = 7; // closed speaker segments from a companion diarization/scene stream
|
|
repeated LiveSoundEvent sounds = 8; // closed sound events from a companion sound/scene stream
|
|
}
|
|
|
|
message LiveSpeakerSegment {
|
|
string speaker = 1; // decimal speaker index
|
|
int64 start = 2; // stream-relative nanoseconds
|
|
int64 end = 3;
|
|
string name = 4; // registered speaker name when the backend identified the speaker, else empty
|
|
}
|
|
|
|
message LiveSoundEvent {
|
|
string label = 1;
|
|
int32 index = 2;
|
|
float peak = 3;
|
|
int64 start = 4; // stream-relative nanoseconds
|
|
int64 end = 5;
|
|
}
|
|
|
|
message TranscriptWord {
|
|
int64 start = 1;
|
|
int64 end = 2;
|
|
string text = 3;
|
|
string speaker = 4; // backend speaker label when diarizing; empty otherwise
|
|
}
|
|
|
|
message TranscriptSegment {
|
|
int32 id = 1;
|
|
int64 start = 2;
|
|
int64 end = 3;
|
|
string text = 4;
|
|
repeated int32 tokens = 5;
|
|
string speaker = 6;
|
|
repeated TranscriptWord words = 7;
|
|
}
|
|
|
|
message GenerateImageRequest {
|
|
int32 height = 1;
|
|
int32 width = 2;
|
|
int32 step = 4;
|
|
int32 seed = 5;
|
|
string positive_prompt = 6;
|
|
string negative_prompt = 7;
|
|
string dst = 8;
|
|
string src = 9;
|
|
|
|
// Diffusers
|
|
string EnableParameters = 10;
|
|
int32 CLIPSkip = 11;
|
|
|
|
// Reference images for models that support them (e.g., Flux Kontext)
|
|
repeated string ref_images = 12;
|
|
// ModelIdentity names the model this request is for; see
|
|
// PredictOptions.ModelIdentity for the full rationale. Empty means "no
|
|
// identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 13;
|
|
}
|
|
|
|
message UpscaleImageRequest {
|
|
string src = 1; // input image path
|
|
string dst = 2; // output image path
|
|
int32 scale = 3; // upscale factor (e.g. 2 or 4)
|
|
}
|
|
|
|
message GenerateVideoRequest {
|
|
string prompt = 1;
|
|
string negative_prompt = 2; // Negative prompt for video generation
|
|
string start_image = 3; // Path or base64 encoded image for the start frame
|
|
string end_image = 4; // Path or base64 encoded image for the end frame
|
|
int32 width = 5;
|
|
int32 height = 6;
|
|
int32 num_frames = 7; // Number of frames to generate
|
|
int32 fps = 8; // Frames per second
|
|
int32 seed = 9;
|
|
float cfg_scale = 10; // Classifier-free guidance scale
|
|
int32 step = 11; // Number of inference steps
|
|
string dst = 12; // Output path for the generated video
|
|
string audio = 13; // Path to staged audio for audio-conditioned video
|
|
// Backend-specific per-request generation parameters. Values are strings
|
|
// and are validated/coerced by the selected backend.
|
|
map<string, string> params = 14;
|
|
// ModelIdentity names the model this request is for; see
|
|
// PredictOptions.ModelIdentity for the full rationale. Empty means "no
|
|
// identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 15;
|
|
// Reference conditioning (MiniMax-H3 Ref2VA). Additive: `audio` and
|
|
// params["ref_image"] keep working and count as one more reference each.
|
|
// Keyframes (start_image/end_image) and references are mutually exclusive.
|
|
repeated string ref_images = 16; // Staged paths of reference images
|
|
repeated VideoReference ref_videos = 17; // Reference videos given as frame directories
|
|
repeated string ref_audios = 18; // Staged paths of reference audio clips (WAV)
|
|
}
|
|
|
|
// VideoReference is one reference video for GenerateVideoRequest.
|
|
message VideoReference {
|
|
string frames_dir = 1; // Staged directory of frame images, read in lexicographic file-name order
|
|
int32 fps = 2; // Frame rate of the source frames; 0 means the backend default
|
|
string audio = 3; // Optional staged WAV path paired with this video
|
|
}
|
|
|
|
// A named conditioning input. Media references are staged local paths by the
|
|
// time they reach the backend; text is passed verbatim.
|
|
message AnimationInput {
|
|
string type = 1; // text, image, video, or mesh
|
|
string data = 2;
|
|
}
|
|
|
|
message Animate3DRequest {
|
|
map<string, AnimationInput> inputs = 1;
|
|
string dst = 2;
|
|
map<string, string> params = 3;
|
|
string model_identity = 4;
|
|
}
|
|
|
|
message Generate3DRequest {
|
|
string src = 1; // Path to the staged conditioning image (3D generation is image-conditioned)
|
|
string dst = 2; // Output path for the generated binary glTF (.glb) asset
|
|
int32 seed = 3; // <=0 lets the backend pick a random seed
|
|
int32 step = 4; // Flow sampling steps; <=0 uses the backend default
|
|
float cfg_scale = 5; // Classifier-free guidance scale; <=0 uses the backend default
|
|
int32 texture_steps = 6; // Texture flow sampling steps; <=0 uses the backend default
|
|
string quality = 7; // Mesh pipeline: ""|"auto"|"coarse"|"512"|"1024"
|
|
string background = 8; // Conditioning-image background handling: ""|"auto"|"keep"|"black"|"white"
|
|
// Backend-specific per-request generation parameters. Values are strings
|
|
// and are validated/coerced by the selected backend.
|
|
map<string, string> params = 9;
|
|
}
|
|
|
|
message TTSRequest {
|
|
string text = 1;
|
|
string model = 2;
|
|
string dst = 3;
|
|
string voice = 4;
|
|
optional string language = 5;
|
|
// instructions is a free-form, per-request style/voice description (maps to
|
|
// the OpenAI `instructions` field). Backends that support expressive synthesis
|
|
// (e.g. Qwen3-TTS CustomVoice/VoiceDesign) prefer this over the static YAML
|
|
// option when set; backends that don't simply ignore it.
|
|
optional string instructions = 6;
|
|
// params carries optional, backend-specific per-request generation parameters
|
|
// (e.g. Chatterbox exaggeration/cfg_weight/temperature). Values are strings and
|
|
// coerced by the backend; unset leaves the backend's configured defaults.
|
|
map<string, string> params = 7;
|
|
// ModelIdentity is a SEPARATE field from `model` above and carries the
|
|
// UNTRANSLATED controller-side ModelConfig.Model, so a backend can reject a
|
|
// request that reached it through a stale distributed route (#10952).
|
|
//
|
|
// `model` cannot be reused for this: FileStagingClient.TTS/.TTSStream and the
|
|
// SoundGeneration path rewrite it into a worker-local absolute path
|
|
// (core/services/nodes/file_staging_client.go), while the load-time value is
|
|
// untranslated. In distributed mode - exactly the configuration this guards -
|
|
// the two already differ, so comparing them would reject valid requests.
|
|
//
|
|
// Empty means "no identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 8;
|
|
}
|
|
|
|
message VADRequest {
|
|
repeated float audio = 1;
|
|
// ModelIdentity names the model this request is for; see
|
|
// PredictOptions.ModelIdentity for the full rationale. Empty means "no
|
|
// identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 2;
|
|
}
|
|
|
|
message VADSegment {
|
|
float start = 1;
|
|
float end = 2;
|
|
}
|
|
|
|
message VADResponse {
|
|
repeated VADSegment segments = 1;
|
|
}
|
|
|
|
// --- Speaker diarization messages ---
|
|
//
|
|
// Pure speaker diarization: "who spoke when". Returns time-stamped segments
|
|
// labelled with cluster IDs (the same string for the same speaker across
|
|
// segments). Some backends (e.g. vibevoice.cpp) produce diarization as a
|
|
// by-product of ASR and may also fill in `text` per segment; backends with a
|
|
// dedicated diarization pipeline (e.g. sherpa-onnx pyannote) leave `text`
|
|
// empty and emit only the segmentation.
|
|
|
|
message DiarizeRequest {
|
|
string dst = 1; // path to audio file (HTTP layer materialises uploads to a temp file)
|
|
uint32 threads = 2;
|
|
string language = 3; // optional; only meaningful for transcription-bundling backends
|
|
int32 num_speakers = 4; // exact speaker count if known (>0 forces); 0 = auto
|
|
int32 min_speakers = 5; // hint when auto-detecting; 0 = unset
|
|
int32 max_speakers = 6; // hint when auto-detecting; 0 = unset
|
|
float clustering_threshold = 7; // distance threshold when num_speakers unknown; 0 = backend default
|
|
float min_duration_on = 8; // discard segments shorter than this (seconds); 0 = backend default
|
|
float min_duration_off = 9; // merge gaps shorter than this (seconds); 0 = backend default
|
|
bool include_text = 10; // when the backend can emit per-segment transcript for free, ask it to populate `text`
|
|
// ModelIdentity names the model this request is for; see
|
|
// PredictOptions.ModelIdentity for the full rationale. Empty means "no
|
|
// identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 11;
|
|
// Registered voices the backend may use to name speakers. Only backends that
|
|
// identify speakers themselves read this; others ignore it.
|
|
repeated KnownVoice known_voices = 12;
|
|
bool include_speaker_profiles = 13; // opt-in sensitive embeddings; unsupported backends must reject
|
|
bool include_sounds = 14; // ask for closed sound events; backends without a sound model must reject, never return an empty list
|
|
}
|
|
|
|
message DiarizeSegment {
|
|
int32 id = 1;
|
|
float start = 2; // seconds
|
|
float end = 3; // seconds
|
|
string speaker = 4; // backend-emitted speaker label (e.g. "0", "SPEAKER_00")
|
|
string text = 5; // optional per-segment transcript (empty unless include_text and supported)
|
|
string name = 6; // registered speaker name, empty when unknown or not identified
|
|
float name_score = 7; // match score of that name (cosine similarity), 0 when unnamed
|
|
}
|
|
|
|
// KnownVoice is one registered voice: a name and its speaker embedding. `model`
|
|
// names the encoder that produced it, so a backend with a different encoder can
|
|
// refuse vectors that are not comparable.
|
|
message KnownVoice {
|
|
string id = 4; // registration ID; native keys must not aggregate duplicate display names
|
|
string name = 1;
|
|
repeated float embedding = 2;
|
|
string model = 3;
|
|
// Fingerprint of the encoder that made the embedding, when it is known: the
|
|
// embedding space ("voicedetect:<arch>:<name>:<dim>") and the exact weights
|
|
// ("sha256:<hex>"). Empty for voices registered before it was recorded.
|
|
string encoder_family = 5;
|
|
string encoder_weights = 6;
|
|
}
|
|
|
|
// DiarizeSound is one closed sound event over the whole clip, merged the same
|
|
// way the live scene stream merges them.
|
|
message DiarizeSound {
|
|
float start = 1; // seconds
|
|
float end = 2; // seconds
|
|
string label = 3; // AudioSet label
|
|
float confidence = 4; // peak score of the event, 0..1
|
|
}
|
|
|
|
message DiarizeResponse {
|
|
string speaker_profiles_json = 5; // versioned speaker_profiles object only; absent by default
|
|
repeated DiarizeSound sounds = 6; // closed sound events; only filled when include_sounds was set
|
|
bool sounds_included = 7; // true when the backend ran sound detection for this request (an empty `sounds` is then a real "nothing heard")
|
|
repeated DiarizeSegment segments = 1;
|
|
int32 num_speakers = 2; // count of distinct speaker labels in `segments`
|
|
float duration = 3; // total audio duration in seconds (0 if unknown)
|
|
string language = 4; // optional, when the backend bundles transcription
|
|
}
|
|
|
|
message SoundGenerationRequest {
|
|
string text = 1;
|
|
string model = 2;
|
|
string dst = 3;
|
|
optional float duration = 4;
|
|
optional float temperature = 5;
|
|
optional bool sample = 6;
|
|
optional string src = 7;
|
|
optional int32 src_divisor = 8;
|
|
optional bool think = 9;
|
|
optional string caption = 10;
|
|
optional string lyrics = 11;
|
|
optional int32 bpm = 12;
|
|
optional string keyscale = 13;
|
|
optional string language = 14;
|
|
optional string timesignature = 15;
|
|
optional bool instrumental = 17;
|
|
// ModelIdentity is a SEPARATE field from `model` above and carries the
|
|
// UNTRANSLATED controller-side ModelConfig.Model, so a backend can reject a
|
|
// request that reached it through a stale distributed route (#10952).
|
|
//
|
|
// `model` cannot be reused for this: FileStagingClient.TTS/.TTSStream and the
|
|
// SoundGeneration path rewrite it into a worker-local absolute path
|
|
// (core/services/nodes/file_staging_client.go), while the load-time value is
|
|
// untranslated. In distributed mode - exactly the configuration this guards -
|
|
// the two already differ, so comparing them would reject valid requests.
|
|
//
|
|
// Empty means "no identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 18;
|
|
map<string, string> params = 19;
|
|
optional bool expanded = 20;
|
|
}
|
|
|
|
message TokenizationResponse {
|
|
int32 length = 1;
|
|
repeated int32 tokens = 2;
|
|
}
|
|
|
|
enum SlotCacheAction {
|
|
SLOT_CACHE_ACTION_UNSPECIFIED = 0;
|
|
SLOT_CACHE_ACTION_SAVE = 1;
|
|
SLOT_CACHE_ACTION_RESTORE = 2;
|
|
}
|
|
|
|
message SlotCacheRequest {
|
|
// Ties a save file to the model it came from. Empty means the backend does
|
|
// not check it.
|
|
string model_identity = 1;
|
|
SlotCacheAction action = 2;
|
|
// The backend's state slot id, 0 is the first slot. For llama.cpp it is the
|
|
// server slot. Other backends may map it to a session id.
|
|
int32 slot = 3;
|
|
// Save: leave empty, the backend issues the ID. Restore: an ID that the
|
|
// backend issued for this model. The client never chooses a file name or a
|
|
// path; the backend must refuse any ID it did not issue for this model.
|
|
string id = 4;
|
|
}
|
|
|
|
message SlotCacheResponse {
|
|
bool success = 1;
|
|
string message = 2; // error detail when success is false
|
|
int32 slot = 3;
|
|
string id = 4; // save: the ID the backend issued. restore: the ID restored
|
|
uint64 n_tokens = 5; // tokens saved or restored
|
|
uint64 n_bytes = 6; // bytes written or read
|
|
double duration_ms = 7;
|
|
}
|
|
|
|
message DetokenizeRequest {
|
|
repeated int32 tokens = 1;
|
|
}
|
|
|
|
message DetokenizeResponse {
|
|
string content = 1;
|
|
}
|
|
|
|
message MemoryUsageData {
|
|
uint64 total = 1;
|
|
map<string, uint64> breakdown = 2;
|
|
}
|
|
|
|
message SpeakerEncoder {
|
|
string identity = 1; // sha256 of loaded GGUF bytes
|
|
int32 dimension = 2;
|
|
string family = 3; // embedding space of the encoder; empty when the backend cannot tell
|
|
}
|
|
|
|
message StatusResponse {
|
|
enum State {
|
|
UNINITIALIZED = 0;
|
|
BUSY = 1;
|
|
READY = 2;
|
|
ERROR = -1;
|
|
}
|
|
State state = 1;
|
|
MemoryUsageData memory = 2;
|
|
SpeakerEncoder speaker_encoder = 3; // trusted metadata from the loaded server encoder, never request data
|
|
}
|
|
|
|
message Message {
|
|
string role = 1;
|
|
string content = 2;
|
|
// Optional fields for OpenAI-compatible message format
|
|
string name = 3; // Tool name (for tool messages)
|
|
string tool_call_id = 4; // Tool call ID (for tool messages)
|
|
string reasoning_content = 5; // Reasoning content (for thinking models)
|
|
string tool_calls = 6; // Tool calls as JSON string (for assistant messages with tool calls)
|
|
}
|
|
|
|
message DetectOptions {
|
|
string src = 1;
|
|
string prompt = 2; // Text prompt (for SAM 3 PCS mode)
|
|
repeated float points = 3; // Point coordinates as [x1, y1, label1, x2, y2, label2, ...] (label: 1=pos, 0=neg)
|
|
repeated float boxes = 4; // Box coordinates as [x1, y1, x2, y2, ...]
|
|
float threshold = 5; // Detection confidence threshold
|
|
// ModelIdentity names the model this request is for; see
|
|
// PredictOptions.ModelIdentity for the full rationale. Empty means "no
|
|
// identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 6;
|
|
}
|
|
|
|
message Detection {
|
|
float x = 1;
|
|
float y = 2;
|
|
float width = 3;
|
|
float height = 4;
|
|
float confidence = 5;
|
|
string class_name = 6;
|
|
bytes mask = 7; // PNG-encoded binary segmentation mask
|
|
}
|
|
|
|
message DetectResponse {
|
|
repeated Detection Detections = 1;
|
|
}
|
|
|
|
// --- Sound-event classification / audio tagging messages (CED) ---
|
|
|
|
message SoundDetectionRequest {
|
|
string src = 1; // audio file path (LocalAI writes the upload to disk)
|
|
int32 top_k = 2; // number of top tags to return (0 = all classes)
|
|
float threshold = 3; // optional: drop tags scoring below this
|
|
// ModelIdentity names the model this request is for; see
|
|
// PredictOptions.ModelIdentity for the full rationale. Empty means "no
|
|
// identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 4;
|
|
}
|
|
|
|
message SoundClass {
|
|
string label = 1; // AudioSet class name, e.g. "Baby cry, infant cry"
|
|
float score = 2; // per-class probability (multi-label, independent)
|
|
int32 index = 3; // class index in the model ontology
|
|
}
|
|
|
|
message SoundDetectionResponse {
|
|
repeated SoundClass detections = 1; // score-descending
|
|
}
|
|
|
|
// --- Depth estimation messages (Depth Anything 3) ---
|
|
|
|
message DepthRequest {
|
|
string src = 1; // input image (filesystem path or base64-encoded payload)
|
|
string dst = 2; // optional output directory for exports (glb/colmap)
|
|
bool include_depth = 3; // return the per-pixel metric depth map
|
|
bool include_confidence = 4; // return the per-pixel confidence map (DualDPT)
|
|
bool include_pose = 5; // return camera extrinsics/intrinsics (DualDPT)
|
|
bool include_sky = 6; // return the per-pixel sky map (mono models)
|
|
bool include_points = 7; // back-project to a 3D point cloud (DualDPT)
|
|
float points_conf_thresh = 8; // keep points with confidence >= this threshold
|
|
repeated string exports = 9; // requested exports: "glb", "colmap"
|
|
// ModelIdentity names the model this request is for; see
|
|
// PredictOptions.ModelIdentity for the full rationale. Empty means "no
|
|
// identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 10;
|
|
}
|
|
|
|
message DepthResponse {
|
|
int32 width = 1; // processed depth-map width
|
|
int32 height = 2; // processed depth-map height
|
|
repeated float depth = 3; // width*height row-major metric depth
|
|
repeated float confidence = 4; // width*height row-major confidence (DualDPT)
|
|
repeated float sky = 5; // width*height row-major sky map (mono)
|
|
repeated float extrinsics = 6; // 12 floats, 3x4 row-major (world-to-camera)
|
|
repeated float intrinsics = 7; // 9 floats, 3x3 row-major
|
|
int32 num_points = 8; // number of 3D points
|
|
repeated float points = 9; // num_points*3 xyz, world space
|
|
bytes point_colors = 10; // num_points*3 uint8 rgb
|
|
repeated string export_paths = 11; // paths written for the requested exports
|
|
bool is_metric = 12; // depth is in metric units
|
|
}
|
|
|
|
// --- Time-series forecasting messages (timestral.cpp) ---
|
|
//
|
|
// Arrays are flat and row-major. NaN marks a missing value. One request may
|
|
// carry series of different shapes; the backend groups them by shape and
|
|
// returns the results in the order the series were sent.
|
|
|
|
message ForecastSeries {
|
|
string id = 1; // echoed back in the matching result
|
|
int32 num_variates = 2; // V
|
|
int32 length = 3; // T, context steps per variate
|
|
repeated float target = 4; // V*T, NaN = missing
|
|
int32 num_past_covariates = 5; // C_past
|
|
repeated float past_covariates = 6; // C_past*T
|
|
int32 num_known_covariates = 7; // C_known
|
|
repeated float known_covariates = 8; // C_known*(T+H)
|
|
int32 num_past_categorical = 9; // CC_past
|
|
repeated double past_categorical = 10; // CC_past*T, NaN = missing code
|
|
int32 num_known_categorical = 11; // CC_known
|
|
repeated double known_categorical = 12; // CC_known*(T+H), NaN = missing code
|
|
}
|
|
|
|
message ForecastRequest {
|
|
repeated ForecastSeries series = 1;
|
|
int32 prediction_length = 2; // H, steps to forecast
|
|
repeated double quantiles = 3; // empty = backend default
|
|
int32 max_context = 4; // 0 = model default
|
|
optional bool symmetric_averaging = 5; // unset = model default
|
|
optional bool clip_nonnegative = 6; // unset = model default
|
|
// ModelIdentity names the model this request is for; see
|
|
// PredictOptions.ModelIdentity for the full rationale. Empty means "no
|
|
// identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 7;
|
|
}
|
|
|
|
message ForecastSeriesResult {
|
|
string id = 1;
|
|
int32 num_variates = 2; // V
|
|
repeated float values = 3; // V*Q*H row-major
|
|
}
|
|
|
|
message ForecastResponse {
|
|
int32 prediction_length = 1;
|
|
repeated double quantile_levels = 2; // levels returned, ascending
|
|
repeated ForecastSeriesResult series = 3; // same order as the request
|
|
}
|
|
|
|
// --- Face recognition messages ---
|
|
|
|
message FacialArea {
|
|
float x = 1;
|
|
float y = 2;
|
|
float w = 3;
|
|
float h = 4;
|
|
}
|
|
|
|
message FaceVerifyRequest {
|
|
string img1 = 1; // base64-encoded image
|
|
string img2 = 2; // base64-encoded image
|
|
float threshold = 3; // cosine-distance threshold; 0 = use backend default
|
|
bool anti_spoofing = 4; // run MiniFASNet liveness on each image; failed liveness forces verified=false
|
|
// ModelIdentity names the model this request is for; see
|
|
// PredictOptions.ModelIdentity for the full rationale. Empty means "no
|
|
// identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 5;
|
|
}
|
|
|
|
message FaceVerifyResponse {
|
|
bool verified = 1;
|
|
float distance = 2; // 1 - cosine_similarity
|
|
float threshold = 3;
|
|
float confidence = 4; // 0-100
|
|
string model = 5; // e.g. "buffalo_l"
|
|
FacialArea img1_area = 6;
|
|
FacialArea img2_area = 7;
|
|
float processing_time_ms = 8;
|
|
bool img1_is_real = 9; // anti-spoofing result when enabled
|
|
float img1_antispoof_score = 10;
|
|
bool img2_is_real = 11;
|
|
float img2_antispoof_score = 12;
|
|
}
|
|
|
|
message FaceAnalyzeRequest {
|
|
string img = 1; // base64-encoded image
|
|
repeated string actions = 2; // subset of ["age","gender","emotion","race"]; empty = all-supported
|
|
bool anti_spoofing = 3;
|
|
// ModelIdentity names the model this request is for; see
|
|
// PredictOptions.ModelIdentity for the full rationale. Empty means "no
|
|
// identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 4;
|
|
}
|
|
|
|
message FaceAnalysis {
|
|
FacialArea region = 1;
|
|
float face_confidence = 2;
|
|
float age = 3;
|
|
string dominant_gender = 4; // "Man" | "Woman"
|
|
map<string, float> gender = 5;
|
|
string dominant_emotion = 6; // reserved; empty in MVP
|
|
map<string, float> emotion = 7;
|
|
string dominant_race = 8; // not populated
|
|
map<string, float> race = 9;
|
|
bool is_real = 10; // anti-spoofing result when enabled
|
|
float antispoof_score = 11;
|
|
}
|
|
|
|
message FaceAnalyzeResponse {
|
|
repeated FaceAnalysis faces = 1;
|
|
}
|
|
|
|
// --- Voice (speaker) recognition messages ---
|
|
//
|
|
// Analogous to the Face* messages above, but for speaker biometrics.
|
|
// Audio fields accept a filesystem path (same convention as
|
|
// TranscriptRequest.dst). The HTTP layer materialises base64 / URL /
|
|
// data-URI inputs to a temp file before calling the gRPC backend.
|
|
|
|
message VoiceVerifyRequest {
|
|
string audio1 = 1; // path to first audio clip
|
|
string audio2 = 2; // path to second audio clip
|
|
float threshold = 3; // cosine-distance threshold; 0 = use backend default
|
|
bool anti_spoofing = 4; // reserved for future AASIST bolt-on
|
|
// ModelIdentity names the model this request is for; see
|
|
// PredictOptions.ModelIdentity for the full rationale. Empty means "no
|
|
// identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 5;
|
|
}
|
|
|
|
message VoiceVerifyResponse {
|
|
bool verified = 1;
|
|
float distance = 2; // 1 - cosine_similarity
|
|
float threshold = 3;
|
|
float confidence = 4; // 0-100
|
|
string model = 5; // e.g. "speechbrain/spkrec-ecapa-voxceleb"
|
|
float processing_time_ms = 6;
|
|
}
|
|
|
|
message VoiceAnalyzeRequest {
|
|
string audio = 1; // path to audio clip
|
|
repeated string actions = 2; // subset of ["age","gender","emotion"]; empty = all-supported
|
|
// ModelIdentity names the model this request is for; see
|
|
// PredictOptions.ModelIdentity for the full rationale. Empty means "no
|
|
// identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 3;
|
|
}
|
|
|
|
message VoiceAnalysis {
|
|
float start = 1; // segment start time in seconds (0 if single-utterance)
|
|
float end = 2; // segment end time in seconds
|
|
float age = 3;
|
|
string dominant_gender = 4;
|
|
map<string, float> gender = 5;
|
|
string dominant_emotion = 6;
|
|
map<string, float> emotion = 7;
|
|
}
|
|
|
|
message VoiceAnalyzeResponse {
|
|
repeated VoiceAnalysis segments = 1;
|
|
}
|
|
|
|
message VoiceEmbedRequest {
|
|
string audio = 1; // path to audio clip
|
|
// ModelIdentity names the model this request is for; see
|
|
// PredictOptions.ModelIdentity for the full rationale. Empty means "no
|
|
// identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 2;
|
|
}
|
|
|
|
message VoiceEmbedResponse {
|
|
repeated float embedding = 1;
|
|
string model = 2;
|
|
// Fingerprint of the encoder that made the embedding, when the backend can
|
|
// tell: the embedding space ("voicedetect:<arch>:<name>:<dim>") and the
|
|
// weights ("sha256:<hex>" of the model file). Both empty when unknown, and
|
|
// old backends never set them.
|
|
string encoder_family = 3;
|
|
string encoder_weights = 4;
|
|
}
|
|
|
|
message ToolFormatMarkers {
|
|
string format_type = 1; // "json_native", "tag_with_json", "tag_with_tagged"
|
|
|
|
// Tool section markers
|
|
string section_start = 2; // e.g., "<tool_call>", "[TOOL_CALLS]"
|
|
string section_end = 3; // e.g., "</tool_call>"
|
|
string per_call_start = 4; // e.g., "<|tool_call_begin|>"
|
|
string per_call_end = 5; // e.g., "<|tool_call_end|>"
|
|
|
|
// Function name markers (TAG_WITH_JSON / TAG_WITH_TAGGED)
|
|
string func_name_prefix = 6; // e.g., "<function="
|
|
string func_name_suffix = 7; // e.g., ">"
|
|
string func_close = 8; // e.g., "</function>"
|
|
|
|
// Argument markers (TAG_WITH_TAGGED)
|
|
string arg_name_prefix = 9; // e.g., "<param="
|
|
string arg_name_suffix = 10; // e.g., ">"
|
|
string arg_value_prefix = 11;
|
|
string arg_value_suffix = 12; // e.g., "</param>"
|
|
string arg_separator = 13; // e.g., "\n"
|
|
|
|
// JSON format fields (JSON_NATIVE)
|
|
string name_field = 14; // e.g., "name"
|
|
string args_field = 15; // e.g., "arguments"
|
|
string id_field = 16; // e.g., "id"
|
|
bool fun_name_is_key = 17;
|
|
bool tools_array_wrapped = 18;
|
|
reserved 19;
|
|
|
|
// Reasoning markers
|
|
string reasoning_start = 20; // e.g., "<think>"
|
|
string reasoning_end = 21; // e.g., "</think>"
|
|
|
|
// Content markers
|
|
string content_start = 22;
|
|
string content_end = 23;
|
|
|
|
// Args wrapper markers
|
|
string args_start = 24; // e.g., "<args>"
|
|
string args_end = 25; // e.g., "</args>"
|
|
|
|
// JSON parameter ordering
|
|
string function_field = 26; // e.g., "function" (wrapper key in JSON)
|
|
repeated string parameter_order = 27;
|
|
|
|
// Generated ID field (alternative field name for generated IDs)
|
|
string gen_id_field = 28; // e.g., "call_id"
|
|
|
|
// Call ID markers (position and delimiters for tool call IDs)
|
|
string call_id_position = 29; // "none", "pre_func_name", "between_func_and_args", "post_args"
|
|
string call_id_prefix = 30; // e.g., "[CALL_ID]"
|
|
string call_id_suffix = 31; // e.g., ""
|
|
}
|
|
|
|
message AudioEncodeRequest {
|
|
bytes pcm_data = 1;
|
|
int32 sample_rate = 2;
|
|
int32 channels = 3;
|
|
map<string, string> options = 4;
|
|
}
|
|
|
|
message AudioEncodeResult {
|
|
repeated bytes frames = 1;
|
|
int32 sample_rate = 2;
|
|
int32 samples_per_frame = 3;
|
|
}
|
|
|
|
message AudioDecodeRequest {
|
|
repeated bytes frames = 1;
|
|
map<string, string> options = 2;
|
|
}
|
|
|
|
message AudioDecodeResult {
|
|
bytes pcm_data = 1;
|
|
int32 sample_rate = 2;
|
|
int32 samples_per_frame = 3;
|
|
}
|
|
|
|
// Generic audio transform: an audio-in, audio-out operation, optionally
|
|
// conditioned on a second reference signal. Concrete transforms include
|
|
// AEC + noise suppression + dereverberation (LocalVQE), voice conversion
|
|
// (reference = target speaker), pitch shifting, etc.
|
|
message AudioTransformRequest {
|
|
string audio_path = 1; // required, primary input file path
|
|
string reference_path = 2; // optional auxiliary; empty => zero-fill
|
|
string dst = 3; // required, output file path
|
|
map<string, string> params = 4; // backend-specific tuning
|
|
// ModelIdentity names the model this request is for; see
|
|
// PredictOptions.ModelIdentity for the full rationale. Empty means "no
|
|
// identity supplied" and backends MUST skip the check.
|
|
string ModelIdentity = 5;
|
|
}
|
|
|
|
// One named output of a transform that produces several from a single run.
|
|
// Source separation is the case that needs it: htdemucs yields drums, bass,
|
|
// other and vocals from one pass over the input.
|
|
message AudioTransformStem {
|
|
string name = 1; // the model's own stem id, e.g. "vocals"
|
|
string dst = 2; // path of the file written for that stem
|
|
}
|
|
|
|
message AudioTransformResult {
|
|
string dst = 1;
|
|
int32 sample_rate = 2;
|
|
int32 samples = 3;
|
|
bool reference_provided = 4;
|
|
// Every named output the run produced, in the model's own order, including
|
|
// the one copied into dst. Empty for a transform with a single output.
|
|
//
|
|
// It exists because dst carries one file while separation produces several,
|
|
// and running the model once per stem would cost four full separations of
|
|
// the same audio. The backend runs once, writes each stem beside dst, and
|
|
// names them here; without this field the other stems are on disk but no
|
|
// caller can find them, which is the same as not having produced them.
|
|
repeated AudioTransformStem stems = 5;
|
|
}
|
|
|
|
// Bidirectional streaming audio transform. The first message MUST carry a
|
|
// Config; subsequent messages carry Frames. A second Config mid-stream
|
|
// resets streaming state before the next frame.
|
|
message AudioTransformFrameRequest {
|
|
oneof payload {
|
|
AudioTransformStreamConfig config = 1;
|
|
AudioTransformFrame frame = 2;
|
|
}
|
|
}
|
|
|
|
message AudioTransformStreamConfig {
|
|
enum SampleFormat {
|
|
F32_LE = 0;
|
|
S16_LE = 1;
|
|
}
|
|
SampleFormat sample_format = 1;
|
|
int32 sample_rate = 2; // 0 => backend default
|
|
int32 frame_samples = 3; // 0 => backend default
|
|
map<string, string> params = 4;
|
|
bool reset = 5; // reset streaming state before next frame
|
|
}
|
|
|
|
message AudioTransformFrame {
|
|
bytes audio_pcm = 1; // frame_samples samples in stream's format
|
|
bytes reference_pcm = 2; // empty => zero-fill (silent reference)
|
|
}
|
|
|
|
message AudioTransformFrameResponse {
|
|
bytes pcm = 1;
|
|
int64 frame_index = 2;
|
|
}
|
|
|
|
// === AudioToAudioStream messages =========================================
|
|
//
|
|
// Bidirectional stream between the LocalAI core and an any-to-any audio
|
|
// model. The client opens the stream with a Config payload, then alternates
|
|
// Frame (input audio) and Control (turn boundaries, function-call results,
|
|
// session updates) payloads. The server streams back typed events: audio
|
|
// frames carry PCM in `pcm`; transcript / tool-call deltas carry JSON in
|
|
// `meta`; the stream ends with a `response.done` (success) or `error` event.
|
|
|
|
message AudioToAudioRequest {
|
|
oneof payload {
|
|
AudioToAudioConfig config = 1;
|
|
AudioToAudioFrame frame = 2;
|
|
AudioToAudioControl control = 3;
|
|
}
|
|
}
|
|
|
|
message AudioToAudioConfig {
|
|
// PCM format for client→server audio. 0 => backend default
|
|
// (16 kHz, the rate the speech encoder expects).
|
|
int32 input_sample_rate = 1;
|
|
// Preferred server→client audio rate. 0 => backend default
|
|
// (24 kHz, the rate the speech decoder produces).
|
|
int32 output_sample_rate = 2;
|
|
// Optional system prompt override. Empty => backend chooses based on
|
|
// mode (e.g. "Respond with interleaved text and audio.").
|
|
string system_prompt = 3;
|
|
// Optional baked-voice id. Models that only ship a fixed set of
|
|
// voices (e.g. us_male/us_female/uk_male/uk_female) match
|
|
// this against their voice table; an empty string keeps the default.
|
|
string voice = 4;
|
|
// JSON-encoded array of tool definitions in OpenAI Chat Completions
|
|
// format. Empty => no tools.
|
|
string tools = 5;
|
|
// Free-form sampling / decoding parameters (temperature, top_k,
|
|
// max_new_tokens, audio_top_k, etc).
|
|
map<string, string> params = 6;
|
|
// True => reset any session-scoped state before processing further
|
|
// frames on this stream. The first Config implicitly resets.
|
|
bool reset = 7;
|
|
}
|
|
|
|
message AudioToAudioFrame {
|
|
// Raw PCM s16le mono at config.input_sample_rate. Empty pcm + end_of_input
|
|
// is a valid "user finished speaking" marker without trailing audio.
|
|
bytes pcm = 1;
|
|
// Marks the last frame of a user turn. The backend may begin emitting
|
|
// a response immediately after seeing this.
|
|
bool end_of_input = 2;
|
|
}
|
|
|
|
message AudioToAudioControl {
|
|
// Free-form control event names. Initial set:
|
|
// "input_audio_buffer.commit" — user finished speaking
|
|
// "response.cancel" — abort in-flight generation
|
|
// "conversation.item.create" — inject a non-audio item (e.g.
|
|
// function_call_output as JSON in
|
|
// `payload`)
|
|
// "session.update" — re-configure mid-stream
|
|
// "response.create" — start a response; payload
|
|
// {"output_modalities":[...],
|
|
// "max_output_tokens":N}
|
|
// A function_call_output item is {"type":"function_call_output",
|
|
// "call_id":...,"output":...} in the payload of "conversation.item.create".
|
|
string event = 1;
|
|
// Event-specific JSON payload.
|
|
bytes payload = 2;
|
|
}
|
|
|
|
message AudioToAudioResponse {
|
|
// Event identifies what this frame carries. Mirrors the OpenAI Realtime
|
|
// API server-event names where applicable. Initial set:
|
|
// "session.created" — meta: input_sample_rate,
|
|
// output_sample_rate, voices
|
|
// "session.updated" — meta: same as session.created
|
|
// "input_audio_buffer.committed"
|
|
// "response.audio.delta"
|
|
// "response.audio_transcript.delta" — meta: {"delta": text}
|
|
// "response.text.delta" — text-only responses
|
|
// "response.function_call_arguments.delta"
|
|
// "response.function_call_arguments.done" — meta: call_id, name,
|
|
// arguments (a JSON string)
|
|
// "response.done" — meta: status, usage, text
|
|
// "error" — meta: type, message
|
|
string event = 1;
|
|
// Populated when event = response.audio.delta.
|
|
bytes pcm = 2;
|
|
// Populated alongside pcm to identify its rate. 0 => same as the
|
|
// session's negotiated output_sample_rate.
|
|
int32 sample_rate = 3;
|
|
// JSON payload for non-PCM events (transcript chunk, tool args, error
|
|
// body).
|
|
bytes meta = 4;
|
|
// Monotonic per-stream counter, useful for client reordering and
|
|
// debugging.
|
|
int64 sequence = 5;
|
|
}
|
|
|
|
message ModelMetadataResponse {
|
|
bool supports_thinking = 1;
|
|
string rendered_template = 2; // The rendered chat template with enable_thinking=true (empty if not applicable)
|
|
ToolFormatMarkers tool_format = 3; // Auto-detected tool format markers from differential template analysis
|
|
string media_marker = 4; // Marker the backend expects in the prompt for each multimodal input (images/audio/video). Empty when the backend does not use a marker.
|
|
}
|
|
|
|
// Fine-tuning messages
|
|
|
|
message FineTuneRequest {
|
|
// Model identification
|
|
string model = 1; // HF model name or local path
|
|
string training_type = 2; // "lora", "loha", "lokr", "full" — what parameters to train
|
|
string training_method = 3; // "sft", "dpo", "grpo", "rloo", "reward", "kto", "orpo", "network_training"
|
|
|
|
// Adapter config (universal across LoRA/LoHa/LoKr for LLM + diffusion)
|
|
int32 adapter_rank = 10; // LoRA rank (r), default 16
|
|
int32 adapter_alpha = 11; // scaling factor, default 16
|
|
float adapter_dropout = 12; // default 0.0
|
|
repeated string target_modules = 13; // layer names to adapt
|
|
|
|
// Universal training hyperparameters
|
|
float learning_rate = 20; // default 2e-4
|
|
int32 num_epochs = 21; // default 3
|
|
int32 batch_size = 22; // default 2
|
|
int32 gradient_accumulation_steps = 23; // default 4
|
|
int32 warmup_steps = 24; // default 5
|
|
int32 max_steps = 25; // 0 = use epochs
|
|
int32 save_steps = 26; // 0 = only save final
|
|
float weight_decay = 27; // default 0.01
|
|
bool gradient_checkpointing = 28;
|
|
string optimizer = 29; // adamw_8bit, adamw, sgd, adafactor, prodigy
|
|
int32 seed = 30; // default 3407
|
|
string mixed_precision = 31; // fp16, bf16, fp8, no
|
|
|
|
// Dataset
|
|
string dataset_source = 40; // HF dataset ID, local file/dir path
|
|
string dataset_split = 41; // train, test, etc.
|
|
|
|
// Output
|
|
string output_dir = 50;
|
|
string job_id = 51; // client-assigned or auto-generated
|
|
|
|
// Resume training from a checkpoint
|
|
string resume_from_checkpoint = 55; // path to checkpoint dir to resume from
|
|
|
|
// Backend-specific AND method-specific extensibility
|
|
map<string, string> extra_options = 60;
|
|
}
|
|
|
|
message FineTuneJobResult {
|
|
string job_id = 1;
|
|
bool success = 2;
|
|
string message = 3;
|
|
}
|
|
|
|
message FineTuneProgressRequest {
|
|
string job_id = 1;
|
|
}
|
|
|
|
message FineTuneProgressUpdate {
|
|
string job_id = 1;
|
|
int32 current_step = 2;
|
|
int32 total_steps = 3;
|
|
float current_epoch = 4;
|
|
float total_epochs = 5;
|
|
float loss = 6;
|
|
float learning_rate = 7;
|
|
float grad_norm = 8;
|
|
float eval_loss = 9;
|
|
float eta_seconds = 10;
|
|
float progress_percent = 11;
|
|
string status = 12; // queued, caching, loading_model, loading_dataset, training, saving, completed, failed, stopped
|
|
string message = 13;
|
|
string checkpoint_path = 14; // set when a checkpoint is saved
|
|
string sample_path = 15; // set when a sample is generated (video/image backends)
|
|
map<string, float> extra_metrics = 16; // method-specific metrics
|
|
}
|
|
|
|
message FineTuneStopRequest {
|
|
string job_id = 1;
|
|
bool save_checkpoint = 2;
|
|
}
|
|
|
|
message ListCheckpointsRequest {
|
|
string output_dir = 1;
|
|
}
|
|
|
|
message ListCheckpointsResponse {
|
|
repeated CheckpointInfo checkpoints = 1;
|
|
}
|
|
|
|
message CheckpointInfo {
|
|
string path = 1;
|
|
int32 step = 2;
|
|
float epoch = 3;
|
|
float loss = 4;
|
|
string created_at = 5;
|
|
}
|
|
|
|
message ExportModelRequest {
|
|
string checkpoint_path = 1;
|
|
string output_path = 2;
|
|
string export_format = 3; // lora, loha, lokr, merged_16bit, merged_4bit, gguf, diffusers
|
|
string quantization_method = 4; // for GGUF: q4_k_m, q5_k_m, q8_0, f16, etc.
|
|
string model = 5; // base model name (for merge operations)
|
|
map<string, string> extra_options = 6;
|
|
}
|
|
|
|
// Quantization messages
|
|
|
|
message QuantizationRequest {
|
|
string model = 1; // HF model name or local path
|
|
string quantization_type = 2; // q4_k_m, q5_k_m, q8_0, f16, etc.
|
|
string output_dir = 3; // where to write output files
|
|
string job_id = 4; // client-assigned job ID
|
|
map<string, string> extra_options = 5; // hf_token, custom flags, etc.
|
|
}
|
|
|
|
message QuantizationJobResult {
|
|
string job_id = 1;
|
|
bool success = 2;
|
|
string message = 3;
|
|
}
|
|
|
|
message QuantizationProgressRequest {
|
|
string job_id = 1;
|
|
}
|
|
|
|
message QuantizationProgressUpdate {
|
|
string job_id = 1;
|
|
float progress_percent = 2;
|
|
string status = 3; // queued, downloading, converting, quantizing, completed, failed, stopped
|
|
string message = 4;
|
|
string output_file = 5; // set when completed — path to the output GGUF file
|
|
map<string, float> extra_metrics = 6; // e.g. file_size_mb, compression_ratio
|
|
}
|
|
|
|
message QuantizationStopRequest {
|
|
string job_id = 1;
|
|
}
|
|
|
|
// ForwardHeader is one HTTP header on the request or response. Headers
|
|
// like Authorization are typically injected by the backend (from the
|
|
// resolved API key) rather than passed through from the client.
|
|
message ForwardHeader {
|
|
string name = 1;
|
|
string value = 2;
|
|
}
|
|
|
|
// ForwardRequest is a streamed HTTP request to the upstream. First
|
|
// message carries path/method/headers; subsequent messages carry
|
|
// body_chunk only. All fields except body_chunk are honoured on the
|
|
// first message and ignored thereafter.
|
|
message ForwardRequest {
|
|
string path = 1; // e.g. "/v1/chat/completions" — appended to the model's upstream_url
|
|
string method = 2; // usually "POST"
|
|
repeated ForwardHeader headers = 3;
|
|
bytes body_chunk = 4;
|
|
}
|
|
|
|
// ForwardReply is a streamed HTTP response from the upstream. First
|
|
// message carries status/headers; subsequent messages carry body_chunk
|
|
// only. SSE responses arrive as a sequence of body_chunk frames; the
|
|
// caller is responsible for any parsing.
|
|
message ForwardReply {
|
|
int32 status = 1;
|
|
repeated ForwardHeader headers = 2;
|
|
bytes body_chunk = 3;
|
|
}
|
|
|
|
// Configuration is first; later messages contain input only.
|
|
message MotionRequest {
|
|
string model_identity = 1;
|
|
string profile = 2;
|
|
bytes input = 3; // Serialized public localai.motion.v1.Input.
|
|
}
|
|
message MotionResponse {
|
|
bytes output = 1; // Serialized public localai.motion.v1.Output.
|
|
// Backend-only bounded stage timings; not part of the public wire protocol.
|
|
map<string, double> stage_ms = 2;
|
|
}
|