chatgpt-mirai-qq-bot-web-search 0.2.3__py3-none-any.whl → 0.2.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: chatgpt-mirai-qq-bot-web-search
3
- Version: 0.2.3
3
+ Version: 0.2.5
4
4
  Summary: WebSearch adapter for lss233/chatgpt-mirai-qq-bot
5
5
  Home-page: https://github.com/chuanSir123/web_search
6
6
  Author: chuanSir
@@ -0,0 +1,11 @@
1
+ web_search/__init__.py,sha256=bpu1gpf9tq3mOAoaGMM-8S6GBw2GzRAG6ClHGlp-CVw,4607
2
+ web_search/blocks.py,sha256=duMWavXLkUpoChZhA8NPj3EVqWaJR0TbDqYP8wwD5B4,9140
3
+ web_search/config.py,sha256=DhLiERBJR2V5Boglf7Aq9Rbc4vsvLIh67CrLDIPeqA0,398
4
+ web_search/web_searcher.py,sha256=760WTBGusxYntigGi5Wsbm2rRHEWq3sTwfNlf3ew3b0,20919
5
+ web_search/example/roleplayWithWebSearch.yaml,sha256=C-dGy3z8gcRcmxzurssP-kPRLqMf1TYR-nnNUaJjISE,7468
6
+ chatgpt_mirai_qq_bot_web_search-0.2.5.dist-info/LICENSE,sha256=ILBn-G3jdarm2w8oOrLmXeJNU3czuJvVhDLBASWdhM8,34522
7
+ chatgpt_mirai_qq_bot_web_search-0.2.5.dist-info/METADATA,sha256=NMPI_KliHYAFbH5uqNYKDTtO1j_tIrC9wRkycBttLDY,1734
8
+ chatgpt_mirai_qq_bot_web_search-0.2.5.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
9
+ chatgpt_mirai_qq_bot_web_search-0.2.5.dist-info/entry_points.txt,sha256=o3kRDSdSmSdnCKlK6qS57aN0WpI4ab-Nxub2NwUrjf0,64
10
+ chatgpt_mirai_qq_bot_web_search-0.2.5.dist-info/top_level.txt,sha256=PoNm8MJYw_y8RTMaNlY0ePLoNHxVUAE2IHDuL5fFubI,11
11
+ chatgpt_mirai_qq_bot_web_search-0.2.5.dist-info/RECORD,,
web_search/blocks.py CHANGED
@@ -8,7 +8,7 @@ from kirara_ai.llm.format.response import LLMChatResponse
8
8
  from kirara_ai.ioc.container import DependencyContainer
9
9
  import re
10
10
  from kirara_ai.im.message import IMMessage
11
-
11
+ from kirara_ai.im.sender import ChatSender, ChatType
12
12
  def get_options_provider(container: DependencyContainer, block: Block) -> List[str]:
13
13
  return ["bing", "google", "baidu"]
14
14
  class WebSearchBlock(Block):
@@ -73,7 +73,7 @@ class WebSearchBlock(Block):
73
73
  proxy = self.proxy,
74
74
  )
75
75
  )
76
- return {"results": "\n以下是联网搜索的结果:\n-- 搜索结果开始 --"+results+"\n-- 搜索结果结束 --"}
76
+ return {"results": "\n以下是联网搜索的结果:\n-- 搜索结果开始 --\n"+results+"\n-- 搜索结果结束 --\n"}
77
77
  except Exception as e:
78
78
  print(e)
79
79
  return {"results": f"搜索失败: {str(e)}"}
@@ -162,7 +162,7 @@ class AppendSystemPromptBlock(Block):
162
162
  results = kwargs["results"]
163
163
  messages: List[LLMChatMessage] = kwargs["messages"]
164
164
 
165
- if messages and len(messages) > 0:
165
+ if messages and len(messages) > 0 and results and isinstance(content,str):
166
166
  # 在第一条消息内容后面附加搜索结果
167
167
  messages[0].content = messages[0].content + f"{results}"
168
168
 
@@ -214,14 +214,14 @@ class DouyinVideoSearchBlock(Block):
214
214
  except RuntimeError:
215
215
  loop = asyncio.new_event_loop()
216
216
  asyncio.set_event_loop(loop)
217
-
217
+ sender = self.container.resolve(IMMessage).sender
218
218
  results = loop.run_until_complete(
219
219
  self.searcher.search_douyin_videos(
220
220
  keyword=keyword,
221
221
  count=count,
222
222
  timeout=self.timeout,
223
223
  proxy=self.proxy,
224
- sender = self.container.resolve(IMMessage).sender.user_id
224
+ sender = sender.group_id if sender.chat_type == ChatType.GROUP else sender.user_id
225
225
  )
226
226
  )
227
227
  return {"results": f"\n以下是抖音视频搜索结果:\n{results}"}
@@ -72,7 +72,7 @@ class WebSearcher:
72
72
 
73
73
  # 合并所有选项到一个字典
74
74
  context_options = {
75
- 'headless': False,
75
+ 'headless': True,
76
76
  'chromium_sandbox': False,
77
77
  'slow_mo': 50, # 减慢操作速度,更像人类
78
78
  'args': [
@@ -1,11 +0,0 @@
1
- web_search/__init__.py,sha256=bpu1gpf9tq3mOAoaGMM-8S6GBw2GzRAG6ClHGlp-CVw,4607
2
- web_search/blocks.py,sha256=NJqWOAp7X-WMM3c3Xn3qLb9IVV090W3MqELHZTAw8tk,8959
3
- web_search/config.py,sha256=DhLiERBJR2V5Boglf7Aq9Rbc4vsvLIh67CrLDIPeqA0,398
4
- web_search/web_searcher.py,sha256=d6sFvaMMcm0vXPDRjAVPAvUcrPN6fU7cxbxikFyE23w,20920
5
- web_search/example/roleplayWithWebSearch.yaml,sha256=C-dGy3z8gcRcmxzurssP-kPRLqMf1TYR-nnNUaJjISE,7468
6
- chatgpt_mirai_qq_bot_web_search-0.2.3.dist-info/LICENSE,sha256=ILBn-G3jdarm2w8oOrLmXeJNU3czuJvVhDLBASWdhM8,34522
7
- chatgpt_mirai_qq_bot_web_search-0.2.3.dist-info/METADATA,sha256=vlaZCwGj4Rts9xD-zq7nabGU7MC0vDHDP4nqFmDKQec,1734
8
- chatgpt_mirai_qq_bot_web_search-0.2.3.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
9
- chatgpt_mirai_qq_bot_web_search-0.2.3.dist-info/entry_points.txt,sha256=o3kRDSdSmSdnCKlK6qS57aN0WpI4ab-Nxub2NwUrjf0,64
10
- chatgpt_mirai_qq_bot_web_search-0.2.3.dist-info/top_level.txt,sha256=PoNm8MJYw_y8RTMaNlY0ePLoNHxVUAE2IHDuL5fFubI,11
11
- chatgpt_mirai_qq_bot_web_search-0.2.3.dist-info/RECORD,,