# Hubei_api **Repository Path**: thunderlz/hubei_api ## Basic Information - **Project Name**: Hubei_api - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-18 - **Last Updated**: 2026-01-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 湖北信通大模型服务接口测试脚本 基于《湖北信通大模型服务接口文档.pdf》v1.1版本编写的API测试脚本。 ## 功能特性 - ✅ 支持所有文档中提到的模型 - ✅ 支持流式和非流式响应 - ✅ 包含多种测试用例(数学推理、代码生成、翻译、商业分析等) - ✅ 详细的请求/响应日志 - ✅ Token使用统计 - ✅ 连接测试功能 - ✅ 命令行参数支持 ## 支持的模型 | 模型标识 | 模型名称 | 支持模式 | |---------|---------|---------| | qwen3-235b-a22b-thinking-2507 | Qwen3-235B-A22B | 思考模式 | | qwen3-235b-a22b-instruct-2507 | Qwen3-235B-A22B | 非思考模式 | | qwen3-30b-a3b-thinking-2507 | Qwen3-30B-A3B | 思考模式 | | qwen3-30b-a3b-instruct-2507 | Qwen3-30B-A3B | 非思考模式 | | qwen3-vl-30b-a3b-instruct | Qwen3-VL-30B-A3B-Instruct | 非思考模式(视觉) | ## 安装依赖 ```bash pip install requests ``` ## 使用方法 ### 1. 查看帮助 ```bash python3 test_hubei_api.py --help ``` ### 2. 列出所有测试用例 ```bash python3 test_hubei_api.py --list-cases ``` ### 3. 测试API连接 ```bash python3 test_hubei_api.py --check-connection ``` ### 4. 运行单个测试用例 ```bash # 运行翻译测试 python3 test_hubei_api.py --test-case instruct_model_translation # 运行代码生成测试 python3 test_hubei_api.py --test-case instruct_model_code # 运行数学推理测试 python3 test_hubei_api.py --test-case thinking_model_math # 运行商业分析测试(流式响应) python3 test_hubei_api.py --test-case thinking_model_business # 运行多轮对话测试 python3 test_hubei_api.py --test-case multiturn_conversation ``` ### 5. 运行所有测试 ```bash python3 test_hubei_api.py --test-all ``` ### 6. 安静模式(减少输出) ```bash python3 test_hubei_api.py --test-case instruct_model_translation --quiet ``` ## 测试用例说明 1. **thinking_model_math** - 思考模式数学问题 - 测试思考模型的逻辑推理能力 - 包含系统提示要求展示思考过程 2. **instruct_model_code** - 指令模式代码生成 - 测试指令模型的代码生成能力 - 要求直接给出Python代码 3. **thinking_model_business** - 思考模式商业分析 - 测试思考模型的商业分析能力 - 使用流式响应模式 4. **instruct_model_translation** - 指令模式翻译任务 - 测试指令模型的翻译能力 - 中译英专业翻译 5. **multiturn_conversation** - 多轮对话测试 - 测试多轮对话上下文保持能力 - 模拟真实对话场景 ## API配置 - 服务地址:`http://59.173.174.226:53101/v1/chat/completions` - 认证方式:Bearer Token - API密钥:在脚本中已配置为 `sk-PhgqJb01nHo89wpWQ6pRWhFqbaVZZkTPy1JCz8yit6wkcl5o` 如需修改API密钥或服务地址,请编辑 `test_hubei_api.py` 文件中的 `API_KEY` 和 `base_url` 参数。 ## 脚本结构 ``` HubeiAPITester 类 ├── __init__() - 初始化API配置 ├── _create_test_cases() - 创建测试用例 ├── test_single_request() - 测试单个请求 ├── _test_normal_request() - 测试普通请求 ├── _test_stream_request() - 测试流式请求 ├── run_all_tests() - 运行所有测试 └── test_connection() - 测试API连接 ``` ## 响应示例 脚本会显示完整的请求和响应信息,包括: - 请求体(JSON格式) - 响应时间 - HTTP状态码 - 响应内容(JSON格式) - 生成的文本(截断显示) - Token使用统计 ## 注意事项 1. **API密钥安全**:请妥善保管API密钥,不要公开分享 2. **网络连接**:确保网络可以访问API服务地址 3. **超时设置**:复杂请求可能需要较长时间,脚本已设置合理超时 4. **流式响应**:流式响应测试会实时显示生成内容 5. **Token限制**:注意max_tokens参数设置,避免超出模型限制 ## 版本历史 - v1.0 (2025-12-18): 初始版本,基于接口文档v1.1 ## 许可证 本脚本仅供测试使用,请遵守相关服务条款和法律法规。