mirror of
https://github.com/jxxghp/MoviePilot-Plugins.git
synced 2026-03-27 10:05:57 +00:00
fix(autosubv2): v2.5 fix openai client init problem
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
"name": "AI字幕自动生成(v2)",
|
||||
"description": "使用whisper自动生成视频文件字幕,使用大模型翻译字幕成中文。",
|
||||
"labels": "字幕",
|
||||
"version": "2.4",
|
||||
"version": "2.5",
|
||||
"icon": "autosubtitles.jpeg",
|
||||
"author": "TimoYoung",
|
||||
"level": 1,
|
||||
@@ -39,7 +39,7 @@
|
||||
"v2.1": "支持清除历史记录",
|
||||
"v2.2": "fix",
|
||||
"v2.3": "支持独立的大模型调用配置",
|
||||
"v2.4": "适配openai api v1"
|
||||
"v2.5": "适配openai api v1"
|
||||
}
|
||||
},
|
||||
"CustomSites": {
|
||||
|
||||
@@ -66,7 +66,7 @@ class AutoSubv2(_PluginBase):
|
||||
# 主题色
|
||||
plugin_color = "#2C4F7E"
|
||||
# 插件版本
|
||||
plugin_version = "2.4"
|
||||
plugin_version = "2.5"
|
||||
# 插件作者
|
||||
plugin_author = "TimoYoung"
|
||||
# 作者主页
|
||||
|
||||
@@ -17,10 +17,16 @@ class OpenAi:
|
||||
compatible: bool = False):
|
||||
self._api_key = api_key
|
||||
self._api_url = api_url
|
||||
openai.api_base = self._api_url if compatible else self._api_url + "/v1"
|
||||
openai.api_key = self._api_key
|
||||
base_url = self._api_url if compatible else self._api_url + "/v1"
|
||||
|
||||
# 创建 OpenAI 客户端实例
|
||||
if proxy and proxy.get("https"):
|
||||
openai.proxy = proxy.get("https")
|
||||
import httpx
|
||||
http_client = httpx.Client(proxies=proxy.get("https"))
|
||||
self.client = openai.OpenAI(api_key=self._api_key, base_url=base_url, http_client=http_client)
|
||||
else:
|
||||
self.client = openai.OpenAI(api_key=self._api_key, base_url=base_url)
|
||||
|
||||
if model:
|
||||
self._model = model
|
||||
|
||||
|
||||
Reference in New Issue
Block a user