From 40d149240f7c83caaab7f887bd31dc52e9f7e672 Mon Sep 17 00:00:00 2001 From: HuangHai <10402852@qq.com> Date: Fri, 15 Aug 2025 15:56:49 +0800 Subject: [PATCH] 'commit' --- dsLightRag/Test/TestGoogleGemini.py | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 dsLightRag/Test/TestGoogleGemini.py diff --git a/dsLightRag/Test/TestGoogleGemini.py b/dsLightRag/Test/TestGoogleGemini.py new file mode 100644 index 00000000..1b03af53 --- /dev/null +++ b/dsLightRag/Test/TestGoogleGemini.py @@ -0,0 +1,32 @@ +import requests +import json + +# API配置 +API_URL = "https://goapi.gptnb.ai/v1/chat/completions" +API_KEY = "sk-amQHwiEzPIZIB2KuF5A10dC23a0e4b02B48a7a2b6aFa0662" # 从文件末尾提取的API密钥 + +# 请求头 +headers = { + "Content-Type": "application/json", + "Authorization": f"Bearer {API_KEY}" +} + +# 请求体 +payload = { + "model": "gemini-2.5-pro", + "messages": [{"role": "user", "content": "你是谁?"}], + "temperature": 0.7 +} + +try: + # 发送POST请求 + response = requests.post(API_URL, headers=headers, data=json.dumps(payload)) + response.raise_for_status() # 检查请求是否成功 + + # 解析响应 + result = response.json() + print("API响应:") + print(json.dumps(result, ensure_ascii=False, indent=2)) + +except requests.exceptions.RequestException as e: + print(f"请求发生错误: {e}") \ No newline at end of file