#!/bin/bash # 测试 Cherry Studio 客户端优化功能 # 1. 测试客户端名称显示(x-title 请求头) # 2. 测试 thinking_budget 到 reasoning_effort 的映射 API_URL="http://localhost:8000/v1/chat/completions" API_KEY="sk-oci-genai-default-key" echo "==========================================" echo "测试 1: thinking_budget = 1000 (应映射到 low)" echo "==========================================" curl -s -X POST "$API_URL" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $API_KEY" \ -H "x-title: Cherry Studio" \ -d '{ "model": "google.gemini-2.5-pro", "messages": [ {"role": "user", "content": "Hello, how are you?"} ], "temperature": 0.7, "max_tokens": 100, "extra_body": { "google": { "thinking_config": { "thinking_budget": 1000, "include_thoughts": true } } } }' | jq . echo "" echo "==========================================" echo "测试 2: thinking_budget = 5000 (应映射到 medium)" echo "==========================================" curl -s -X POST "$API_URL" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $API_KEY" \ -H "x-title: Cherry Studio" \ -d '{ "model": "google.gemini-2.5-pro", "messages": [ {"role": "user", "content": "What is 2+2?"} ], "temperature": 0.7, "max_tokens": 100, "extra_body": { "google": { "thinking_config": { "thinking_budget": 5000, "include_thoughts": true } } } }' | jq . echo "" echo "==========================================" echo "测试 3: thinking_budget = 20000 (应映射到 high)" echo "==========================================" curl -s -X POST "$API_URL" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $API_KEY" \ -H "x-title: Cherry Studio" \ -d '{ "model": "google.gemini-2.5-pro", "messages": [ {"role": "user", "content": "Explain quantum computing"} ], "temperature": 0.7, "max_tokens": 100, "extra_body": { "google": { "thinking_config": { "thinking_budget": 20000, "include_thoughts": true } } } }' | jq . echo "" echo "==========================================" echo "测试 4: thinking_budget = -1 (应使用模型默认值)" echo "==========================================" curl -s -X POST "$API_URL" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $API_KEY" \ -H "x-title: Cherry Studio" \ -d '{ "model": "google.gemini-2.5-pro", "messages": [ {"role": "user", "content": "Tell me a joke"} ], "temperature": 0.7, "max_tokens": 100, "extra_body": { "google": { "thinking_config": { "thinking_budget": -1, "include_thoughts": true } } } }' | jq . echo "" echo "==========================================" echo "测试 5: 无 extra_body (正常请求)" echo "==========================================" curl -s -X POST "$API_URL" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $API_KEY" \ -H "x-title: Cherry Studio" \ -d '{ "model": "google.gemini-2.5-pro", "messages": [ {"role": "user", "content": "Hi there!"} ], "temperature": 0.7, "max_tokens": 100 }' | jq . echo "" echo "==========================================" echo "测试 6: 不同客户端名称 (Postman)" echo "==========================================" curl -s -X POST "$API_URL" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $API_KEY" \ -H "x-title: Postman" \ -d '{ "model": "google.gemini-2.5-pro", "messages": [ {"role": "user", "content": "Test from Postman"} ], "temperature": 0.7, "max_tokens": 100 }' | jq . echo "" echo "==========================================" echo "所有测试完成!" echo "请查看服务器日志,验证:" echo "1. 客户端名称是否正确显示(Cherry Studio / Postman)" echo "2. thinking_budget 是否正确映射到 reasoning_effort" echo " - thinking_budget = 1000 → reasoning_effort = LOW" echo " - thinking_budget = 5000 → reasoning_effort = MEDIUM" echo " - thinking_budget = 20000 → reasoning_effort = HIGH" echo " - thinking_budget = -1 → 使用模型默认值(无 reasoning_effort 日志)" echo "=========================================="