MCPcopy Create free account

hub / github.com/123hi123/qwen2api-rs / functions

Functions435 in github.com/123hi123/qwen2api-rs

↓ 2 callersMethodcreate_chat
建立會話 POST /api/v2/chats/new → chat_id。
src/upstream/client.rs:195
↓ 2 callersMethoddb_path
(&self)
src/stats.rs:97
↓ 2 callersFunctiondetect_profile
由 headers + body 推測客戶端 profile。
src/request/client_profiles.rs:13
↓ 2 callersFunctiondownload_to_local
下載媒體 URL 到本地,回傳檔名(失敗回 None)。經 QwenClient 的 reqwest(含出口代理)。
src/media.rs:229
↓ 2 callersFunctionextract_api_token
從 headers / query 取出 API key:Authorization: Bearer → x-api-key → ?key/?api_key。
src/auth.rs:33
↓ 2 callersFunctionextract_upstream_error
偵測上游明確 JSON 錯誤({"success":false} 或 {"error":...}),回錯誤訊息。
src/upstream/sse.rs:114
↓ 2 callersFunctionfillMsgInner
(inner, m, typing)
web/app.js:1304
↓ 2 callersFunctionfind_subslice
(haystack: &[u8], needle: &[u8])
src/toolcall/mod.rs:223
↓ 2 callersFunctionfind_tool_blocks
找出 text 內所有 tool_call 區塊(含 `<tool_call>...</tool_call>` 與 ```` ``` 圍欄)。 回傳 (整個區塊起始位置, 整個區塊結束後位置, 內部 JSON 區域起始, 結束)。 - 結束位置考慮三種: 1. `</tool_call>` / `\
src/toolcall/mod.rs:181
↓ 2 callersFunctiongetKey
读取当前会话 Key(默认 admin)
web/app.js:16
↓ 2 callersMethodhas_tools
(&self)
src/request/standard.rs:40
↓ 2 callersMethodinit_runtime
載入後初始化執行期欄位(serde skip 的欄位不會自動設對)。
src/account/account.rs:81
↓ 2 callersMethodinsert_done
直接插入一筆已完成任務(給同步 API 的本地備份用,狀態 done 不會被 worker 重生)。
src/media.rs:408
↓ 2 callersMethodis_rate_limited
(&self)
src/account/account.rs:93
↓ 2 callersFunctionis_textual
(content_type: &str, filename: &str)
src/context/mod.rs:28
↓ 2 callersFunctionjwt_exp
解 chat.qwen.ai web JWT 的 exp 欄位(unix 秒),失敗回 None。 不驗簽(驗簽密鑰只有 Qwen 後端有)——僅用於 client 端時序判定(refresh 排程、過期分桶等)。
src/util.rs:9
↓ 2 callersMethodlist_models
列出上游模型 GET /api/models → data 陣列。
src/upstream/client.rs:178
↓ 2 callersFunctionloadKeys
()
web/app.js:988
↓ 2 callersMethodmark_rate_limited
標記限流(指數退避冷卻)。
src/account/pool.rs:588
↓ 2 callersFunctionmediaTag
依 URL 判斷圖片或影片,產生對應標籤
web/app.js:1344
↓ 2 callersFunctionmessages_to_prompt
主流程:messages → prompt。extra_context 為附件內聯文字(插在 Assistant: 之前)。
src/request/prompt_builder.rs:143
↓ 2 callersFunctionnormalize_tools
將 OpenAI / Anthropic 工具定義正規化。
src/toolcall/mod.rs:32
↓ 2 callersMethodopen_block
(&mut self, out: &mut Vec<String>, kind: Block)
src/execution/presenter.rs:71
↓ 2 callersFunctionparse_data_uri
解析 data: URI → (content_type, bytes)。
src/context/mod.rs:45
↓ 2 callersFunctionparse_naked_one
(json_str: &str, registry: &HashMap<String, String>)
src/toolcall/mod.rs:288
↓ 2 callersMethodpartial_cmp
(&self, other: &Self)
src/account/pool.rs:40
↓ 2 callersFunctionprepare_attachments
主入口:預處理附件。無附件時極快返回。
src/context/mod.rs:120
↓ 2 callersFunctionread_json_or
讀取 JSON 檔;失敗回 default。
src/db.rs:27
↓ 2 callersMethodrelease
釋放帳號。
src/account/pool.rs:570
↓ 2 callersFunctionrenderMediaPage
媒体页:任务队列 + 画廊(图片/影片共用)
web/app.js:1371
↓ 2 callersMethodsave
將目前記憶體值寫回磁碟。
src/db.rs:99
↓ 2 callersMethodsave_api_keys
持久化 api_keys 到磁碟。
src/state.rs:115
↓ 2 callersFunctionsetKey
写入会话 Key
web/app.js:20
↓ 2 callersFunctionsetMode
(think)
web/app.js:1098
↓ 2 callersMethodspawn_refill
對指定帳號補滿至 target(背景任務)。以 pending 佔位避免並發過量;用傳入 token,不查帳號池。
src/upstream/chat_id_pool.rs:128
↓ 2 callersMethodstart
啟動背景 dispatcher(在 main 內以 state clone 呼叫,避免 Arc 循環)。
src/media.rs:561
↓ 2 callersFunctionstrip_tool_calls_with
同 `strip_tool_calls`,但帶 registry 以啟用裸 JSON 剝離。傳空 registry 等同舊行為。
src/toolcall/mod.rs:355
↓ 2 callersMethodtarget
(&self)
src/upstream/chat_id_pool.rs:66
↓ 2 callersFunctionto_qwen_name
工具名稱混淆,對應 Python `services/tool_name_obfuscation.py`。 將客戶端工具名映射成 Qwen 不會攔截的安全別名,並可反向還原。 客戶端名 → Qwen 安全名。
src/toolcall/obfuscation.rs:5
↓ 2 callersMethodtoken_of
取得某帳號的 token(依 email)。
src/account/pool.rs:325
↓ 2 callersMethodttl
(&self)
src/upstream/chat_id_pool.rs:69
↓ 2 callersFunctionwrite_json_atomic
原子寫入任意可序列化值到 JSON 檔(臨時檔 + rename)。
src/db.rs:11
↓ 2 callersMethodwrite_to_disk
(&self, value: &T)
src/db.rs:104
↓ 2 callersFunctionyAt
(v)
web/app.js:586
↓ 1 callersFunctionaccStatusBadge
(code)
web/app.js:694
↓ 1 callersFunctionaccStatusCn
(code)
web/app.js:690
↓ 1 callersMethodacquire
取一個未過期的預熱 chat_id(pop);過期的丟棄並背景刪除(用傳入 token)。 取用後立即 spawn 回補(命中與未命中皆補)以維持水位、跟隨熱帳號。
src/upstream/chat_id_pool.rs:84
↓ 1 callersMethodacquire_indexed
Ready-Set 選號(攤銷 ~O(1))。
src/account/pool.rs:442
↓ 1 callersMethodacquire_scan
舊版 O(n) 掃描選號(POOL_READY_INDEX=0 時使用;亦作為測試 oracle)。
src/account/pool.rs:391
↓ 1 callersFunctionadmin_router
()
src/main.rs:29
↓ 1 callersMethodall_emails_tokens
所有可用帳號 (email, token)(給預熱池 bootstrap 用)。
src/account/pool.rs:788
↓ 1 callersMethodany_valid_account
取得任一可用帳號 (email, token)(用於檔案上傳並綁定後續對話)。
src/account/pool.rs:341
↓ 1 callersFunctionapiPoolCard
静态 API 接口池卡片
web/app.js:400
↓ 1 callersMethodapply_config
(&self, target: Option<usize>, ttl_seconds: Option<u64>)
src/upstream/chat_id_pool.rs:73
↓ 1 callersFunctionbindMobileNav
()
web/app.js:1794
↓ 1 callersFunctionbuildExamplesCard
()
web/app.js:1746
↓ 1 callersFunctionbuild_anthropic_message
Anthropic Messages(非串流)。
src/execution/formatters.rs:50
↓ 1 callersFunctionbuild_gemini_generate
Gemini generateContent(非串流)。
src/execution/formatters.rs:83
↓ 1 callersFunctionbuild_gemini_request
Gemini generateContent → StandardRequest。把 Gemini body 轉成內部 openai-ish body 再壓平。
src/request/mod.rs:69
↓ 1 callersFunctionbuild_openai_completion
OpenAI chat.completion(非串流)。
src/execution/formatters.rs:10
↓ 1 callersFunctionbuild_openai_model_list
建立 OpenAI 風格模型列表。upstream 為 /api/models 的 data 陣列。
src/request/model_catalog.rs:40
↓ 1 callersFunctionbuild_registry
建立 qwen_name(正規化) → 原始名 的反向註冊表。
src/toolcall/mod.rs:70
↓ 1 callersFunctionbuild_response_object
(id: &str, model: &str, text: &str, usage: &execution::Usage)
src/api/responses.rs:81
↓ 1 callersFunctionbuild_stream_params
(std: &StandardRequest, image_options: Option<ImageOptions>)
src/execution/mod.rs:73
↓ 1 callersFunctionbuild_tool_instruction_block
建立工具指令塊(注入 prompt)。
src/toolcall/mod.rs:90
↓ 1 callersFunctioncapsLabel
(caps)
web/app.js:1146
↓ 1 callersMethodchat_type
(&self)
src/media.rs:35
↓ 1 callersFunctioncheck_consistency
驗證索引與帳號真實狀態一致(min_interval=0 時為時間穩定不變式)。
src/account/pool.rs:1052
↓ 1 callersFunctioncollect_attachments
掃描 body.messages 收集所有附件。
src/context/mod.rs:103
↓ 1 callersMethodcomplete
(&self, id: i64, results: Value, attempts: u32)
src/media.rs:379
↓ 1 callersMethodconcurrency_config
目前並發設定 (max_inflight_per_account, global_max_inflight, max_queue_size)。
src/account/pool.rs:782
↓ 1 callersFunctioncount_tokens
POST .../messages/count_tokens(開放,不需認證)。回 input_tokens(×1.35 提前觸發壓縮)。
src/api/anthropic.rs:69
↓ 1 callersMethodcreate_task
建立排隊中的任務,回傳 task id。
src/media.rs:308
↓ 1 callersFunctioncurrentRoute
()
web/app.js:157
↓ 1 callersMethoddefault_ext
(&self)
src/media.rs:54
↓ 1 callersFunctiondefault_model_map
預設模型別名映射(對應 Python MODEL_MAP)。下游傳入的模型名 → Qwen 實際 base model。 注意:上游現役旗艦已是 qwen3.7-plus(見 dev/UPSTREAM.md),故預設指向之。
src/config.rs:184
↓ 1 callersMethoddelete
(&self, file_id: &str)
src/context/file_store.rs:61
↓ 1 callersMethoddelete_chat_reliable
帶有限重試的刪除。
src/upstream/client.rs:276
↓ 1 callersFunctiondoSearch
()
web/app.js:759
↓ 1 callersMethodensure_started
(&mut self, out: &mut Vec<String>)
src/execution/presenter.rs:42
↓ 1 callersFunctionextract_capabilities
由 capabilities + chat_type 列表合成能力旗標(鍵對齊前端 Test 頁)。
src/request/model_catalog.rs:13
↓ 1 callersFunctionextract_from_part
從一個 content part 抽出附件(若有)。
src/context/mod.rs:59
↓ 1 callersFunctionextract_reasoning_cumulative
從 extra.summary_thought.content(陣列)join 出累積思考文字。
src/upstream/sse.rs:52
↓ 1 callersFunctionextract_reasoning_incremental
從 delta 抓舊格式增量 reasoning。
src/upstream/sse.rs:32
↓ 1 callersFunctionextract_system_prompt
從 OpenAI/Anthropic 風格 body 取出 system prompt 文字。
src/request/prompt_builder.rs:85
↓ 1 callersFunctionextract_thinking
從 body 萃取思考開關(對應 build_chat_standard_request 的 _extract_thinking_enabled)。
src/request/mod.rs:45
↓ 1 callersMethodfail
(&self, id: i64, error: &str, attempts: u32)
src/media.rs:393
↓ 1 callersFunctionfallback_model_list
無法取得上游時的 fallback。
src/request/model_catalog.rs:80
↓ 1 callersFunctionfetch_upstream_models
取得(快取的)上游模型列表。
src/api/models.rs:18
↓ 1 callersFunctionfirst_text
(values: &[Option<&Value>])
src/upstream/sse.rs:20
↓ 1 callersFunctionformat_upstream_error
(obj: &Value)
src/upstream/sse.rs:152
↓ 1 callersFunctionguess_ext
(url: &str, kind: MediaKind)
src/media.rs:257
↓ 1 callersFunctioninit_schema
(path: &Path)
src/media.rs:491
↓ 1 callersFunctioninit_schema
(path: &Path)
src/stats.rs:116
↓ 1 callersFunctioninsert_batch
(conn: &mut Connection, batch: &[RequestRecord])
src/stats.rs:171
↓ 1 callersFunctionlast_user_text
取最後一則 user 訊息的純文字(影像/影片生成用)。
src/request/mod.rs:18
↓ 1 callersMethodlist
列出最近任務(含結果),供前端畫廊渲染。
src/media.rs:436
↓ 1 callersMethodload
載入檔案;不存在或解析失敗則用 default,並寫回一份。
src/db.rs:48
↓ 1 callersFunctionmarkRange
()
web/app.js:472
↓ 1 callersMethodmark_success
標記成功(清失敗計數、限流→可用)。
src/account/pool.rs:651
← previousnext →101–200 of 435, ranked by callers