fulian23 4 months ago
parent
commit
8c791447c2
5 changed files with 36 additions and 18 deletions
  1. 12 0
      .idea/CopilotChatHistory.xml
  2. 0 16
      aitest.py
  3. 2 1
      api/gitRouter.py
  4. 1 1
      test/addLines.py
  5. 21 0
      test/aitest.py

+ 12 - 0
.idea/CopilotChatHistory.xml

@@ -3,6 +3,18 @@
   <component name="CopilotChatHistory">
     <option name="conversations">
       <list>
+        <Conversation>
+          <option name="createTime" value="1742705963507" />
+          <option name="id" value="0195c15eb1f3711f9472b5b245e8f1c8" />
+          <option name="title" value="新对话 2025年3月23日 12:59:23" />
+          <option name="updateTime" value="1742705963507" />
+        </Conversation>
+        <Conversation>
+          <option name="createTime" value="1742541939752" />
+          <option name="id" value="0195b797e42870f5a1858adfde34698d" />
+          <option name="title" value="新对话 2025年3月21日 15:25:39" />
+          <option name="updateTime" value="1742541939752" />
+        </Conversation>
         <Conversation>
           <option name="createTime" value="1742493777759" />
           <option name="id" value="0195b4b8ff5f7de586a6dcb029dc4ee2" />

+ 0 - 16
aitest.py

@@ -1,16 +0,0 @@
-import os
-from http import HTTPStatus
-from dashscope import Application
-response = Application.call(
-    # 若没有配置环境变量,可用百炼API Key将下行替换为:api_key="sk-xxx"。但不建议在生产环境中直接将API Key硬编码到代码中,以减少API Key泄露风险。
-    api_key="sk-f49eecdb8e50462aa5cdc4f6f1c27446",
-    app_id='b2fc1c44f28647f3ab2fbe283d7e4102',# 替换为实际的应用 ID
-    prompt='你是谁?')
-
-if response.status_code != HTTPStatus.OK:
-    print(f'request_id={response.request_id}')
-    print(f'code={response.status_code}')
-    print(f'message={response.message}')
-    print(f'请参考文档:https://help.aliyun.com/zh/model-studio/developer-reference/error-code')
-else:
-    print(response.output.text)

+ 2 - 1
api/gitRouter.py

@@ -106,7 +106,7 @@ async def change(request: CommitHash):
         return {"status": "404", "msg": "仓库不存在", "uuid": request.uuid, "repo_url": request.repo_url}
     commit = repo.commit(request.commit_hash)
 
-    if not commit.parents:  # 处理首次提交
+    if not commit.parents:
         print("首次提交,无父提交对比")
         return
 
@@ -119,3 +119,4 @@ async def change(request: CommitHash):
         print(diff.diff.decode('utf-8'))
 
 
+

+ 1 - 1
test/addLines.py

@@ -1,3 +1,3 @@
 with open('code.txt', 'r',encoding="utf8") as f_in, open('output.txt', 'w',encoding="utf8") as f_out:
     for line_num, line in enumerate(f_in, start=1):
-        f_out.write(f"{line_num}\t{line}")  # 行号后添加制表符[1,3](@ref)
+        f_out.write(f"{line_num}\t{line}")

+ 21 - 0
test/aitest.py

@@ -0,0 +1,21 @@
+import json
+from http import HTTPStatus
+from dashscope import Application
+
+with open("output.txt", 'r', encoding="utf8") as f:
+    prompt = f.read()
+
+response = Application.call(
+    # 若没有配置环境变量,可用百炼API Key将下行替换为:api_key="sk-xxx"。但不建议在生产环境中直接将API Key硬编码到代码中,以减少API Key泄露风险。
+    api_key="sk-0164613e1a2143fc808fc4cc2451bef0",
+    app_id='2f288f146e2d492abb3fe22695e70635',  # 替换为实际的应用 ID
+    prompt=prompt)
+
+if response.status_code == HTTPStatus.OK:
+    try:
+        json_data = json.loads(response.output.text)
+        print(json_data)
+    except json.JSONDecodeError:
+        print("返回内容不是有效的 JSON 格式!")
+else:
+    print(f"请求失败: {response.message}")