pycoze 0.1.209__py3-none-any.whl → 0.1.210__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.
pycoze/bot/agent/agent.py CHANGED
@@ -13,13 +13,10 @@ from langchain_core.agents import AgentFinish
13
13
  from .agent_types.const import HumanToolString
14
14
 
15
15
 
16
- async def run_agent(agent, inputs: list, tool_compatibility_mode: bool, should_exit):
16
+ async def run_agent(agent, inputs: list, tool_compatibility_mode: bool):
17
17
  exist_ids = set()
18
18
  content_list = []
19
19
  async for event in agent.astream_events(inputs, version="v2"):
20
- if should_exit.is_set():
21
- break
22
-
23
20
  kind = event["event"]
24
21
  if kind == "on_chain_end":
25
22
  if "data" in event:
pycoze/bot/agent_chat.py CHANGED
@@ -34,7 +34,7 @@ def load_abilities(bot_setting_file: str):
34
34
  return abilities
35
35
 
36
36
 
37
- async def agent_chat(bot_setting_file, history, should_exit):
37
+ async def agent_chat(bot_setting_file, history):
38
38
  role_setting = load_role_setting(bot_setting_file)
39
39
  abilities = load_abilities(bot_setting_file)
40
40
 
@@ -77,6 +77,9 @@ async def agent_chat(bot_setting_file, history, should_exit):
77
77
  assistant_message=prompt,
78
78
  tool_compatibility_mode=cfg["toolCompatibilityMode"],
79
79
  )
80
- result = await run_agent(agent, history, cfg["toolCompatibilityMode"], should_exit)
81
- if not should_exit.is_set():
82
- output("assistant", result)
80
+ try:
81
+ result = await run_agent(agent, history, cfg["toolCompatibilityMode"])
82
+ return result
83
+ except KeyboardInterrupt:
84
+ return CHAT_DATA["info"]
85
+
pycoze/bot/bot.py CHANGED
@@ -22,9 +22,8 @@ def chat(bot_setting_file: str):
22
22
  raise ValueError("Invalid message")
23
23
  message = json.loads(input_text[len(INPUT_MESSAGE) :])
24
24
  history.append(HumanMessage(message["content"]))
25
- should_exit = threading.Event()
26
- asyncio.run(agent_chat(bot_setting_file, history, should_exit))
27
- history.append(AIMessage(CHAT_DATA["output"]))
25
+ result = asyncio.run(agent_chat(bot_setting_file, history))
26
+ history.append(AIMessage(result))
28
27
 
29
28
 
30
29
 
@@ -32,6 +31,5 @@ def chat(bot_setting_file: str):
32
31
  def get_chat_response(bot_setting_file: str, input_text: str):
33
32
  history = [HumanMessage(input_text)]
34
33
  clear_chat_data()
35
- should_exit = threading.Event()
36
- asyncio.run(agent_chat(bot_setting_file, history, should_exit))
34
+ asyncio.run(agent_chat(bot_setting_file, history))
37
35
  return CHAT_DATA["output"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycoze
3
- Version: 0.1.209
3
+ Version: 0.1.210
4
4
  Summary: Package for pycoze only!
5
5
  Author: Yuan Jie Xiong
6
6
  Author-email: aiqqqqqqq@qq.com
@@ -5,10 +5,10 @@ pycoze/automation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
5
5
  pycoze/automation/browser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  pycoze/automation/browser/edge_driver_manager.py,sha256=gpgseunph5owZH6EskSYthuhey2SU3UP204gY0yIcuI,3022
7
7
  pycoze/bot/__init__.py,sha256=6HHMxDQVOyZM9dtSjQm9tjGnhj4h7CixD0JOvEwTi48,41
8
- pycoze/bot/agent_chat.py,sha256=hr0jGTd-lvLSe4vCcvaN2rKhB7BMBcVBtI1FpVa6ngs,3016
9
- pycoze/bot/bot.py,sha256=MtQcntUrKqUhxMbInZYz0l3muuO2X_C9HFjYLXndFiE,1159
8
+ pycoze/bot/agent_chat.py,sha256=4J-y7lSM2ULQQYIUB0L4i94m0KyeB4Gdf2U3zhVMOG4,3033
9
+ pycoze/bot/bot.py,sha256=A1EryCW6WCnb6jIKc0V58Qzv6qQebKTfQxhcLp8Ngtc,1051
10
10
  pycoze/bot/agent/__init__.py,sha256=3wE8_FFQS8j2BY-g9Cr-onV0POEvDRZaw_NCzpqrNus,265
11
- pycoze/bot/agent/agent.py,sha256=Ueste4xWvkQFk5Giklv4c-kcxiPL-D-KafzZ4DONosY,3613
11
+ pycoze/bot/agent/agent.py,sha256=chUgNZh6v6375L_Y2dBEAaLJyfmw4SygYjVVrDN8VIk,3548
12
12
  pycoze/bot/agent/assistant.py,sha256=3iLxnRvf_ia0cP-FHK5Fv4ylltlnzPq1KscRCFYqjkc,1147
13
13
  pycoze/bot/agent/chat.py,sha256=mubOCAHvA6VtyE6N40elI6KrP6A69uB_G6ihE3G_Vi4,860
14
14
  pycoze/bot/agent/agent_types/__init__.py,sha256=zmU2Kmrv5mCdfg-QlPn2H6pWxbGeq8s7YTqLhpzJC6k,179
@@ -28,8 +28,8 @@ pycoze/utils/__init__.py,sha256=Gi5EnrWZGMD2JRejgV4c_VLCXyvA2wwBFI_niDF5MUE,110
28
28
  pycoze/utils/arg.py,sha256=GtfGbMTMdaK75Fwh6MpUe1pCA5X6Ep4LFG7a72YrzjI,525
29
29
  pycoze/utils/env.py,sha256=W04lhvTHhAAC6EldP6kk2xrctqtu8K6kl1vDLZDNeh8,561
30
30
  pycoze/utils/text_or_file.py,sha256=gpxZVWt2DW6YiEg_MnMuwg36VNf3TX383QD_1oZNB0Y,551
31
- pycoze-0.1.209.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
32
- pycoze-0.1.209.dist-info/METADATA,sha256=M10jwT4s0ZFcC1Cs2df86tpvX0D_cOb5AOfNnLEoT5o,726
33
- pycoze-0.1.209.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
34
- pycoze-0.1.209.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
35
- pycoze-0.1.209.dist-info/RECORD,,
31
+ pycoze-0.1.210.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
32
+ pycoze-0.1.210.dist-info/METADATA,sha256=51S7PW9RP7qdVpol_GmP_1IXKvJNDCgIDLrcRw0gxmk,726
33
+ pycoze-0.1.210.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
34
+ pycoze-0.1.210.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
35
+ pycoze-0.1.210.dist-info/RECORD,,