Files
ermnvldmr.com/services/docs/content/en/quetza/guides/conversational-ai.md
T
deytenit b3638f4d63 fix: cyrillic fonts, dev certs, page head, and ru-text typography (#67)
🤖 PR generated for branch `fix/cyrillic-fonts-dev-certs-and-page-head`.

### Changes Summary
- **Fonts**: Add Cyrillic glyph subsets for Lato, EB Garamond, and Fira
Code.
- **Dev**: Support remote Root CA and encrypted dev CA key in
`.env.dev`.
- **UI & Kits**: Add size variant to `Breadcrumbs` component and enlarge
`PageHead` breadcrumbs with tuned collapse scroll threshold.
- **ESLint**: Add `no-hanging-particles` i18n & markdown typography rule
with auto-fixer.
- **Content & i18n**: Apply `ru-text` editorial and typography polish
(em dashes, number ranges, «ё» restoration, non-breaking spaces) across
`services/www` and `services/docs`.
2026-10-25 15:21:09 +03:00

1.5 KiB

title, weight
title weight
Conversational AI Integration 4

Goal: Integrate Large Language Models (LLMs) while managing context and Discord's timeout constraints.

1. Context Management Strategy

Conversations require history to be coherent.

  • Scoping: Map<GuildID, Map<UserID, Message[]>>
    • Guild Key: Prevents cross-server leaks.
    • User Key: Prevents cross-user confusion in public channels.
  • Lifecycle: Implement a rolling window (e.g., last 50 messages) to prevent context bloat.

2. Response Streaming

LLMs are slow; Discord is fast (3s timeout).

{{% steps %}}

Step 1: Defer Interaction

Immediately call interaction.deferReply(). This buys you 15 minutes.

Step 2: Invoke LLM

Call your AI service asynchronously.

Step 3: Edit Response

When data arrives, use interaction.editReply(content). {{% /steps %}}

3. Implementation Sketch

// commands/chat.ts
export async function execute(interaction, controller) {
  // 1. Defer
  await interaction.deferReply();

  // 2. Process
  const history = controller.getHistory(interaction.guildId, interaction.user.id);
  const response = await aiService.generate(interaction.options.getString('prompt'), history);

  // 3. Respond
  await interaction.editReply(response);
  controller.updateHistory(interaction.guildId, interaction.user.id, response);
}

Warning

API Costs: AI APIs are often billed by token. Implement strict user-based rate limits in your Controller to prevent abuse.