Add the harness, envs, per-bot models and chat attachments
- Harness: providers, model catalog synced hourly, automatic free picks, cooldowns, tool loop with context trimming, MCP computer tools - Bots queue runs replies and tasks through the harness; jobs wait (attempt refunded) while every model is resting - Envs: Settings > Environment, scoped general/workspace/computer, written to computers and redacted from tool output - Models: Settings > Models, per-harness provider select defaulting to OpenRouter, and a models modal on each bot's chat (the coordinator's edits the defaults) - Chat: thinking row while a reply runs, file attachments (upload, paste, drop) that replies read as images, audio and document text - Fix media uploads failing after a user's first file, and private files being served from the public media path Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
import grabHarnessSetting from "@/src/functions/backend/db/harness/grab-harness-setting";
|
||||
import grabHarnessAdapter from "../providers/grab-harness-adapter";
|
||||
import resolveHarnessCandidates from "../resolve/resolve-harness-candidates";
|
||||
import withCandidates from "../resolve/with-candidates";
|
||||
import type { HarnessCandidate } from "../types";
|
||||
|
||||
type Params = {
|
||||
text: string;
|
||||
/**
|
||||
* `mp3` unless set.
|
||||
*/
|
||||
format?: string;
|
||||
signal?: AbortSignal;
|
||||
/**
|
||||
* Uses this bot's speech model and voice when it has its own.
|
||||
*/
|
||||
bot_id?: number | string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Reads text aloud with the speech harness. Uses the voice picked in the
|
||||
* speech setting when the model has it, else the model's first voice.
|
||||
*/
|
||||
export default async function speakText({
|
||||
text,
|
||||
format,
|
||||
signal,
|
||||
bot_id,
|
||||
}: Params) {
|
||||
const [candidates, setting] = await Promise.all([
|
||||
resolveHarnessCandidates({ harness: "speech", bot_id }),
|
||||
grabHarnessSetting({ harness: "speech", bot_id }),
|
||||
]);
|
||||
|
||||
const { result } = await withCandidates({
|
||||
harness: "speech",
|
||||
candidates,
|
||||
run: async (candidate) =>
|
||||
await grabHarnessAdapter({ kind: candidate.provider.kind }).speak({
|
||||
candidate,
|
||||
text,
|
||||
voice: pickVoice({
|
||||
candidate,
|
||||
voice:
|
||||
typeof setting.options.voice == "string"
|
||||
? setting.options.voice
|
||||
: undefined,
|
||||
}),
|
||||
format,
|
||||
signal: signal || new AbortController().signal,
|
||||
}),
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function pickVoice({
|
||||
candidate,
|
||||
voice,
|
||||
}: {
|
||||
candidate: HarnessCandidate;
|
||||
voice?: string;
|
||||
}) {
|
||||
const voices = candidate.model.voices;
|
||||
|
||||
if (voice && (candidate.source == "pinned" || voices?.includes(voice))) {
|
||||
return voice;
|
||||
}
|
||||
|
||||
if (voices?.[0]) return voices[0];
|
||||
|
||||
return candidate.provider.kind == "openai" ? "alloy" : undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user