dify/api/services/enterprise/base.py

23 lines
661 B
Python
Raw Normal View History

2024-04-18 17:33:32 +08:00
import os
import requests
class EnterpriseRequest:
base_url = os.environ.get("ENTERPRISE_API_URL", "ENTERPRISE_API_URL")
secret_key = os.environ.get("ENTERPRISE_API_SECRET_KEY", "ENTERPRISE_API_SECRET_KEY")
2024-04-18 17:33:32 +08:00
2024-10-11 11:35:01 +08:00
proxies = {
"http": None,
"https": None,
}
2024-04-18 17:33:32 +08:00
@classmethod
def send_request(cls, method, endpoint, json=None, params=None):
headers = {"Content-Type": "application/json", "Enterprise-Api-Secret-Key": cls.secret_key}
2024-04-18 17:33:32 +08:00
url = f"{cls.base_url}{endpoint}"
2024-10-11 11:35:01 +08:00
response = requests.request(method, url, json=json, params=params, headers=headers, proxies=cls.proxies)
2024-04-18 17:33:32 +08:00
return response.json()