Spaces:
Sleeping
Sleeping
sanbo
commited on
Commit
·
3012e75
1
Parent(s):
a4633a8
update sth. at 2024-11-15 19:35:00
Browse files
app.py
CHANGED
@@ -93,7 +93,7 @@ def build_interface():
|
|
93 |
status_output = gr.Textbox(label="服务状态", value=service_status, interactive=False)
|
94 |
|
95 |
# 文本聊天模块
|
96 |
-
with gr.Tab("
|
97 |
chatbox_input = gr.Textbox(label="输入你的问题", placeholder="请提问...")
|
98 |
chatbox_output = gr.Textbox(label="回答")
|
99 |
chatbox_button = gr.Button("发送")
|
|
|
93 |
status_output = gr.Textbox(label="服务状态", value=service_status, interactive=False)
|
94 |
|
95 |
# 文本聊天模块
|
96 |
+
with gr.Tab("Llama3.2-11B"):
|
97 |
chatbox_input = gr.Textbox(label="输入你的问题", placeholder="请提问...")
|
98 |
chatbox_output = gr.Textbox(label="回答")
|
99 |
chatbox_button = gr.Button("发送")
|
req.py
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
import requests
|
2 |
-
import json
|
3 |
-
|
4 |
-
def chatgpt_4o_mini(Query):
|
5 |
-
url = 'https://sanbo1200-duck2api.hf.space/completions'
|
6 |
-
headers = {'Content-Type': 'application/json'}
|
7 |
-
data = {
|
8 |
-
"model": "gpt-4o-mini",
|
9 |
-
"messages": [
|
10 |
-
{"role": "system", "content": "你是一个辅助机器人"},
|
11 |
-
{"role": "user", "content": Query}
|
12 |
-
],
|
13 |
-
"stream": False
|
14 |
-
}
|
15 |
-
|
16 |
-
# 发起 HTTP 请求
|
17 |
-
response = requests.post(url, json=data, headers=headers, stream=True)
|
18 |
-
response.encoding = 'utf-8'
|
19 |
-
if response.status_code!= 200:
|
20 |
-
return "请求失败"
|
21 |
-
else:
|
22 |
-
json_data = response.json()
|
23 |
-
return json_data['choices'][0]['message']['content']
|
24 |
-
|
25 |
-
# 获取回答
|
26 |
-
response = chatgpt_4o_mini('你的知识库最后什么日期')
|
27 |
-
|
28 |
-
# 输出回答
|
29 |
-
print(response)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|