ENHANCEMENT:Reduce unnecessary LLM API calls

未关闭
#241 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@vaishcodescape 已经在做这个了。

开始于 2026年1月15日。

  • #242 来自 @vaishcodescape —— 已关闭,未合并
  • #243 来自 @vaishcodescape —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
ai, performance

调研方向

从 ClassificationRouter.should_process_message 入手,检查当前的 llm.ainvoke 调用及其周围的消息分类流程。找出相关测试,或为规范化的常见消息、重复分类、缓存过期和使用指标添加测试覆盖;完成标准是简单消息或缓存命中的消息避免不必要的 LLM 调用,同时其他消息保持现有行为。

由索引模型根据 Issue 内容生成。

描述

Is your feature request related to a problem?
  • Yes, it is related to a problem
Describe the feature you'd like

🌟 Feature Description

Reduce unnecessary LLM API calls in the message classification system by adding smart caching and simple pattern matching.

This feature will:

  • Detect common messages (e.g. greetings, thanks, acknowledgments) without calling the LLM
  • Cache previous LLM classification results using an LRU cache with TTL
  • Normalize messages (lowercase, trim spaces, etc.) to improve cache hits
  • Track basic metrics to measure cache usage and saved LLM calls

🔍 Problem Statement

Currently, the ClassificationRouter makes an LLM API call for every single Discord message, even for very simple or repeated messages.

This leads to:

  • Unnecessary API usage increasing
  • Increased latency
  • Higher operational costs
Current Behavior
async def should_process_message(self, message: str, context: Dict[str, Any] = None):
    response = await self.llm.ainvoke([HumanMessage(content=triage_prompt)])

Every incoming message triggers the LLM, regardless of whether it is:

  • A simple greeting like “hi”
  • A repeated message
  • A non-actionable acknowledgment

🎯 Expected Outcome

After this enhancement:

  • Simple messages are handled using pattern matching
  • Repeated messages reuse results from the cache
  • LLM calls are made only when truly needed
  • Overall performance and efficiency improve significantly

This will reduce API calls, lower costs, and make the system faster and more scalable.

Record
  • I agree to follow this project's Code of Conduct
  • I want to work on implementing this feature
主要语言
Python
星标
103
派生
143
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

AOSSIE-Org/Devr.AI 的其他 Issue

查看 AOSSIE-Org/Devr.AI 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。