main
HuangHai 5 months ago
parent 2f1bb1a218
commit c717d32313

@ -26,5 +26,5 @@ NEO4J_URI = "neo4j://10.10.21.20:7687"
NEO4J_AUTH = ("neo4j", "DsideaL4r5t6y7u")
# Dify
DIFY_API_KEY = "app-KiNbcuA361kgIzYoYZd43hNT"
DIFY_URL='http://10.10.14.208/v1'
DIFY_API_KEY = "app-jdd8mRNx3IJqVTYhRhmRfxtl"
DIFY_URL='http://10.10.14.207/v1'

@ -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,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))

@ -38,7 +38,8 @@ try:
# 首次显示task_id
if not showed_task_id:
print('task_id=' + json_data['task_id'])
print('message_id=' + json_data['message_id'] + '\n')
print('message_id=' + json_data['message_id'] )
print('conversation_id=' + json_data['conversation_id'] + '\n')
showed_task_id = True
# 提取并输出流式内容
if "answer" in json_data:

@ -12,7 +12,7 @@ headers = {
'Content-Type': 'application/json'
}
# 发送 POST 请求
# 发送 get 请求
response = requests.get(url + '?user=abc-123', headers=headers)
# 解析并打印响应

@ -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)
Loading…
Cancel
Save