From c1be38fd1e2969bc1ffdbb2915151b7c2eabfec7 Mon Sep 17 00:00:00 2001 From: Kakune55 Date: Wed, 15 Nov 2023 08:46:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E5=AF=86=E9=92=A5=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=94=BE=E7=BD=AE=E4=BA=8E=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LICENSE | 21 +++++++++++++++++++++ README.md | 3 +++ src/Server/chatglmTurbo.py | 4 ++-- src/Server/config.py | 5 +++++ src/Server/db.py | 12 ++++++------ src/Server/qwenTurbo.py | 7 +++---- 6 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 src/Server/config.py diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..cf7b12c --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Kakune55 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..fdb72f7 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# PyGetGPT +使用python构建的简易语言模型api调用系统 +使用web页面作为GUI易于部署 diff --git a/src/Server/chatglmTurbo.py b/src/Server/chatglmTurbo.py index a63e2ca..3a58ce0 100644 --- a/src/Server/chatglmTurbo.py +++ b/src/Server/chatglmTurbo.py @@ -1,6 +1,6 @@ -import zhipuai +import zhipuai , config -zhipuai.api_key = "83f977afedc7f414dea579a2551298c2.sydItr1sZT8UPXWb" +zhipuai.api_key = config.readConf()["chatglmturbo"]["Authorization"] def service(prompt,history = ""): if history == "": diff --git a/src/Server/config.py b/src/Server/config.py new file mode 100644 index 0000000..012db0c --- /dev/null +++ b/src/Server/config.py @@ -0,0 +1,5 @@ +import json + +def readConf(): + with open('config.json') as f: + return json.load(f) \ No newline at end of file diff --git a/src/Server/db.py b/src/Server/db.py index 46d69b7..395ce47 100644 --- a/src/Server/db.py +++ b/src/Server/db.py @@ -1,13 +1,13 @@ -import pymysql +import pymysql , config def userSurplus(userkey): #打开数据库连接 - db = pymysql.connect(host='www.kakuweb.top', - port=33306, - user='root', - password='KAku3.14159..', - database='AIapi') + db = pymysql.connect(host=config.readConf()["db"]["host"], + port=config.readConf()["db"]["port"], + user=config.readConf()["db"]["user"], + password=config.readConf()["db"]["passwd"], + database=config.readConf()["db"]["database"]) # 使用 cursor() 方法创建一个游标对象 cursor cursor = db.cursor() diff --git a/src/Server/qwenTurbo.py b/src/Server/qwenTurbo.py index 77d76fb..70344dd 100644 --- a/src/Server/qwenTurbo.py +++ b/src/Server/qwenTurbo.py @@ -1,11 +1,10 @@ -import requests , json +import requests , json , config # 设置请求的目标URL -url = "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation" # 替换为你的API端点URL - +url = config.readConf()["qwenturbo"]["url"] # 替换为你的API端点URL header = { "Content-Type":"application/json", - "Authorization":"Bearer sk-69129a5d7fc6468a9f6f30d6935254c6" + "Authorization":config.readConf()["qwenturbo"]["Authorization"] } def service(prompt,history = ""):