chao hace 1 mes
padre
commit
e41ae0dbd0
Se han modificado 2 ficheros con 18 adiciones y 15 borrados
  1. 2 2
      main.py
  2. 16 13
      preset/drivers/pylib/GPTrequest.py

+ 2 - 2
main.py

@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-#version    :       2024.08.16
+#version    :       2025.02.13
 #language   :       en
 #hardware   :       pi
 import time
@@ -72,7 +72,7 @@ main_title = (
         "A"
     )
 splash_text = (
-        "Version: 2024-10-18 ",
+        "Version: 2025-05-13 ",
         "System version: N/A",
         "2. After loading the code,press ",
         "   KEY-A for 2s to back to start ",

+ 16 - 13
preset/drivers/pylib/GPTrequest.py

@@ -37,15 +37,16 @@ class GPTrequest():
         print(self.hwMac)
        
     # 文字生成图片
-    def get_text_to_img(self,text):
+    def get_text_to_img(self,text,model="cogview-3"):
         uid = str(uuid.uuid1().hex)
         param = {
-            "size": "1024x1024",
+            "size": "1024*1024" if model.find("cogview-3")>-1 else "1024x1024",
             "quality": "standard",
             "n": 1,
             "prompt": text,
             "style":"natural",
-            "uid": uid
+            "uid": uid,
+            "model":model
         }
         headers={
             "Content-Type":"application/json",
@@ -74,7 +75,7 @@ class GPTrequest():
         return str(base64.b64encode(img_data), "utf-8")
 
     # 通过图片获取文字
-    def get_image_to_text(self,imgUrl,textDesc):
+    def get_image_to_text(self,imgUrl,textDesc,model="gpt-4o"):
         uid = str(uuid.uuid1().hex)
         strBase = self.encode_image(imgUrl)
         params = {
@@ -89,7 +90,8 @@ class GPTrequest():
                 }
             ],
             "uid": uid,
-            "stream": False
+            "stream": False,
+            "model":model
         }
         headers={
             "Content-Type":"application/json",
@@ -106,10 +108,10 @@ class GPTrequest():
         return textContent
     
     # 文字生成音頻文件
-    def get_text_to_voice(self,text):
+    def get_text_to_voice(self,text,model="tts-1"):
         uid = str(uuid.uuid1().hex)
         url = "https://gpt4.cocorobo.cn/getV831Audio"
-        payload = json.dumps({"input": text,"response_format":"mp3","voice": "shimmer","uid":uid})
+        payload = json.dumps({"input": text,"response_format":"mp3","voice": "shimmer","uid":uid,"model":model})
         
         headers={
             "Content-Type":"application/json",
@@ -130,9 +132,9 @@ class GPTrequest():
         return voiceFilePath
     
     # 音频转文字
-    def get_voice_to_text(self,voicePath):
+    def get_voice_to_text(self,voicePath,model=""):
         voiceData = open(voicePath,'rb')
-        data = {"file": voiceData}
+        data = {"file": voiceData,"model":model}
         param = {}
         headers={
             "hwMac":self.hwMac
@@ -145,9 +147,9 @@ class GPTrequest():
         return voiceResult
 
     # gpt 對話,並生成音頻文件
-    def get_post_chatgpt(self,datas):
+    def get_post_chatgpt(self,datas,model="deepseek-chat"):
         url = "https://gpt4.cocorobo.cn/v831AskForTopicNew"
-        payload = json.dumps({"topic": datas})
+        payload = json.dumps({"topic": datas,"model":model})
         headers={
             "Content-Type":"application/json",
             "hwMac":self.hwMac
@@ -162,13 +164,14 @@ class GPTrequest():
         return result
     
     
-    def get_post_AI_Intelligence(self,id,text):
+    def get_post_AI_Intelligence(self,id,text,model="deepseek-chat"):
         url = "https://gpt4.cocorobo.cn/ai_agent_chat"
         params = {
             "id":id,
             "userId":self.hwMac,
             "message":text,
-            "file_ids": []
+            "file_ids": [],
+            "model":model
         }
         headers={
             "Content-Type":"application/json",