matchAgentByReference (voice/match-agent.ts)

better-chatbot · apps/web/src/lib/voice/match-agent.ts · typescript · MIT
voice

* Matching an agent from whatever a speech model said. Client-safe and pure, because both halves need it: `askAgent` resolves on the server, while `activateAgent` is handled inline in the voice hook and resolves in the browser. One implementation keeps the two from disagreeing ab

// Source: https://github.com/keinsaasforever/better-chatbot | License: MIT | Copyright 2025 better-chatbot
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Matching an agent from whatever a speech model said.
 *
 * Client-safe and pure, because both halves need it: `askAgent` resolves on
 * the server, while `activateAgent` is handled inline in the voice hook and
 * resolves in the browser. One implementation keeps the two from disagreeing
 * about which agent "the sales one" means.
 */

export type AgentChoice = { id: string; name: string };

/**
 * Find the agent a reference points at, or `null`.
 *
 * A speech model does not say UUIDs. Even with the roster in its instructions
 * it paraphrases — "the sales agent", "Sales", "unser Vertriebsagent" — so an
 * id-onl

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key