feat: 添加账号池管理功能并更新文档
- 在convert.js中为工具调用添加index字段支持 - 在common.js中添加fullOldResponseJson变量用于调试 - 更新README文档,添加账号池管理功能说明和快速导航 - 同步更新英文版README文档
This commit is contained in:
parent
71fc06ad91
commit
7b0aee7959
4 changed files with 53 additions and 4 deletions
24
README-EN.md
24
README-EN.md
|
|
@ -39,9 +39,25 @@
|
|||
* ✅ **Bypass Official Restrictions**: By supporting Gemini CLI's OAuth authorization method, it effectively circumvents the rate and quota limits of official free APIs, granting you higher request quotas and usage frequency.
|
||||
* ✅ **Bypass Client Restrictions**: Kiro API mode supports free usage of the Claude Sonnet 4 model.
|
||||
* ✅ **Seamless OpenAI Compatibility**: Provides an interface fully compatible with the OpenAI API, enabling your existing toolchains and clients (e.g., LobeChat, NextChat) to integrate all supported models at zero cost.
|
||||
* ✅ **Intelligent Account Pool Management**: Supports multi-account polling, failover, and configuration degradation, ensuring high service availability and effectively avoiding single account limitations.
|
||||
* ✅ **Enhanced Controllability**: Powerful logging features allow you to capture and record all request prompts, facilitating auditing, debugging, and building private datasets.
|
||||
* ✅ **Extremely Easy to Extend**: Thanks to the new modular and strategy pattern design, adding a new model provider has never been simpler.
|
||||
* ✅ **Comprehensive Test Coverage**: Provides extensive integration and unit tests, ensuring the stability and reliability of all API endpoints and features.
|
||||
* ✅ **Docker Support**: Provides complete Docker containerization support for rapid deployment and environment isolation.
|
||||
|
||||
---
|
||||
|
||||
## 📑 Quick Navigation
|
||||
|
||||
- [🎨 Model Protocol and Provider Relationship Diagram](#-model-protocol-and-provider-relationship-diagram)
|
||||
- [🔧 Usage Instructions](#-usage-instructions)
|
||||
- [💻 Proxy Settings](#-proxy-settings)
|
||||
- [🌟 Special Usage & Advanced Tips](#-special-usage--advanced-tips)
|
||||
- [🐳 Docker Deployment](#-docker-deployment)
|
||||
- [🚀 Project Startup Parameters](#-project-startup-parameters)
|
||||
- [📄 Open Source License](#-open-source-license)
|
||||
- [🙏 Acknowledgements](#-acknowledgements)
|
||||
- [⚠️ Disclaimer](#-disclaimer)
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -96,7 +112,7 @@
|
|||
* **Multimodal Capabilities**: Supports multimodal inputs like images and documents, offering a richer interactive experience.
|
||||
* **Latest Model Support**: Supports the latest **Kimi K2**, **GLM-4.5** and **Qwen Code** models. Simply configure the corresponding OpenAI or Claude compatible interfaces in `config.json` for use.
|
||||
* **Qwen Code Support**: Using Qwen Code will automatically open an authorization page in the browser. After completing authorization, it will generate an `oauth_creds.json` file in the `~/.qwen` directory. Please use the official default parameters temperature=0 and top_p=1.
|
||||
* **Kiro API**: Using the Kiro API requires [downloading the Kiro client](https://aibook.ren/archives/kiro-install) and completing authorized login to generate `kiro-auth-token.json`. **Recommended for optimal experience with Claude Code**. Note: New users who encounter **429** errors when using the service indicate that the Kiro service is **no longer available**, and may need to wait until Kiro fully opens registration before being able to use it.
|
||||
* **Kiro API**: Using the Kiro API requires [downloading the Kiro client](https://aibook.ren/archives/kiro-install) and completing authorized login to generate `kiro-auth-token.json`. **Recommended for optimal experience with Claude Code**. Note: Kiro service policy has been adjusted, please check official announcements for specific usage limitations.
|
||||
* **Using Different Providers in Claude Code**: Via Path routing, you can use different providers in Claude-related API calls:
|
||||
* `http://localhost:3000/claude-custom` - Use the Claude API provider defined in the configuration file
|
||||
* `http://localhost:3000/claude-kiro-oauth` - Access the Claude API using Kiro OAuth authentication
|
||||
|
|
@ -204,6 +220,12 @@ These settings are effective only for the current PowerShell session. For perman
|
|||
* **Response Caching**: Implement caching logic for frequently repeated queries to reduce API calls and enhance response speed.
|
||||
* **Custom Content Filtering**: Introduce keyword filtering or content review logic before sending or returning requests to ensure compliance.
|
||||
|
||||
* **🎯 Advanced Account Pool Configuration**:
|
||||
* **Multi-Account Management**: Configure multiple accounts for each provider through the `provider_pools.json` file, enabling intelligent polling.
|
||||
* **Failover**: When an account becomes unavailable, the system automatically switches to the next available account, ensuring service continuity.
|
||||
* **Configuration Degradation**: Dynamically adjust configuration parameters based on account status to optimize resource usage efficiency.
|
||||
* **Usage Example**: Refer to the `provider_pools.json` configuration file in the project to easily set up a multi-account environment.
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Project Startup Parameters
|
||||
|
|
|
|||
24
README.md
24
README.md
|
|
@ -40,9 +40,25 @@
|
|||
* ✅ **突破官方限制**:通过支持 Gemini CLI 的 OAuth 授权方式,有效绕过官方免费 API 的速率和配额限制,让您享受更高的请求额度和使用频率。
|
||||
* ✅ **突破客户端限制**:Kiro API 模式下支持免费使用Claude Sonnet 4 模型。
|
||||
* ✅ **无缝兼容 OpenAI**:提供与 OpenAI API 完全兼容的接口,让您现有的工具链和客户端(如 LobeChat, NextChat 等)可以零成本接入所有支持的模型。
|
||||
* ✅ **账号池智能管理**:支持多账号轮询、故障转移和配置降级,确保服务高可用性,有效避免单一账号的限制问题。
|
||||
* ✅ **增强的可控性**:通过强大的日志功能,可以捕获并记录所有请求的提示词(Prompts),便于审计、调试和构建私有数据集。
|
||||
* ✅ **极易扩展**:得益于全新的模块化和策略模式设计,添加一个新的模型服务商变得前所未有的简单。
|
||||
* ✅ **完整测试覆盖**:提供全面的集成测试和单元测试,确保各个API端点和功能的稳定性和可靠性。
|
||||
* ✅ **Docker支持**:提供完整的Docker容器化支持,支持快速部署和环境隔离。
|
||||
|
||||
---
|
||||
|
||||
## 📑 快速导航
|
||||
|
||||
- [🎨 模型协议与提供商关系图](#-模型协议与提供商关系图)
|
||||
- [🔧 使用说明](#-使用说明)
|
||||
- [💻 代理设置](#-代理设置)
|
||||
- [🌟 特殊用法与进阶技巧](#-特殊用法与进阶技巧)
|
||||
- [🐳 Docker 部署](#-docker-部署)
|
||||
- [🚀 项目启动参数](#-项目启动参数)
|
||||
- [📄 开源许可](#-开源许可)
|
||||
- [🙏 致谢](#-致谢)
|
||||
- [⚠️ 免责声明](#-免责声明)
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -100,7 +116,7 @@ claude-kiro-oauth 和 openai-qwen-oauth。
|
|||
* **多模态能力**: 支持图片、文档等多模态输入,为您提供更丰富的交互体验。
|
||||
* **最新模型支持**: 支持最新的 **Kimi K2**、**GLM-4.5** 和 **Qwen Code** 模型,只需在 `config.json` 中配置相应的 OpenAI 或 Claude 兼容接口即可使用。
|
||||
* **Qwen Code 支持**: 使用 Qwen Code 会自动在浏览器打开授权页面,完成授权后会在 `~/.qwen` 目录下生成 `oauth_creds.json` 文件。请使用官方默认参数 temperature=0 , top_p=1。
|
||||
* **Kiro API**: 使用 Kiro API 需要[下载kiro客户端](https://aibook.ren/archives/kiro-install)并完成授权登录生成 kiro-auth-token.json。**推荐配合 Claude Code 使用以获得最佳体验**。注意:新注册的用户,如果使用时报**429**,表示**已不可使用** Kiro 的服务,可能需要等Kiro完全开放注册后,才能使用。
|
||||
* **Kiro API**: 使用 Kiro API 需要[下载kiro客户端](https://aibook.ren/archives/kiro-install)并完成授权登录生成 kiro-auth-token.json。**推荐配合 Claude Code 使用以获得最佳体验**。注意:Kiro服务政策已调整,具体使用限制请查看官方公告。
|
||||
* **Claude Code 中使用不同供应商**: 通过 Path 路由或环境变量,您可以在 Claude 相关的 API 调用中使用不同的供应商:
|
||||
* `http://localhost:3000/claude-custom` - 使用配置文件中定义的 Claude API 供应商
|
||||
* `http://localhost:3000/claude-kiro-oauth` - 使用 Kiro OAuth 认证方式访问 Claude API
|
||||
|
|
@ -209,6 +225,12 @@ $env:HTTP_PROXY="http://your_proxy_address:port"
|
|||
* **响应缓存**: 对高频重复问题添加缓存逻辑,降低 API 调用,提升响应速度。
|
||||
* **自定义内容过滤**: 在请求发送或返回前增加关键词过滤或内容审查逻辑,满足合规要求。
|
||||
|
||||
* **🎯 账号池高级配置**:
|
||||
* **多账号管理**: 通过配置 `provider_pools.json` 文件,可以为每个提供商配置多个账号,实现智能轮询。
|
||||
* **故障转移**: 当某个账号失效时,系统会自动切换到下一个可用账号,确保服务连续性。
|
||||
* **配置降级**: 支持根据账号状态动态调整配置参数,优化资源使用效率。
|
||||
* **使用示例**: 参考项目中的 `provider_pools.json` 配置文件,轻松设置多账号环境。
|
||||
|
||||
---
|
||||
|
||||
## 🚀 项目启动参数
|
||||
|
|
|
|||
|
|
@ -203,6 +203,7 @@ export async function handleUnifiedResponse(res, responsePayload, isStream) {
|
|||
export async function handleStreamRequest(res, service, model, requestBody, fromProvider, toProvider, PROMPT_LOG_MODE, PROMPT_LOG_FILENAME, providerPoolManager, pooluuid) {
|
||||
let fullResponseText = '';
|
||||
let fullResponseJson = '';
|
||||
let fullOldResponseJson = '';
|
||||
let responseClosed = false;
|
||||
|
||||
await handleUnifiedResponse(res, '', true);
|
||||
|
|
@ -235,6 +236,7 @@ export async function handleStreamRequest(res, service, model, requestBody, from
|
|||
// console.log(`event: ${chunkToSend.type}\n`);
|
||||
}
|
||||
|
||||
// fullOldResponseJson += JSON.stringify(nativeChunk)+"\n";
|
||||
// fullResponseJson += JSON.stringify(chunkToSend)+"\n";
|
||||
res.write(`data: ${JSON.stringify(chunkToSend)}\n\n`);
|
||||
// console.log(`data: ${JSON.stringify(chunkToSend)}\n`);
|
||||
|
|
@ -265,6 +267,7 @@ export async function handleStreamRequest(res, service, model, requestBody, from
|
|||
res.end();
|
||||
}
|
||||
await logConversation('output', fullResponseText, PROMPT_LOG_MODE, PROMPT_LOG_FILENAME);
|
||||
// fs.writeFile('oldResponse'+Date.now()+'.json', fullOldResponseJson);
|
||||
// fs.writeFile('response'+Date.now()+'.json', fullResponseJson);
|
||||
}
|
||||
}
|
||||
|
|
@ -379,6 +382,7 @@ export async function handleContentGenerationRequest(req, res, service, endpoint
|
|||
|
||||
// 1. Convert request body from client format to backend format, if necessary.
|
||||
let processedRequestBody = originalRequestBody;
|
||||
// fs.writeFile('originalRequestBody'+Date.now()+'.json', JSON.stringify(originalRequestBody));
|
||||
if (getProtocolPrefix(fromProvider) !== getProtocolPrefix(toProvider)) {
|
||||
console.log(`[Request Convert] Converting request from ${fromProvider} to ${toProvider}`);
|
||||
processedRequestBody = convertData(originalRequestBody, 'request', fromProvider, toProvider);
|
||||
|
|
|
|||
|
|
@ -774,7 +774,7 @@ export function toOpenAIRequestFromClaude(claudeRequest) {
|
|||
const funcArgs = firstPart.input || {};
|
||||
tempOpenAIMessages.push({
|
||||
role: "assistant",
|
||||
content: null,
|
||||
content: '',
|
||||
tool_calls: [
|
||||
{
|
||||
id: firstPart.id || `call_${funcName}_1`,
|
||||
|
|
@ -782,7 +782,8 @@ export function toOpenAIRequestFromClaude(claudeRequest) {
|
|||
function: {
|
||||
name: funcName,
|
||||
arguments: JSON.stringify(funcArgs)
|
||||
}
|
||||
},
|
||||
index: firstPart.index || 0
|
||||
}
|
||||
]
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue