zenfeed icon indicating copy to clipboard operation
zenfeed copied to clipboard

add rate limiting for LLMs, added a new api for adding RSS , fixed a bug where the RSS interface was not using the access key.

Open Twelveeee opened this issue 11 months ago • 5 comments

add rate limiting for LLMs, added a new api for adding RSS , fixed a bug where the RSS interface was not using the access key.

Summary

This PR introduces three major enhancements to improve the functionality, security, and stability of the zenfeed project:

1. LLM Rate Limiting Implementation

  • Added RPM (Requests Per Minute) configuration field for LLM settings
  • Implemented token bucket rate limiter with comprehensive unit tests
  • Integrated rate limiting into OpenAI and Gemini LLM implementations
  • Updated documentation to describe the new rate limiting configuration

2. RSS Feed Source Addition Interface

  • Added AddFeedSource API endpoint for dynamically adding new RSS feed sources
  • Implemented comprehensive validation for feed source parameters
  • Added HTTP route /add_feed_source for REST API access
  • Created MCP tool add_feed_source for feed source management through MCP protocol

3. Fixed RSS Interface Access Key Bug

  • Added RSSHubAccessKey configuration field to support RSSHub instances with authentication
  • Implemented appendAccessKeyToURL method to automatically append access keys to RSSHub API requests
  • Updated RSSHub query methods to use access keys properly

实现LLM 速率限制,新增rss订阅链接添加接口,修复rss接口没有使用accessKey的bug

摘要

本 PR 引入了三项主要增强功能,以提高 zenfeed 项目的功能性、安全性和稳定性:

1. 实现LLM速率限制

  • 为 LLM 设置添加 RPM(每分钟请求数)配置字段
  • 实现基于令牌桶算法的速率限制器,包含全面的单元测试
  • 将速率限制集成到 OpenAI 和 Gemini LLM 实现中
  • 更新文档,描述新的速率限制配置

2. 新增RSS订阅链接添加接口

  • 添加 AddFeedSource API 端点,用于动态添加新的 RSS 源
  • 实现对 RSS 源参数的全面验证
  • 添加 HTTP 路由 /add_feed_source 用于 REST API 访问
  • 创建 MCP 工具 add_feed_source,通过 MCP 协议管理 RSS 源

3. 修复RSS接口没有使用accessKey的bug

  • 添加 RSSHubAccessKey 配置字段,支持需要身份验证的 RSSHub 实例
  • 实现 appendAccessKeyToURL 方法,自动将访问密钥附加到 RSSHub API 请求
  • 更新 RSSHub 查询方法,正确使用访问密钥

Summary by Sourcery

添加可配置的 LLM 每分钟请求次数限流、新的用于添加 RSS 源的 API 接口(包括 HTTP 和 MCP 工具),并修复 RSSHub 和标签处理逻辑,以提高可靠性并支持带身份认证的 RSS。

New Features:

  • 引入可配置的「按 LLM 维度」的每分钟请求数(RPM)限流机制,并将其应用于 OpenAI 和 Gemini provider
  • 新增 API endpoint、HTTP route 和 MCP tool,以便动态向抓取配置中添加 RSS 源

Bug Fixes:

  • 确保 RSSHub 请求在配置中提供可选的 access key 时,将其追加到所有 RSSHub API URL 中
  • 修复 JSON label 的序列化处理,避免返回可能会从对象池中被复用的缓冲区

Enhancements:

  • 在 LLM 配置中扩展一个 RPM 字段,并在工厂配置中完成传递
  • 在 API 配置中暴露 RSSHub access key,以支持需要认证的 RSSHub 实例

Documentation:

  • 在英文和中文的配置指南中补充新的 LLM rpm 配置选项说明

Tests:

  • 为基于 token-bucket 的 LLM 限流器添加单元测试,覆盖基础行为、速率控制、取消、零/负 RPM,以及并发场景
Original summary in English

Summary by Sourcery

Add configurable LLM requests-per-minute rate limiting, a new API surface for adding RSS feed sources (including HTTP and MCP tooling), and fix RSSHub and label handling to improve reliability and authenticated RSS support.

New Features:

  • Introduce configurable per-LLM requests-per-minute rate limiting and apply it to OpenAI and Gemini providers
  • Add an API endpoint, HTTP route, and MCP tool to dynamically add RSS feed sources to the scrape configuration

Bug Fixes:

  • Ensure RSSHub requests include an optional access key from configuration by appending it to all RSSHub API URLs
  • Fix JSON label marshaling to avoid returning a buffer that may be reused from the pool

Enhancements:

  • Extend LLM configuration with an RPM field and propagate it through factory configuration
  • Expose RSSHub access key in API configuration for authenticated RSSHub instances

Documentation:

  • Document the new LLM rpm configuration option in both English and Chinese config guides

Tests:

  • Add unit tests for the token-bucket-based LLM rate limiter, including basic, rate, cancellation, zero/negative RPM, and concurrency scenarios

Twelveeee avatar Jan 04 '26 14:01 Twelveeee

Reviewer's Guide

为 LLM 提供商实现基于令牌桶的每分钟请求数(RPM)限流;新增用于动态添加 RSS 源的 API / HTTP / MCP 接口;修复所有 RSSHub 查询中对 RSSHub 访问密钥的处理;并通过在重用缓冲区前进行拷贝,修正 Labels 中的 JSON 编码(marshaling)问题,同时更新相关配置与文档。

新增 add_feed_source MCP 与 API 流程的时序图

sequenceDiagram
    actor User
    participant MCPClient
    participant MCPServer as MCPServer_server
    participant API as API_impl
    participant ConfigMgr as ConfigManager

    User->>MCPClient: Configure add_feed_source tool call
    MCPClient->>MCPServer: callTool add_feed_source(name, url|rsshub_route_path)
    MCPServer->>MCPServer: addFeedSource validate arguments
    MCPServer->>API: AddFeedSource(AddFeedSourceRequest)
    API->>API: Validate Source (name, RSS, URL vs RSSHubRoutePath)
    API->>ConfigMgr: AppConfig()
    ConfigMgr-->>API: AppConfig with Scrape.Sources
    API->>API: Check duplicate source name
    API->>ConfigMgr: SaveAppConfig(updated AppConfig)
    ConfigMgr-->>API: Save result
    API-->>MCPServer: AddFeedSourceResponse
    MCPServer-->>MCPClient: CallToolResult "Feed source added successfully"
    MCPClient-->>User: Display success message

LLM 限流与提供商集成的类图

classDiagram
    class Config {
        +string Provider
        +string APIKey
        +string Model
        +string EmbeddingModel
        +string TTSModel
        +float32 Temperature
        +int RPM
    }

    class RateLimiter {
        <<interface>>
        +Wait(ctx context.Context) error
        +TryAcquire() bool
    }

    class noopRateLimiter {
        +Wait(ctx context.Context) error
        +TryAcquire() bool
    }

    class tokenBucketRateLimiter {
        -int rpm
        -time.Duration interval
        -chan structEmpty tokens
        -sync.Mutex mu
        -chan structEmpty stopCh
        -bool stopped
        +Wait(ctx context.Context) error
        +TryAcquire() bool
        +Stop()
        -refillTokens()
    }

    class openai {
        +*component.Base[Config, structEmpty] Base
        +text text
        +RateLimiter rateLimiter
    }

    class openaiText {
        +*component.Base[Config, structEmpty] Base
        +*oai.Client client
        +embeddingSpliter embeddingSpliter
        +RateLimiter rateLimiter
        +String(ctx context.Context, messages []string) (string, error)
        +Embedding(ctx context.Context, s string) ([]float32, error)
    }

    class gemini {
        +*component.Base[Config, structEmpty] Base
        +text text
        +*http.Client hc
        +RateLimiter rateLimiter
        +embeddingSpliter embeddingSpliter
        +WAV(ctx context.Context, text string, speakers []Speaker) (io.ReadCloser, error)
    }

    class NewRateLimiter {
        <<function>>
        +NewRateLimiter(rpm int) RateLimiter
    }

    RateLimiter <|.. noopRateLimiter
    RateLimiter <|.. tokenBucketRateLimiter

    NewRateLimiter ..> RateLimiter
    NewRateLimiter ..> tokenBucketRateLimiter

    openai o-- openaiText
    openaiText ..> RateLimiter
    gemini ..> RateLimiter

    Config <.. openai
    Config <.. openaiText
    Config <.. gemini

API 中 RSSHub 访问密钥与 AddFeedSource 端点的类图

classDiagram
    class API {
        <<interface>>
        +QueryRSSHubCategories(ctx context.Context, req *QueryRSSHubCategoriesRequest) (*QueryRSSHubCategoriesResponse, error)
        +QueryRSSHubWebsites(ctx context.Context, req *QueryRSSHubWebsitesRequest) (*QueryRSSHubWebsitesResponse, error)
        +QueryRSSHubRoutes(ctx context.Context, req *QueryRSSHubRoutesRequest) (*QueryRSSHubRoutesResponse, error)
        +AddFeedSource(ctx context.Context, req *AddFeedSourceRequest) (*AddFeedSourceResponse, error)
    }

    class api {
        +Config() *Config
        +Dependencies() *Dependencies
        +Reload(app *config.App) error
        +QueryRSSHubCategories(ctx context.Context, req *QueryRSSHubCategoriesRequest) (*QueryRSSHubCategoriesResponse, error)
        +QueryRSSHubWebsites(ctx context.Context, req *QueryRSSHubWebsitesRequest) (*QueryRSSHubWebsitesResponse, error)
        +QueryRSSHubRoutes(ctx context.Context, req *QueryRSSHubRoutesRequest) (*QueryRSSHubRoutesResponse, error)
        +AddFeedSource(ctx context.Context, req *AddFeedSourceRequest) (*AddFeedSourceResponse, error)
        -appendAccessKeyToURL(url string) string
    }

    API <|.. api

    class Config {
        +string RSSHubEndpoint
        +string RSSHubAccessKey
        +string LLM
        +Validate() error
        +From(app *config.App) *Config
    }

    class AddFeedSourceRequest {
        +config.ScrapeSource Source
    }

    class AddFeedSourceResponse {
    }

    class ScrapeSource {
        +string Name
        +*ScrapeSourceRSS RSS
    }

    class ScrapeSourceRSS {
        +string URL
        +string RSSHubRoutePath
    }

    class ConfigManager {
        +AppConfig() *config.App
        +SaveAppConfig(app *config.App) error
    }

    class Dependencies {
        +ConfigManager ConfigManager
    }

    api ..> Config
    api ..> Dependencies
    api ..> AddFeedSourceRequest
    AddFeedSourceRequest o-- ScrapeSource
    ScrapeSource o-- ScrapeSourceRSS
    Dependencies o-- ConfigManager

    class HTTPServer {
        +new(instance string, app *config.App, dependencies Dependencies) (Server, error)
    }

    HTTPServer ..> API

    class MCPServer {
        +registerFeedSourceTools()
        +addFeedSource(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error)
    }

    MCPServer ..> API
    MCPServer ..> AddFeedSourceRequest

File-Level Changes

Change Details Files
为每个 LLM 引入可配置的 RPM 限流,并将其集成到 OpenAI 和 Gemini 调用中。
  • 扩展 LLM 配置(YAML/JSON 以及工厂装配)以加入 RPM 字段,并在英文和中文配置文档中进行说明。
  • 实现基于令牌桶的 RateLimiter,对非正 RPM 采用 noop 行为,包含支持 context 的 Wait、TryAcquire、内部补充令牌 goroutine 和单元测试。
  • 在 OpenAI 与 Gemini 的 LLM 实现中注入 RateLimiter,并在聊天、Embedding 和 WAV/TTS 请求前调用 Wait()。
pkg/llm/llm.go
pkg/config/config.go
docs/config.md
docs/config-zh.md
pkg/llm/ratelimiter.go
pkg/llm/ratelimiter_test.go
pkg/llm/openai.go
pkg/llm/gemini.go
增加动态创建 RSS 源的 API,并通过 HTTP JSON-RPC 和 MCP 工具对外暴露。
  • 扩展 API 接口及其 mock,加入 AddFeedSource 的请求/响应类型。
  • 实现 AddFeedSource 处理函数,校验源字段、强制源名称唯一、更新内存中的应用抓取源,并通过 ConfigManager.SaveAppConfig 持久化,带有遥测和错误映射。
  • 注册新的 /add_feed_source HTTP JSON-RPC 路由,并转发到 API 处理函数。
  • 注册 MCP 工具 add_feed_source,支持参数 (name, url, rsshub_route_path),实现 MCP 处理函数:校验参数、构造 ScrapeSource、调用 API.AddFeedSource,并返回成功消息。
pkg/api/api.go
pkg/api/http/http.go
pkg/api/mcp/mcp.go
修复 RSSHub 调用,确保在所有 API 请求中正确携带已配置的访问密钥。
  • 在 API Config 中加入 RSSHubAccessKey,并从 app.Scrape.RSSHubAccessKey 中加载。
  • 新增辅助函数 appendAccessKeyToURL,根据 URL 是否已经包含查询参数,条件性地追加 ?key= 或 &key=。
  • 在 QueryRSSHubCategories、QueryRSSHubWebsites 和 QueryRSSHubRoutes 中使用 appendAccessKeyToURL,以便在设置访问密钥时,所有 RSSHub 端点都附带该密钥。
pkg/api/api.go
防止在 Labels.MarshalJSON 中重用内部 bytes 缓冲区导致输出损坏。
  • 修改 Labels.MarshalJSON,在返回前将累积的字节拷贝到新的切片中,避免返回池化缓冲区带来的问题。
pkg/model/model.go

Tips and commands

与 Sourcery 交互

  • 触发一次新的审查: 在 Pull Request 中评论 @sourcery-ai review。
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub Issue: 在某条审查评论下回复,请求 Sourcery 从该评论创建一个 issue。你也可以直接回复 @sourcery-ai issue 来从该评论创建 issue。
  • 生成 Pull Request 标题: 在 Pull Request 标题中任意位置写 @sourcery-ai 即可随时生成标题。也可以在 Pull Request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 Pull Request 摘要: 在 Pull Request 正文任意位置写 @sourcery-ai summary,即可在该位置生成 PR 摘要。也可以评论 @sourcery-ai summary 来随时(重新)生成摘要。
  • 生成审查者指南: 在 Pull Request 中评论 @sourcery-ai guide,即可随时(重新)生成审查者指南。
  • 一次性解决所有 Sourcery 评论: 在 Pull Request 中评论 @sourcery-ai resolve,即可将所有 Sourcery 评论标记为已解决。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 忽略所有 Sourcery 审查: 在 Pull Request 中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审查。特别适合希望基于新一轮审查重新开始的场景——别忘了再评论 @sourcery-ai review 来触发新的审查!

自定义你的使用体验

前往你的 控制台 以:

  • 启用或禁用审查特性,例如 Sourcery 生成的 Pull Request 摘要、审查者指南等。
  • 更改审查语言。
  • 添加、移除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

  • 如有问题或反馈,请联系支持团队。
  • 访问我们的文档以获取详细指南和信息。
  • 通过关注我们的 X/Twitter、LinkedIn 或 GitHub 与 Sourcery 团队保持联系。
Original review guide in English

Reviewer's Guide

Implements token-bucket RPM rate limiting for LLM providers, adds a new API/HTTP/MCP interface for dynamically adding RSS feed sources, fixes RSSHub access-key handling in all RSSHub queries, and corrects a JSON marshaling bug in Labels by copying the buffer before reuse, along with corresponding config and docs updates.

Sequence diagram for the new add_feed_source MCP and API flow

sequenceDiagram
    actor User
    participant MCPClient
    participant MCPServer as MCPServer_server
    participant API as API_impl
    participant ConfigMgr as ConfigManager

    User->>MCPClient: Configure add_feed_source tool call
    MCPClient->>MCPServer: callTool add_feed_source(name, url|rsshub_route_path)
    MCPServer->>MCPServer: addFeedSource validate arguments
    MCPServer->>API: AddFeedSource(AddFeedSourceRequest)
    API->>API: Validate Source (name, RSS, URL vs RSSHubRoutePath)
    API->>ConfigMgr: AppConfig()
    ConfigMgr-->>API: AppConfig with Scrape.Sources
    API->>API: Check duplicate source name
    API->>ConfigMgr: SaveAppConfig(updated AppConfig)
    ConfigMgr-->>API: Save result
    API-->>MCPServer: AddFeedSourceResponse
    MCPServer-->>MCPClient: CallToolResult "Feed source added successfully"
    MCPClient-->>User: Display success message

Class diagram for LLM rate limiting and provider integration

classDiagram
    class Config {
        +string Provider
        +string APIKey
        +string Model
        +string EmbeddingModel
        +string TTSModel
        +float32 Temperature
        +int RPM
    }

    class RateLimiter {
        <<interface>>
        +Wait(ctx context.Context) error
        +TryAcquire() bool
    }

    class noopRateLimiter {
        +Wait(ctx context.Context) error
        +TryAcquire() bool
    }

    class tokenBucketRateLimiter {
        -int rpm
        -time.Duration interval
        -chan structEmpty tokens
        -sync.Mutex mu
        -chan structEmpty stopCh
        -bool stopped
        +Wait(ctx context.Context) error
        +TryAcquire() bool
        +Stop()
        -refillTokens()
    }

    class openai {
        +*component.Base[Config, structEmpty] Base
        +text text
        +RateLimiter rateLimiter
    }

    class openaiText {
        +*component.Base[Config, structEmpty] Base
        +*oai.Client client
        +embeddingSpliter embeddingSpliter
        +RateLimiter rateLimiter
        +String(ctx context.Context, messages []string) (string, error)
        +Embedding(ctx context.Context, s string) ([]float32, error)
    }

    class gemini {
        +*component.Base[Config, structEmpty] Base
        +text text
        +*http.Client hc
        +RateLimiter rateLimiter
        +embeddingSpliter embeddingSpliter
        +WAV(ctx context.Context, text string, speakers []Speaker) (io.ReadCloser, error)
    }

    class NewRateLimiter {
        <<function>>
        +NewRateLimiter(rpm int) RateLimiter
    }

    RateLimiter <|.. noopRateLimiter
    RateLimiter <|.. tokenBucketRateLimiter

    NewRateLimiter ..> RateLimiter
    NewRateLimiter ..> tokenBucketRateLimiter

    openai o-- openaiText
    openaiText ..> RateLimiter
    gemini ..> RateLimiter

    Config <.. openai
    Config <.. openaiText
    Config <.. gemini

Class diagram for API RSSHub access key and AddFeedSource endpoint

classDiagram
    class API {
        <<interface>>
        +QueryRSSHubCategories(ctx context.Context, req *QueryRSSHubCategoriesRequest) (*QueryRSSHubCategoriesResponse, error)
        +QueryRSSHubWebsites(ctx context.Context, req *QueryRSSHubWebsitesRequest) (*QueryRSSHubWebsitesResponse, error)
        +QueryRSSHubRoutes(ctx context.Context, req *QueryRSSHubRoutesRequest) (*QueryRSSHubRoutesResponse, error)
        +AddFeedSource(ctx context.Context, req *AddFeedSourceRequest) (*AddFeedSourceResponse, error)
    }

    class api {
        +Config() *Config
        +Dependencies() *Dependencies
        +Reload(app *config.App) error
        +QueryRSSHubCategories(ctx context.Context, req *QueryRSSHubCategoriesRequest) (*QueryRSSHubCategoriesResponse, error)
        +QueryRSSHubWebsites(ctx context.Context, req *QueryRSSHubWebsitesRequest) (*QueryRSSHubWebsitesResponse, error)
        +QueryRSSHubRoutes(ctx context.Context, req *QueryRSSHubRoutesRequest) (*QueryRSSHubRoutesResponse, error)
        +AddFeedSource(ctx context.Context, req *AddFeedSourceRequest) (*AddFeedSourceResponse, error)
        -appendAccessKeyToURL(url string) string
    }

    API <|.. api

    class Config {
        +string RSSHubEndpoint
        +string RSSHubAccessKey
        +string LLM
        +Validate() error
        +From(app *config.App) *Config
    }

    class AddFeedSourceRequest {
        +config.ScrapeSource Source
    }

    class AddFeedSourceResponse {
    }

    class ScrapeSource {
        +string Name
        +*ScrapeSourceRSS RSS
    }

    class ScrapeSourceRSS {
        +string URL
        +string RSSHubRoutePath
    }

    class ConfigManager {
        +AppConfig() *config.App
        +SaveAppConfig(app *config.App) error
    }

    class Dependencies {
        +ConfigManager ConfigManager
    }

    api ..> Config
    api ..> Dependencies
    api ..> AddFeedSourceRequest
    AddFeedSourceRequest o-- ScrapeSource
    ScrapeSource o-- ScrapeSourceRSS
    Dependencies o-- ConfigManager

    class HTTPServer {
        +new(instance string, app *config.App, dependencies Dependencies) (Server, error)
    }

    HTTPServer ..> API

    class MCPServer {
        +registerFeedSourceTools()
        +addFeedSource(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error)
    }

    MCPServer ..> API
    MCPServer ..> AddFeedSourceRequest

File-Level Changes

Change Details Files
Introduce configurable per-LLM RPM rate limiting and integrate it into OpenAI and Gemini calls.
  • Extend LLM config (YAML/JSON and factory wiring) with an RPM field and document it in both English and Chinese config docs.
  • Implement a token-bucket-based RateLimiter with noop behavior for non-positive RPM, including context-aware Wait, TryAcquire, internal refill goroutine, and unit tests.
  • Inject a RateLimiter into OpenAI and Gemini LLM implementations and call Wait() before chat, embedding, and WAV/TTS requests.
pkg/llm/llm.go
pkg/config/config.go
docs/config.md
docs/config-zh.md
pkg/llm/ratelimiter.go
pkg/llm/ratelimiter_test.go
pkg/llm/openai.go
pkg/llm/gemini.go
Add a dynamic RSS feed source creation API and expose it via HTTP JSON-RPC and MCP tool.
  • Extend the API interface and mock with AddFeedSource request/response types.
  • Implement AddFeedSource handler to validate source fields, enforce name uniqueness, update the in-memory app scrape sources, and persist via ConfigManager.SaveAppConfig with telemetry and error mapping.
  • Register a new /add_feed_source HTTP JSON-RPC route that forwards to the API handler.
  • Register an MCP tool add_feed_source with arguments (name, url, rsshub_route_path) and implement the MCP handler that validates arguments, builds a ScrapeSource, calls API.AddFeedSource, and returns a success message.
pkg/api/api.go
pkg/api/http/http.go
pkg/api/mcp/mcp.go
Fix RSSHub calls to correctly include the configured access key on all API requests.
  • Extend API Config with RSSHubAccessKey and hydrate it from app.Scrape.RSSHubAccessKey.
  • Add appendAccessKeyToURL helper that conditionally appends ?key= or &key= depending on whether the URL already has query parameters.
  • Use appendAccessKeyToURL for QueryRSSHubCategories, QueryRSSHubWebsites, and QueryRSSHubRoutes so all RSSHub endpoints include the access key when set.
pkg/api/api.go
Prevent reuse of an internal bytes buffer in Labels.MarshalJSON that could lead to corrupted output.
  • Change Labels.MarshalJSON to copy the accumulated bytes into a new slice before returning, avoiding issues with returning a pooled buffer.
pkg/model/model.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an issue from a review comment by replying to it. You can also reply to a review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull request title to generate a title at any time. You can also comment @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment @sourcery-ai summary on the pull request to (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the pull request to resolve all Sourcery comments. Useful if you've already addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull request to dismiss all existing Sourcery reviews. Especially useful if you want to start fresh with a new review - don't forget to comment @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

  • Contact our support team for questions or feedback.
  • Visit our documentation for detailed guides and information.
  • Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.

sourcery-ai[bot] avatar Jan 04 '26 14:01 sourcery-ai[bot]

关于客户端限流的‘必要性’,有什么具体场景吗?

glidea avatar Jan 06 '26 03:01 glidea

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Regarding the ‘necessity’ of client-side current limiting, are there any specific scenarios?

Issues-translate-bot avatar Jan 06 '26 03:01 Issues-translate-bot

关于客户端限流的‘必要性’,有什么具体场景吗?

之前用阿里云百炼的 deepseek-v3.2 不到10分钟干完了免费的 一百万token 。

然后我换成用薄荷大佬的公益api,他的RPM只有3,但是免费 (狗头

对于公益大模型来说,RPM限制还是挺有用的,如果一直请求对方服务器,像是ddos对方服务器一样。 或者对于各种免费的 2api 来说,并发太高会有封号风险。

Twelveeee avatar Jan 06 '26 07:01 Twelveeee

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Regarding the ‘necessity’ of client-side current limiting, are there any specific scenarios?

Previously, I used Alibaba Cloud Bailian's deepseek-v3.2 to complete the free one million tokens in less than 10 minutes.

Then I switched to using the public welfare API of Mint Boss. His RPM is only 3, but it is free.

For large public welfare models, RPM limits are quite useful. If you keep requesting the other party's server, it is like ddos the other party's server. Or for various free APIs, if the concurrency is too high, there is a risk of account closure.

Issues-translate-bot avatar Jan 06 '26 07:01 Issues-translate-bot