mirror of
https://git.undefined-dev.fr/Blendman974/faceclaw.git
synced 2026-11-29 09:03:12 +00:00
Add calculator and microphone conversation apps
Add symbolic math and graphing tools, dual-microphone audio processing, live captions, translation, speaker diarization, sentiment analysis, and searchable conversation history. Extend Android voice and BLE support for microphone control, recording, transcoding, and on-device speaker identification, with coverage for calculator and microphone workflows.
This commit is contained in:
124 files changed
+22061
-58
No files matched your search
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* One-shot completion against the assistant's configured model, used by the
|
||||
* Calculator's optional rewrite fallback (see MathCoordinator.answerSpoken:
|
||||
* the deterministic parser runs first; the model only ever translates words
|
||||
* into notation). Resolves to null when no provider is configured or the
|
||||
* call fails — the calculator then reports "could not read that" instead of
|
||||
* surfacing a transport error.
|
||||
*/
|
||||
import { streamAnthropicMessage } from "../../native/anthropic";
|
||||
import { streamLocalQwen } from "../../native/llama";
|
||||
import { streamOpenAiResponse } from "../../native/openai";
|
||||
import { resolveAssistantModel } from "../../assistant/models";
|
||||
import { type LlmStreamOptions } from "../../assistant/llm-protocol";
|
||||
import {
|
||||
anthropicApiKeySetting,
|
||||
assistantModelSetting,
|
||||
openAiApiKeySetting,
|
||||
} from "../../ui/dashboard-settings";
|
||||
import { CALCULATOR_REWRITE_SYSTEM_PROMPT, buildCalculatorRewriteUserMessage } from "../../prompts";
|
||||
|
||||
export function rewriteSpokenProblem(spoken: string): Promise<string | null> {
|
||||
const resolved = resolveAssistantModel(assistantModelSetting.get(), {
|
||||
anthropic: anthropicApiKeySetting.get(),
|
||||
openai: openAiApiKeySetting.get(),
|
||||
});
|
||||
if (!resolved) return Promise.resolve(null);
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const options: LlmStreamOptions = {
|
||||
apiKey: resolved.apiKey,
|
||||
model: resolved.model,
|
||||
system: CALCULATOR_REWRITE_SYSTEM_PROMPT,
|
||||
effort: "low",
|
||||
maxTokens: 200,
|
||||
messages: [{ role: "user", content: buildCalculatorRewriteUserMessage(spoken) }],
|
||||
onDone: (result) => resolve(result.text ?? null),
|
||||
onError: () => resolve(null),
|
||||
};
|
||||
switch (resolved.provider) {
|
||||
case "openai":
|
||||
streamOpenAiResponse(options);
|
||||
break;
|
||||
case "local":
|
||||
streamLocalQwen(options);
|
||||
break;
|
||||
default:
|
||||
streamAnthropicMessage(options);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user