Skip to content

Commit 39a6b84

Browse files
authored
Merge pull request #7 from dataelement/sara
1. 添加对外接口的脚本
2 parents 5837181 + ff982f0 commit 39a6b84

23 files changed

+484
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
@Time : 2025/5/14 15:55
4+
@Auth : Sara
5+
@File :test_AddQA.py
6+
@IDE :PyCharm
7+
"""
8+
import requests
9+
import json
10+
11+
url = "http://192.168.106.120:3002/api/v2/filelib/add_qa"
12+
13+
payload = json.dumps({
14+
"knowledge_id": 1587,
15+
"data": [
16+
{
17+
"question": "API添加QA知识库``",
18+
"answer": [
19+
"添加成功了"
20+
]
21+
}
22+
],
23+
"user_id": 12
24+
})
25+
headers = {
26+
'Content-Type': 'application/json'
27+
}
28+
29+
response = requests.request("POST", url, headers=headers, data=payload)
30+
31+
print(response.text)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
@Time : 2025/5/14 16:06
4+
@Auth : Sara
5+
@File :test_AddRelactive_qa.py
6+
@IDE :PyCharm
7+
"""
8+
import requests
9+
import json
10+
11+
url = "http://192.168.106.120:3002/api/v2/filelib/add_relative_qa"
12+
13+
payload = json.dumps({
14+
"knowledge_id": 1587,
15+
"data": {
16+
"relative_questions": ["1111"],
17+
"id": "1462"
18+
},
19+
"user_id": 0
20+
})
21+
headers = {
22+
'Content-Type': 'application/json'
23+
}
24+
25+
response = requests.request("POST", url, headers=headers, data=payload)
26+
27+
print(response.text)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import requests
2+
import json
3+
4+
url = "http://192.168.106.120:3002/api/v2/filelib/chunk_clear"
5+
6+
payload = json.dumps({
7+
# "flow_id": "d4cfb643-c141-4f40-8b10-c69958e9db65",
8+
# "chat_id": "98c6b4f961e3f22cf10dc5f161111f05"
9+
})
10+
headers = {
11+
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
12+
'Content-Type': 'application/json'
13+
}
14+
15+
response = requests.request("POST", url, headers=headers, data=payload)
16+
17+
print(response.text)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
@Time : 2025/5/8 11:16
4+
@Auth : Sara
5+
@File :test_ClearTmpChunksData.py
6+
@IDE :PyCharm
7+
"""
8+
import requests
9+
import json
10+
11+
url = "http://192.168.106.120:3002/api/v2/filelib/chunk_clear"
12+
13+
payload = json.dumps({
14+
"flow_id": "cd4bdfb0080c4f288f562dab46f480c4",
15+
"chat_id": "b2a07bf2a7c52cb60f6e3667d8b299a7"
16+
})
17+
headers = {
18+
'Content-Type': 'application/json'
19+
}
20+
21+
response = requests.request("POST", url, headers=headers, data=payload)
22+
23+
print(response.text)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# 清空知识库中的文件
2+
import requests
3+
4+
url = "http://192.168.106.120:3002/api/v2/filelib/clear/1572"
5+
6+
headers = {
7+
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)'
8+
}
9+
10+
response = requests.request("DELETE", url, headers=headers)
11+
12+
print(response.text)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
@Time : 2025/5/7 17:16
4+
@Auth : Sara
5+
@File :test_CreateKnowledge.py
6+
@IDE :PyCharm
7+
"""
8+
import requests
9+
import json
10+
11+
url = "http://192.168.106.120:3002/api/v2/filelib/"
12+
13+
payload = json.dumps({
14+
"name": "api创建120版本",
15+
"description": "描述",
16+
"model": "161",
17+
"is_partition": True
18+
})
19+
headers = {
20+
'Content-Type': 'application/json'
21+
}
22+
23+
response = requests.request("POST", url, headers=headers, data=payload)
24+
25+
print(response.text)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
@Time : 2025/5/8 10:39
4+
@Auth : Sara
5+
@File :test_DeleteFileBatch.py
6+
@IDE :PyCharm
7+
"""
8+
import requests
9+
import json
10+
11+
url = "http://192.168.106.120:3002/api/v2/filelib/delete_file"
12+
13+
payload = json.dumps([
14+
38310,
15+
38309,
16+
38308,
17+
38307
18+
])
19+
headers = {
20+
'Content-Type': 'application/json'
21+
}
22+
23+
response = requests.request("POST", url, headers=headers, data=payload)
24+
25+
print(response.text)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import requests
2+
import json
3+
4+
url = "http://192.168.106.120:3002/api/v2/filelib/delete_file"
5+
6+
payload = json.dumps([
7+
33980,
8+
33979
9+
])
10+
headers = {
11+
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
12+
'Content-Type': 'application/json'
13+
}
14+
15+
response = requests.request("POST", url, headers=headers, data=payload)
16+
17+
print(response.text)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import requests
2+
3+
# 基础URL
4+
url = "http://192.168.106.120:3002/api/v2/filelib/1573"
5+
6+
# 查询参数(用于DELETE请求)
7+
payload = {
8+
# "knowledge_id": 1573
9+
}
10+
11+
# 请求头
12+
headers = {
13+
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)'
14+
}
15+
16+
# 使用DELETE请求,并通过params传递查询参数
17+
response = requests.request("DELETE", url, headers=headers, data=payload)
18+
19+
# 打印响应内容
20+
print(response.text)
21+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
@Time : 2025/5/7 19:35
4+
@Auth : Sara
5+
@File :test_DeleteKnowledgeFile.py
6+
@IDE :PyCharm
7+
"""
8+
import requests
9+
10+
url = "http://192.168.106.120:3002/api/v2/filelib/file/38121"
11+
12+
payload={}
13+
headers = {}
14+
15+
response = requests.request("DELETE", url, headers=headers, data=payload)
16+
17+
print(response.text)

0 commit comments

Comments
 (0)