sanbo
commited on
Commit
·
b23eeaf
1
Parent(s):
f265549
update sth. at 2024-11-14 16:08:54
Browse files- call_demo/hg.py +22 -0
- call_demo/hg_fd.py +22 -0
call_demo/hg.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import json
|
3 |
+
|
4 |
+
url = 'https://sanbo1200-duck2api.hf.space/completions'
|
5 |
+
headers = {
|
6 |
+
'Content-Type': 'application/json'
|
7 |
+
}
|
8 |
+
data = {
|
9 |
+
"model": "gpt-4o-mini",
|
10 |
+
"messages": [
|
11 |
+
{"role": "system", "content": "你是一个辅助机器人"},
|
12 |
+
{"role": "user", "content": "你的知识库最后什么日期"}
|
13 |
+
],
|
14 |
+
"stream": False
|
15 |
+
}
|
16 |
+
|
17 |
+
response = requests.post(url, headers=headers, data=json.dumps(data), stream=True)
|
18 |
+
response.encoding = 'utf-8'
|
19 |
+
# 打印返回的数据流
|
20 |
+
for line in response.iter_lines():
|
21 |
+
if line:
|
22 |
+
print(line.decode('utf-8'))
|
call_demo/hg_fd.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import json
|
3 |
+
|
4 |
+
url = 'https://p.till.us.kg/till/https/sanbo1200-duck2api.hf.space/completions'
|
5 |
+
headers = {
|
6 |
+
'Content-Type': 'application/json'
|
7 |
+
}
|
8 |
+
data = {
|
9 |
+
"model": "gpt-4o-mini",
|
10 |
+
"messages": [
|
11 |
+
{"role": "system", "content": "你是一个辅助机器人"},
|
12 |
+
{"role": "user", "content": "你的知识库最后什么日期"}
|
13 |
+
],
|
14 |
+
"stream": False
|
15 |
+
}
|
16 |
+
|
17 |
+
response = requests.post(url, headers=headers, data=json.dumps(data), stream=True)
|
18 |
+
response.encoding = 'utf-8'
|
19 |
+
# 打印返回的数据流
|
20 |
+
for line in response.iter_lines():
|
21 |
+
if line:
|
22 |
+
print(line.decode('utf-8'))
|