From 4db19f816f286ac95cad77b205214052160566e1 Mon Sep 17 00:00:00 2001 From: zhayujie Date: Fri, 3 May 2024 14:10:07 +0800 Subject: [PATCH] feat: update service url --- bot/linkai/link_ai_bot.py | 8 ++++---- config.py | 2 +- plugins/linkai/midjourney.py | 2 +- plugins/linkai/summary.py | 2 +- voice/linkai/linkai_voice.py | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bot/linkai/link_ai_bot.py b/bot/linkai/link_ai_bot.py index 2a3e57d..3fe8131 100644 --- a/bot/linkai/link_ai_bot.py +++ b/bot/linkai/link_ai_bot.py @@ -122,7 +122,7 @@ class LinkAIBot(Bot): headers = {"Authorization": "Bearer " + linkai_api_key} # do http request - base_url = conf().get("linkai_api_base", "https://api.link-ai.chat") + base_url = conf().get("linkai_api_base", "https://api.link-ai.tech") res = requests.post(url=base_url + "/v1/chat/completions", json=body, headers=headers, timeout=conf().get("request_timeout", 180)) if res.status_code == 200: @@ -261,7 +261,7 @@ class LinkAIBot(Bot): headers = {"Authorization": "Bearer " + conf().get("linkai_api_key")} # do http request - base_url = conf().get("linkai_api_base", "https://api.link-ai.chat") + base_url = conf().get("linkai_api_base", "https://api.link-ai.tech") res = requests.post(url=base_url + "/v1/chat/completions", json=body, headers=headers, timeout=conf().get("request_timeout", 180)) if res.status_code == 200: @@ -304,7 +304,7 @@ class LinkAIBot(Bot): def _fetch_app_info(self, app_code: str): headers = {"Authorization": "Bearer " + conf().get("linkai_api_key")} # do http request - base_url = conf().get("linkai_api_base", "https://api.link-ai.chat") + base_url = conf().get("linkai_api_base", "https://api.link-ai.tech") params = {"app_code": app_code} res = requests.get(url=base_url + "/v1/app/info", params=params, headers=headers, timeout=(5, 10)) if res.status_code == 200: @@ -326,7 +326,7 @@ class LinkAIBot(Bot): "response_format": "url", "img_proxy": conf().get("image_proxy") } - url = conf().get("linkai_api_base", "https://api.link-ai.chat") + "/v1/images/generations" + url = conf().get("linkai_api_base", "https://api.link-ai.tech") + "/v1/images/generations" res = requests.post(url, headers=headers, json=data, timeout=(5, 90)) t2 = time.time() image_url = res.json()["data"][0]["url"] diff --git a/config.py b/config.py index f6d25da..7d07379 100644 --- a/config.py +++ b/config.py @@ -163,7 +163,7 @@ available_setting = { "use_linkai": False, "linkai_api_key": "", "linkai_app_code": "", - "linkai_api_base": "https://api.link-ai.chat", # linkAI服务地址,若国内无法访问或延迟较高可改为 https://api.link-ai.tech + "linkai_api_base": "https://api.link-ai.tech", # linkAI服务地址 } diff --git a/plugins/linkai/midjourney.py b/plugins/linkai/midjourney.py index 9c6c57b..6500e57 100644 --- a/plugins/linkai/midjourney.py +++ b/plugins/linkai/midjourney.py @@ -68,7 +68,7 @@ class MJTask: # midjourney bot class MJBot: def __init__(self, config): - self.base_url = conf().get("linkai_api_base", "https://api.link-ai.chat") + "/v1/img/midjourney" + self.base_url = conf().get("linkai_api_base", "https://api.link-ai.tech") + "/v1/img/midjourney" self.headers = {"Authorization": "Bearer " + conf().get("linkai_api_key")} self.config = config self.tasks = {} diff --git a/plugins/linkai/summary.py b/plugins/linkai/summary.py index 1f08e85..84d74bc 100644 --- a/plugins/linkai/summary.py +++ b/plugins/linkai/summary.py @@ -61,7 +61,7 @@ class LinkSummary: return None def base_url(self): - return conf().get("linkai_api_base", "https://api.link-ai.chat") + return conf().get("linkai_api_base", "https://api.link-ai.tech") def headers(self): return {"Authorization": "Bearer " + conf().get("linkai_api_key")} diff --git a/voice/linkai/linkai_voice.py b/voice/linkai/linkai_voice.py index 074c9fd..739b5f6 100644 --- a/voice/linkai/linkai_voice.py +++ b/voice/linkai/linkai_voice.py @@ -19,7 +19,7 @@ class LinkAIVoice(Voice): def voiceToText(self, voice_file): logger.debug("[LinkVoice] voice file name={}".format(voice_file)) try: - url = conf().get("linkai_api_base", "https://api.link-ai.chat") + "/v1/audio/transcriptions" + url = conf().get("linkai_api_base", "https://api.link-ai.tech") + "/v1/audio/transcriptions" headers = {"Authorization": "Bearer " + conf().get("linkai_api_key")} model = None if not conf().get("text_to_voice") or conf().get("voice_to_text") == "openai": @@ -54,7 +54,7 @@ class LinkAIVoice(Voice): def textToVoice(self, text): try: - url = conf().get("linkai_api_base", "https://api.link-ai.chat") + "/v1/audio/speech" + url = conf().get("linkai_api_base", "https://api.link-ai.tech") + "/v1/audio/speech" headers = {"Authorization": "Bearer " + conf().get("linkai_api_key")} model = const.TTS_1 if not conf().get("text_to_voice") or conf().get("text_to_voice") in ["openai", const.TTS_1, const.TTS_1_HD]: