optimze code

This commit is contained in:
= 2025-04-26 22:00:15 +08:00
parent bc6115442d
commit 12e733a9da
2 changed files with 26 additions and 1 deletions

View File

@ -1,2 +1,3 @@
from .crendential import get_api_details
from .file_util import write_file, write_file_batch
__all__ = ['write_file', 'write_file_batch']
__all__ = ['write_file', 'write_file_batch','get_api_details']

24
bot_util/crendential.py Normal file
View File

@ -0,0 +1,24 @@
from dotenv import load_dotenv
import os
load_dotenv()
API_KEY = os.getenv("DEEPSEEK_API_KEY")
API_URL = os.getenv("DEEPSEEK_API_URL")
class ApiCredential:
def __init__(self, api_key: str, api_url: str):
self.api_key = api_key
self.api_url = api_url
def get_api_key(self):
return self.api_key
def get_api_url(self):
return self.api_url
def get_api_details() -> ApiCredential:
"""
Get the API key and URL from environment variables.
"""
return ApiCredential(API_KEY, API_URL)