pycoze 0.1.31__py3-none-any.whl → 0.1.32__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/bot.py CHANGED
@@ -26,31 +26,33 @@ def load_tools(bot_setting_file: str):
26
26
  return tools
27
27
 
28
28
 
29
- def chat(bot_setting_file: str):
29
+ def run_agent(bot_setting_file, history):
30
+ role_setting = load_role_setting(bot_setting_file)
31
+ tools = load_tools(bot_setting_file)
32
+ with open(llm_file, "r", encoding="utf-8") as f:
33
+ cfg = json.load(f)
34
+ chat = ChatOpenAI(
35
+ api_key=cfg["apiKey"],
36
+ base_url=cfg["baseURL"],
37
+ model=cfg["model"],
38
+ temperature=role_setting["temperature"],
39
+ )
40
+
41
+ agent = Runnable(
42
+ agent_execution_mode="FuncCall", # 'FuncCall' or 'ReAct',大模型支持FuncCall的话就用FuncCall
43
+ tools=tools,
44
+ llm=chat,
45
+ assistant_message=role_setting["prompt"],
46
+ )
47
+ return asyncio.run(run_agent(agent, history))
48
+
30
49
 
50
+ def chat(bot_setting_file: str):
31
51
  while True:
32
52
  input_text = input()
33
- role_setting = load_role_setting(bot_setting_file)
34
- tools = load_tools(bot_setting_file)
35
53
  if not input_text.startswith(INPUT_MESSAGE):
36
54
  raise ValueError("Invalid message")
37
55
  messages = json.loads(input_text[len(INPUT_MESSAGE) :])
38
-
39
- with open(llm_file, "r", encoding="utf-8") as f:
40
- cfg = json.load(f)
41
- chat = ChatOpenAI(
42
- api_key=cfg["apiKey"],
43
- base_url=cfg["baseURL"],
44
- model=cfg["model"],
45
- temperature=role_setting["temperature"],
46
- )
47
-
48
- agent = Runnable(
49
- agent_execution_mode="FuncCall", # 'FuncCall' or 'ReAct',大模型支持FuncCall的话就用FuncCall
50
- tools=tools,
51
- llm=chat,
52
- assistant_message=role_setting["prompt"],
53
- )
54
56
  history = []
55
57
  for message in messages:
56
58
  if message["role"] == "assistant":
@@ -61,5 +63,5 @@ def chat(bot_setting_file: str):
61
63
  history += [SystemMessage(content=message["content"])]
62
64
  else:
63
65
  raise ValueError("Invalid message")
64
- result = asyncio.run(run_agent(agent, history))
66
+ result = run_agent(bot_setting_file, history)
65
67
  output("assistant", result, history)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycoze
3
- Version: 0.1.31
3
+ Version: 0.1.32
4
4
  Summary: Package for pycoze only!
5
5
  Author: Yuan Jie Xiong
6
6
  Author-email: aiqqqqqqq@qq.com
@@ -2,7 +2,7 @@ pycoze/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  pycoze/module.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  pycoze/bot/__init__.py,sha256=pciDtfcIXda7iFt9uI5Fpm0JKpGBhdXHmJv4966WTVU,21
4
4
  pycoze/bot/base.py,sha256=GWYDVGGtiCpk6gv-163cAbDid_IsnMe5jTj7eZUMJQU,2679
5
- pycoze/bot/bot.py,sha256=c8xje38_BMf4RgkWNDDuGBelHHszosMdYZevGD8dk-c,2225
5
+ pycoze/bot/bot.py,sha256=mus0g9OMsH0VKOhhk3xmwIxhPkb92xfRsyce0BumQao,2251
6
6
  pycoze/bot/agent/__init__.py,sha256=IaYqQCJ3uBor92JdOxI_EY4HtYOHgej8lijr3UrN1Vc,161
7
7
  pycoze/bot/agent/agent.py,sha256=vDbTCorUL6Eh2Az4uzwGsLa3Hp4EPcOkq62JpQXt8-s,3435
8
8
  pycoze/bot/agent/assistant.py,sha256=QLeWaPi415P9jruYOm8qcIbC94cXXAhJYmLTkyC9NTQ,1267
@@ -21,8 +21,8 @@ pycoze/ui/ui_def.py,sha256=CNFYH8NC-WYmbceIPpxsRr9H6O006pMKukx7U-BOE1Q,3744
21
21
  pycoze/utils/__init__.py,sha256=KExBkotf23dr2NfTEouWke5nJB1q2IuDXgHrmuyd95k,73
22
22
  pycoze/utils/arg.py,sha256=rRujm1zKc0XlnNlpIJ6JAAaFiTzDGmL_RliIpSc5OD8,724
23
23
  pycoze/utils/text_or_file.py,sha256=gpxZVWt2DW6YiEg_MnMuwg36VNf3TX383QD_1oZNB0Y,551
24
- pycoze-0.1.31.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
25
- pycoze-0.1.31.dist-info/METADATA,sha256=uUXKqs4ukQy4dj2MHEabHQPWu8IdK-sckxW0R4GV5kY,719
26
- pycoze-0.1.31.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
27
- pycoze-0.1.31.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
28
- pycoze-0.1.31.dist-info/RECORD,,
24
+ pycoze-0.1.32.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
25
+ pycoze-0.1.32.dist-info/METADATA,sha256=n98a0u3ipHtexw7qRCkCDJG5r8rCG_OKLphc-t5J4VY,719
26
+ pycoze-0.1.32.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
27
+ pycoze-0.1.32.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
28
+ pycoze-0.1.32.dist-info/RECORD,,