From 69d129cba269fd80785c8274776f62506fdcba20 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 7 Feb 2025 12:43:34 +0800 Subject: [PATCH] fix ChatGPT --- package.v2.json | 4 ++-- plugins.v2/chatgpt/__init__.py | 6 ++---- plugins.v2/chatgpt/openai.py | 10 +++++----- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/package.v2.json b/package.v2.json index 9dc0055..3a4f285 100644 --- a/package.v2.json +++ b/package.v2.json @@ -91,12 +91,12 @@ "name": "ChatGPT", "description": "消息交互支持与ChatGPT对话。", "labels": "消息通知,识别", - "version": "2.0.2", + "version": "2.1.0", "icon": "Chatgpt_A.png", "author": "jxxghp", "level": 1, "history": { - "v2.0.2": "调整辅助识别提示词", + "v2.1.0": "优化辅助识别提示词", "v2.0.1": "修复辅助识别", "v2.0": "适配MoviePilot V2 版本,采用链式事件机制" } diff --git a/plugins.v2/chatgpt/__init__.py b/plugins.v2/chatgpt/__init__.py index bc331e5..aaf1a45 100644 --- a/plugins.v2/chatgpt/__init__.py +++ b/plugins.v2/chatgpt/__init__.py @@ -16,7 +16,7 @@ class ChatGPT(_PluginBase): # 插件图标 plugin_icon = "Chatgpt_A.png" # 插件版本 - plugin_version = "2.0.2" + plugin_version = "2.1.0" # 插件作者 plugin_author = "jxxghp" # 作者主页 @@ -247,7 +247,7 @@ class ChatGPT(_PluginBase): # 调用ChatGPT response = self.openai.get_media_name(filename=title) logger.info(f"ChatGPT返回结果:{response}") - if response: + if response and response.get("name"): event.event_data = { 'title': title, 'name': response.get("name"), @@ -255,8 +255,6 @@ class ChatGPT(_PluginBase): 'season': response.get("season"), 'episode': response.get("episode") } - else: - event.event_data = {} def stop_service(self): """ diff --git a/plugins.v2/chatgpt/openai.py b/plugins.v2/chatgpt/openai.py index 9dbd1b3..0703036 100644 --- a/plugins.v2/chatgpt/openai.py +++ b/plugins.v2/chatgpt/openai.py @@ -121,15 +121,15 @@ class OpenAi: return None result = "" try: - _filename_prompt = "I will give you a movie/tvshow file name.You need to return a Json." \ - "\nPay attention to the correct identification of the film name." \ - "\n{\"name\":string,\"version\":string,\"part\":string,\"year\":string,\"resolution\":string,\"season\":number|null,\"episode\":number|null}" + _filename_prompt = '接下来我会给你一个电影或电视剧的文件名,你需要识别文件名中的名称、版本、分段、年份、分瓣率、季集等信息,并按以下JSON格式返回:{"name":string,"version":string,"part":string,"year":string,"resolution":string,"season":number|null,"episode":number|null},特别注意返回结果需要严格附合JSON格式,不需要有任何其它的字符。' completion = self.__get_model(prompt=_filename_prompt, message=filename) result = completion.choices[0].message.content return json.loads(result) except Exception as e: - print(f"{str(e)}:{result}") - return {} + return { + "content": result, + "errorMsg": str(e) + } def get_response(self, text: str, userid: str): """