parent
2f1bb1a218
commit
c717d32313
@ -0,0 +1,20 @@
|
||||
import json
|
||||
|
||||
import requests
|
||||
|
||||
from Config import *
|
||||
|
||||
url = DIFY_URL + "/audio-to-text"
|
||||
|
||||
payload = {'user': 'abc-123'}
|
||||
files = [
|
||||
('file', ('1.png', open(r'D:\KeCheng\片头曲\1_建工高启强_去片头_(人声).mp3', 'rb'), 'type=audio/[mp3|mp4|mpeg|mpga|m4a|wav|webm]'))
|
||||
]
|
||||
headers = {
|
||||
'Authorization': 'Bearer ' + DIFY_API_KEY
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload, files=files)
|
||||
|
||||
json_data = json.loads(response.text)
|
||||
print(json_data)
|
@ -0,0 +1 @@
|
||||
#TODO
|
@ -0,0 +1,21 @@
|
||||
import json
|
||||
import requests
|
||||
from Config import *
|
||||
|
||||
|
||||
|
||||
# Dify API 配置
|
||||
url = DIFY_URL + "/info"
|
||||
headers = {
|
||||
'Authorization': 'Bearer ' + DIFY_API_KEY,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
# 发送 POST 请求
|
||||
response = requests.get(url, headers=headers)
|
||||
|
||||
# 解析并打印响应
|
||||
json_data = response.json()
|
||||
print(json.dumps(json_data, indent=2, ensure_ascii=False))
|
||||
|
||||
|
@ -0,0 +1,21 @@
|
||||
import json
|
||||
import requests
|
||||
from Config import *
|
||||
|
||||
|
||||
|
||||
# Dify API 配置
|
||||
url = DIFY_URL + "/parameters"
|
||||
headers = {
|
||||
'Authorization': 'Bearer ' + DIFY_API_KEY,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
# 发送 POST 请求
|
||||
response = requests.get(url, headers=headers)
|
||||
|
||||
# 解析并打印响应
|
||||
json_data = response.json()
|
||||
print(json.dumps(json_data, indent=2, ensure_ascii=False))
|
||||
|
||||
|
@ -0,0 +1,21 @@
|
||||
import json
|
||||
import requests
|
||||
from Config import *
|
||||
|
||||
|
||||
|
||||
# Dify API 配置
|
||||
url = DIFY_URL + "/meta"
|
||||
headers = {
|
||||
'Authorization': 'Bearer ' + DIFY_API_KEY,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
# 发送 POST 请求
|
||||
response = requests.get(url, headers=headers)
|
||||
|
||||
# 解析并打印响应
|
||||
json_data = response.json()
|
||||
print(json.dumps(json_data, indent=2, ensure_ascii=False))
|
||||
|
||||
|
@ -0,0 +1,23 @@
|
||||
import json
|
||||
import requests
|
||||
from Config import *
|
||||
|
||||
|
||||
# 获取会话历史消息
|
||||
conversation_id = '37a742e4-013d-4466-8a5e-fe64bb3b4e1d'
|
||||
|
||||
# Dify API 配置
|
||||
url = DIFY_URL + "/messages"
|
||||
headers = {
|
||||
'Authorization': 'Bearer ' + DIFY_API_KEY,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
# 发送 POST 请求
|
||||
response = requests.get(url + '?user=abc-123&conversation_id='+conversation_id+"&first_id=&limit=10", headers=headers)
|
||||
|
||||
# 解析并打印响应
|
||||
json_data = response.json()
|
||||
print(json.dumps(json_data, indent=2, ensure_ascii=False))
|
||||
|
||||
|
@ -0,0 +1,20 @@
|
||||
# 获取会话列表
|
||||
import json
|
||||
import requests
|
||||
from Config import *
|
||||
|
||||
# Dify API 配置
|
||||
url = DIFY_URL + "/conversations"
|
||||
headers = {
|
||||
'Authorization': 'Bearer ' + DIFY_API_KEY,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
# 发送 POST 请求
|
||||
response = requests.get(url + '?user=abc-123&limit=10', headers=headers)
|
||||
|
||||
# 解析并打印响应
|
||||
json_data = response.json()
|
||||
print(json.dumps(json_data, indent=2, ensure_ascii=False))
|
||||
|
||||
|
@ -0,0 +1,26 @@
|
||||
import json
|
||||
import requests
|
||||
from Config import *
|
||||
|
||||
# 会话ID
|
||||
conversation_id = '37a742e4-013d-4466-8a5e-fe64bb3b4e1d'
|
||||
|
||||
# Dify API 配置
|
||||
url = DIFY_URL + "/conversations/" + conversation_id
|
||||
headers = {
|
||||
'Authorization': 'Bearer ' + DIFY_API_KEY,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
# 请求体数据
|
||||
data = {
|
||||
'user': 'abc-123' # 用户标识,需与发送消息接口保持一致
|
||||
}
|
||||
|
||||
# 发送 DELETE 请求
|
||||
response = requests.delete(url, headers=headers, json=data)
|
||||
response.raise_for_status() # 检查请求是否成功
|
||||
|
||||
# 解析并打印响应
|
||||
json_data = response.json()
|
||||
print("删除会话成功:", json.dumps(json_data, indent=2, ensure_ascii=False))
|
@ -0,0 +1,26 @@
|
||||
import requests
|
||||
import json
|
||||
from Config import *
|
||||
|
||||
# 会话ID
|
||||
conversation_id = '2a2cb0ad-fc02-449a-ada7-89087c6204e8'
|
||||
|
||||
|
||||
# Dify API 配置
|
||||
url = DIFY_URL + "/conversations/"+conversation_id+"/name"
|
||||
headers = {
|
||||
'Authorization': 'Bearer ' + DIFY_API_KEY,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
|
||||
# 请求数据
|
||||
payload = json.dumps({
|
||||
'name':'黄海的测试',
|
||||
'auto_generate':False,
|
||||
"user": "abc-123"
|
||||
})
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
json_data = json.loads(response.text)
|
||||
print(json_data)
|
Binary file not shown.
Loading…
Reference in new issue