pycoze 0.1.233__tar.gz → 0.1.237__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. {pycoze-0.1.233 → pycoze-0.1.237}/PKG-INFO +1 -1
  2. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/bot/agent/agent.py +2 -3
  3. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/bot/agent/agent_types/openai_func_call_agent.py +1 -7
  4. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/bot/agent/assistant.py +1 -2
  5. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/bot/agent_chat.py +7 -24
  6. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/bot/bot.py +0 -1
  7. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze.egg-info/PKG-INFO +1 -1
  8. {pycoze-0.1.233 → pycoze-0.1.237}/setup.py +1 -1
  9. {pycoze-0.1.233 → pycoze-0.1.237}/LICENSE +0 -0
  10. {pycoze-0.1.233 → pycoze-0.1.237}/README.md +0 -0
  11. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/__init__.py +0 -0
  12. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/ai/__init__.py +0 -0
  13. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/ai/llm/__init__.py +0 -0
  14. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/ai/llm/chat.py +0 -0
  15. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/ai/llm/text_to_image_prompt.py +0 -0
  16. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/ai/llm/think.py +0 -0
  17. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/ai/vram_reserve.py +0 -0
  18. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/automation/__init__.py +0 -0
  19. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/automation/browser/__init__.py +0 -0
  20. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/automation/browser/edge_driver_manager.py +0 -0
  21. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/bot/__init__.py +0 -0
  22. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/bot/agent/__init__.py +0 -0
  23. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/bot/agent/agent_types/__init__.py +0 -0
  24. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/bot/agent/agent_types/const.py +0 -0
  25. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/bot/agent/chat.py +0 -0
  26. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/reference/__init__.py +0 -0
  27. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/reference/bot.py +0 -0
  28. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/reference/lib.py +0 -0
  29. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/reference/tool.py +0 -0
  30. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/reference/workflow.py +0 -0
  31. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/ui/__init__.py +0 -0
  32. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/ui/base.py +0 -0
  33. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/ui/color.py +0 -0
  34. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/ui/typ.py +0 -0
  35. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/ui/ui_def.py +0 -0
  36. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/utils/__init__.py +0 -0
  37. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/utils/arg.py +0 -0
  38. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/utils/env.py +0 -0
  39. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze/utils/text_or_file.py +0 -0
  40. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze.egg-info/SOURCES.txt +0 -0
  41. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze.egg-info/dependency_links.txt +0 -0
  42. {pycoze-0.1.233 → pycoze-0.1.237}/pycoze.egg-info/top_level.txt +0 -0
  43. {pycoze-0.1.233 → pycoze-0.1.237}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycoze
3
- Version: 0.1.233
3
+ Version: 0.1.237
4
4
  Summary: Package for pycoze only!
5
5
  Author: Yuan Jie Xiong
6
6
  Author-email: aiqqqqqqq@qq.com
@@ -13,7 +13,7 @@ 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):
16
+ async def run_agent(agent, inputs: list):
17
17
  exist_ids = set()
18
18
  content_list = []
19
19
  async for event in agent.astream_events(inputs, version="v2"):
@@ -29,7 +29,7 @@ async def run_agent(agent, inputs: list, tool_compatibility_mode: bool):
29
29
  input_list = event["data"]["input"]
30
30
  for msg in input_list:
31
31
  if isinstance(msg, HumanMessage) or isinstance(msg, SystemMessage):
32
- if not tool_compatibility_mode or not msg.content.startswith(HumanToolString):
32
+ if not msg.content.startswith(HumanToolString):
33
33
  content_list = [] # 防止内容重复
34
34
  if isinstance(msg, AIMessage) and not isinstance(
35
35
  msg, AIMessageChunk
@@ -84,7 +84,6 @@ if __name__ == "__main__":
84
84
  tools=[python_tool],
85
85
  llm=chat,
86
86
  assistant_message="请以女友的口吻回答,输出不小于100字,可以随便说点其他的",
87
- tool_compatibility_mode=False,
88
87
  )
89
88
 
90
89
  inputs = [HumanMessage(content="计算根号7+根号88")]
@@ -75,7 +75,6 @@ def create_openai_func_call_agent_executor(
75
75
  tools: list[BaseTool],
76
76
  llm: LanguageModelLike,
77
77
  system_message: str,
78
- tool_compatibility_mode: str,
79
78
  **kwargs
80
79
  ):
81
80
 
@@ -156,12 +155,7 @@ def create_openai_func_call_agent_executor(
156
155
  additional_kwargs={"name": tool_call["function"]["name"]},
157
156
  )
158
157
  tool_messages.append(message)
159
- if tool_compatibility_mode:
160
- # HumanMessage
161
- tool_msgs_str = repr(tool_messages)
162
- tool_messages = [
163
- HumanMessage(content=HumanToolString + tool_msgs_str)
164
- ]
158
+
165
159
  return tool_messages
166
160
 
167
161
  workflow = MessageGraph()
@@ -18,11 +18,10 @@ class Runnable(RunnableBinding):
18
18
  tools: Sequence[BaseTool],
19
19
  llm: LanguageModelLike,
20
20
  assistant_message: str,
21
- tool_compatibility_mode: bool
22
21
  ) -> None:
23
22
 
24
23
  agent_executor = create_openai_func_call_agent_executor(
25
- tools, llm, assistant_message, tool_compatibility_mode
24
+ tools, llm, assistant_message
26
25
  )
27
26
  agent_executor = agent_executor.with_config({"recursion_limit": 50})
28
27
  super().__init__(
@@ -10,8 +10,6 @@ from langchain_core.utils.function_calling import convert_to_openai_tool
10
10
  import os
11
11
 
12
12
  cfg = utils.read_json_file("llm.json")
13
- if cfg["model"].startswith("qwen-") or cfg["model"].startswith("deepseek"):
14
- cfg["toolCompatibilityMode"] = False
15
13
 
16
14
 
17
15
  def load_role_setting(bot_setting_file: str):
@@ -45,10 +43,10 @@ async def check_interrupt_file(interval, interrupt_file,agent_task):
45
43
  agent_task.cancel()
46
44
  break
47
45
 
48
- async def run_with_interrupt_check(agent, history, tool_compatibility_mode, interrupt_file, check_interval=1):
46
+ async def run_with_interrupt_check(agent, history, interrupt_file, check_interval=1):
49
47
  clear_chat_data()
50
48
  try:
51
- agent_task = asyncio.create_task(run_agent(agent, history, tool_compatibility_mode))
49
+ agent_task = asyncio.create_task(run_agent(agent, history))
52
50
  check_task = asyncio.create_task(check_interrupt_file(check_interval, interrupt_file, agent_task))
53
51
  result = await agent_task
54
52
  return result
@@ -59,6 +57,8 @@ async def run_with_interrupt_check(agent, history, tool_compatibility_mode, inte
59
57
  print(traceback.format_exc())
60
58
  return None # 返回 None 或者处理异常后的结果
61
59
  finally:
60
+ if not agent_task.done():
61
+ agent_task.cancel()
62
62
  # 确保即使发生异常也会取消检查任务
63
63
  if not check_task.done():
64
64
  check_task.cancel()
@@ -86,35 +86,18 @@ async def agent_chat(bot_setting_file, history):
86
86
  ], # 停用deepseek的工具调用标记,不然会虚构工具调用过程和结果
87
87
  )
88
88
  prompt = role_setting["prompt"]
89
- if (
90
- (cfg["model"].startswith("deepseek")
91
- or cfg["toolCompatibilityMode"])
92
- and len(abilities) > 0
93
- ):
94
- prompt += """
95
- 作为一个AI,你如果不确定结果,请务必使用工具查询。
96
- 你可以通过下面的方式使用工具,并耐心等待工具返回结果。
97
- 如果你需要调用工具,请使用以正确markdown中的json代码格式进行结尾(务必保证json格式正确,不要出现反斜杠未转义等问题):
98
- ```json
99
- {"name": 函数名, "parameters": 参数词典}
100
- ```
101
- """
102
- if cfg["model"].startswith("yi-"):
103
- prompt += "\nAvailable functions:\n"
104
- for t in abilities:
105
- prompt += f"\n```json\n{json.dumps(convert_to_openai_tool(t))}\n```"
89
+
106
90
  agent = Runnable(
107
91
  agent_execution_mode="FuncCall",
108
92
  tools=abilities,
109
93
  llm=chat,
110
94
  assistant_message=prompt,
111
- tool_compatibility_mode=cfg["toolCompatibilityMode"],
112
95
  )
113
96
  params = utils.read_params_file()
114
97
  if "interruptFile" in params:
115
98
  interrupt_file_path = params["interruptFile"]
116
- result = await run_with_interrupt_check(agent, history, cfg["toolCompatibilityMode"], interrupt_file_path)
99
+ result = await run_with_interrupt_check(agent, history,interrupt_file_path)
117
100
  else:
118
- result = await run_agent(agent, history, cfg["toolCompatibilityMode"])
101
+ result = await run_agent(agent, history)
119
102
  return result
120
103
 
@@ -1,5 +1,4 @@
1
1
  from langchain_core.messages import HumanMessage, AIMessage
2
- import threading
3
2
  import json
4
3
  from .agent import INPUT_MESSAGE, output, CHAT_DATA, clear_chat_data
5
4
  from .agent_chat import agent_chat
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycoze
3
- Version: 0.1.233
3
+ Version: 0.1.237
4
4
  Summary: Package for pycoze only!
5
5
  Author: Yuan Jie Xiong
6
6
  Author-email: aiqqqqqqq@qq.com
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="pycoze",
5
- version="0.1.233",
5
+ version="0.1.237",
6
6
  packages=find_packages(),
7
7
  install_requires=[],
8
8
  author="Yuan Jie Xiong",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes