Files
DM_rewrite_3.31/booway_kg_api/info_extraction.py
T
2025-03-31 15:17:47 +08:00

57 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
===================================
@AutherWenZ
@Company: BooWay
@projectdify_lab
===================================
"""
import requests
import json
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
def info_input(input_str):
# API 端点
url = "https://172.20.0.145/v1/chat-messages"
# 确保 API Key 正确(去掉大括号)
api_key = "app-ziMDuhVoATbd5vF3Lb7iyjVD"
# 认证信息
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
# 请求数据
payload = {
"inputs": {},
"query": "",
"response_mode": "blocking",
"conversation_id": "",
"user": "abc-123",
"files": [
{
"type": "image",
"transfer_method": "remote_url",
"url": "https://cloud.dify.ai/logo/logo-site.png"
}
]
}
payload["query"] = input_str
# 发送 POST 请求
response = requests.post(url, headers=headers, data=json.dumps(payload), verify=False) # verify=False 忽略 SSL 证书验证
response_dict = json.loads(response.text)
return response_dict['conversation_id']
# print(info_input("多个工程需要统一修改定额中材料的单价是否可以呢"))
# print(info_input("多个工程需要统一修改定额中材料的单价是否可以呢"))