From 59505b7f80e5da56f04a3c61c3218f34e40b73af Mon Sep 17 00:00:00 2001 From: cypggs Date: Mon, 1 Jul 2024 16:01:47 +0800 Subject: [PATCH] =?UTF-8?q?Update=20jina=5Fsum.py=20=E5=A2=9E=E5=8A=A0=20h?= =?UTF-8?q?eader=20=E8=A7=A3=E5=86=B3=E5=BE=AE=E4=BF=A1=E5=85=AC=E4=BC=97?= =?UTF-8?q?=E5=8F=B7=E8=BF=94=E5=9B=9E=20403=20=E9=97=AE=E9=A2=98=20(#54)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/jina_sum/jina_sum.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/jina_sum/jina_sum.py b/plugins/jina_sum/jina_sum.py index 8ccecc9..2578f46 100644 --- a/plugins/jina_sum/jina_sum.py +++ b/plugins/jina_sum/jina_sum.py @@ -70,7 +70,8 @@ class JinaSum(Plugin): target_url = html.unescape(content) # 解决公众号卡片链接校验问题,参考 https://github.com/fatwang2/sum4all/commit/b983c49473fc55f13ba2c44e4d8b226db3517c45 jina_url = self._get_jina_url(target_url) - response = requests.get(jina_url, timeout=60) + headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"} + response = requests.get(jina_url, headers=headers, timeout=60) response.raise_for_status() target_url_content = response.text @@ -78,7 +79,7 @@ class JinaSum(Plugin): openai_headers = self._get_openai_headers() openai_payload = self._get_openai_payload(target_url_content) logger.debug(f"[JinaSum] openai_chat_url: {openai_chat_url}, openai_headers: {openai_headers}, openai_payload: {openai_payload}") - response = requests.post(openai_chat_url, headers=openai_headers, json=openai_payload, timeout=60) + response = requests.post(openai_chat_url, headers={**openai_headers, **headers}, json=openai_payload, timeout=60) response.raise_for_status() result = response.json()['choices'][0]['message']['content'] reply = Reply(ReplyType.TEXT, result)