feat(telegram-remote): show transcript in Telegram only, not to AI
This commit is contained in:
@@ -505,8 +505,8 @@ function pickAudioFilename(audio, mimeType) {
|
||||
|
||||
/**
|
||||
* Transcribe a voice message / audio file / audio document via the home-lab
|
||||
* Whishper server, show the transcript, and queue it into the chat session
|
||||
* like a normal user message.
|
||||
* Whishper server and show the transcript in Telegram. The transcript is
|
||||
* deliberately NOT sent to the AI agent as a prompt.
|
||||
*/
|
||||
async function handleAudio(state, chatId, userId, audio, messageId) {
|
||||
let statusMessageId = null;
|
||||
@@ -550,27 +550,7 @@ async function handleAudio(state, chatId, userId, audio, messageId) {
|
||||
state.log("audio transcript edit failed: " + editError.message);
|
||||
}
|
||||
|
||||
const cs = state.chatState(chatId);
|
||||
if (messageId != null) cs.lastUserMessageId = messageId;
|
||||
if (!cs.sessionId) {
|
||||
try {
|
||||
const created = await callApi(state.ctx, "sessions", "create", { cwd: state.config.workspaceRoot || process.cwd() });
|
||||
cs.sessionId = created.sessionId;
|
||||
state.saveState();
|
||||
} catch {}
|
||||
}
|
||||
if (!cs.sessionId) {
|
||||
await state.bot.send(chatId, "No chat is open yet — tap 💬 New chat first.");
|
||||
return;
|
||||
}
|
||||
await callApi(state.ctx, "sessions", "prompt", {
|
||||
sessionId: cs.sessionId,
|
||||
mode: "queue",
|
||||
content: [{ type: "text", text: trimmed }],
|
||||
clientTimeZone: (() => { try { return Intl.DateTimeFormat().resolvedOptions().timeZone; } catch { return "UTC"; } })(),
|
||||
});
|
||||
state.notePrompt(cs.sessionId, trimmed);
|
||||
state.log("audio transcribed (" + state.config.whisperModel + ") and sent to " + cs.sessionId + " by " + userId);
|
||||
state.log("audio transcribed (" + state.config.whisperModel + ") for chat " + chatId + " by " + userId);
|
||||
} catch (error) {
|
||||
state.log("audio handling failed: " + (error.stack ?? error.message));
|
||||
const message = "⚠️ Couldn't transcribe the audio: " + esc(error.message);
|
||||
|
||||
Reference in New Issue
Block a user