pycoze 0.1.206__tar.gz → 0.1.208__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. {pycoze-0.1.206 → pycoze-0.1.208}/PKG-INFO +1 -1
  2. pycoze-0.1.208/pycoze/bot/bot.py +37 -0
  3. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze.egg-info/PKG-INFO +1 -1
  4. {pycoze-0.1.206 → pycoze-0.1.208}/setup.py +1 -1
  5. pycoze-0.1.206/pycoze/bot/bot.py +0 -82
  6. {pycoze-0.1.206 → pycoze-0.1.208}/LICENSE +0 -0
  7. {pycoze-0.1.206 → pycoze-0.1.208}/README.md +0 -0
  8. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/__init__.py +0 -0
  9. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/ai/__init__.py +0 -0
  10. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/ai/vram_reserve.py +0 -0
  11. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/automation/__init__.py +0 -0
  12. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/automation/browser/__init__.py +0 -0
  13. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/automation/browser/edge_driver_manager.py +0 -0
  14. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/bot/__init__.py +0 -0
  15. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/bot/agent/__init__.py +0 -0
  16. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/bot/agent/agent.py +0 -0
  17. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/bot/agent/agent_types/__init__.py +0 -0
  18. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/bot/agent/agent_types/const.py +0 -0
  19. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/bot/agent/agent_types/openai_func_call_agent.py +0 -0
  20. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/bot/agent/assistant.py +0 -0
  21. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/bot/agent/chat.py +0 -0
  22. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/bot/agent_chat.py +0 -0
  23. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/reference/__init__.py +0 -0
  24. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/reference/bot.py +0 -0
  25. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/reference/lib.py +0 -0
  26. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/reference/tool.py +0 -0
  27. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/reference/workflow.py +0 -0
  28. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/ui/__init__.py +0 -0
  29. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/ui/base.py +0 -0
  30. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/ui/color.py +0 -0
  31. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/ui/typ.py +0 -0
  32. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/ui/ui_def.py +0 -0
  33. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/utils/__init__.py +0 -0
  34. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/utils/arg.py +0 -0
  35. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/utils/env.py +0 -0
  36. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze/utils/text_or_file.py +0 -0
  37. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze.egg-info/SOURCES.txt +0 -0
  38. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze.egg-info/dependency_links.txt +0 -0
  39. {pycoze-0.1.206 → pycoze-0.1.208}/pycoze.egg-info/top_level.txt +0 -0
  40. {pycoze-0.1.206 → pycoze-0.1.208}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycoze
3
- Version: 0.1.206
3
+ Version: 0.1.208
4
4
  Summary: Package for pycoze only!
5
5
  Author: Yuan Jie Xiong
6
6
  Author-email: aiqqqqqqq@qq.com
@@ -0,0 +1,37 @@
1
+ from langchain_core.messages import HumanMessage, AIMessage
2
+ import threading
3
+ import queue
4
+ import json
5
+ from .agent import INPUT_MESSAGE, output, CHAT_DATA, clear_chat_data
6
+ from .agent_chat import agent_chat
7
+ import asyncio
8
+
9
+ class PeekableQueue(queue.Queue):
10
+ def peek(self):
11
+ try:
12
+ return self._get()
13
+ except queue.Empty:
14
+ return None
15
+
16
+
17
+ def chat(bot_setting_file: str):
18
+ history = []
19
+ while True:
20
+ input_text = input()
21
+ if not input_text.startswith(INPUT_MESSAGE):
22
+ raise ValueError("Invalid message")
23
+ message = json.loads(input_text[len(INPUT_MESSAGE) :])
24
+ history.append(HumanMessage(message["content"]))
25
+ should_exit = threading.Event()
26
+ result = agent_chat(bot_setting_file, history, should_exit)
27
+ history.append(AIMessage(result["output"]))
28
+
29
+
30
+
31
+
32
+ def get_chat_response(bot_setting_file: str, input_text: str):
33
+ history = [HumanMessage(input_text)]
34
+ clear_chat_data()
35
+ should_exit = threading.Event()
36
+ asyncio.run(agent_chat(bot_setting_file, history, should_exit))
37
+ return CHAT_DATA["output"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycoze
3
- Version: 0.1.206
3
+ Version: 0.1.208
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.206",
5
+ version="0.1.208",
6
6
  packages=find_packages(),
7
7
  install_requires=[],
8
8
  author="Yuan Jie Xiong",
@@ -1,82 +0,0 @@
1
- import signal
2
- import sys
3
- import json
4
- from .agent import INPUT_MESSAGE, output, CHAT_DATA, clear_chat_data
5
- from .agent_chat import agent_chat
6
- from multiprocessing import Process, Event
7
- import asyncio
8
- from langchain_core.messages import HumanMessage, AIMessage
9
-
10
- # 用于标记中断请求
11
- interrupt_flag = False
12
-
13
- # 信号处理函数
14
- def handle_interrupt(signum, frame):
15
- global interrupt_flag
16
- interrupt_flag = True
17
- print("Interrupt signal received. Waiting for the current operation to complete...")
18
-
19
- # 设置信号处理器
20
- signal.signal(signal.SIGINT, handle_interrupt)
21
-
22
- def read_input():
23
- while True:
24
- try:
25
- input_text = input()
26
- if input_text.startswith(INPUT_MESSAGE):
27
- yield input_text
28
- else:
29
- raise ValueError("Invalid message")
30
- except EOFError: # 如果输入流结束,则退出循环
31
- break
32
-
33
- def chat(bot_setting_file: str):
34
- history = []
35
- for input_text in read_input():
36
- try:
37
- message = json.loads(input_text[len(INPUT_MESSAGE):])
38
- history.append(HumanMessage(message["content"]))
39
- clear_chat_data()
40
-
41
- # 创建一个事件来控制子进程的退出
42
- should_exit = Event()
43
-
44
- # 使用进程来运行 agent_chat
45
- agent_chat_process = Process(target=asyncio.run, args=(agent_chat(bot_setting_file, history, should_exit),))
46
- agent_chat_process.start()
47
-
48
- # 从管道中读取子进程的输出或错误
49
- if parent_conn.poll():
50
- result = parent_conn.recv()
51
- print(result)
52
-
53
- # 检查是否收到了中断信号
54
- while agent_chat_process.is_alive():
55
- if interrupt_flag:
56
- should_exit.set() # 设置退出标志
57
- break
58
- time.sleep(0.1) # 每隔 0.1 秒检查一次
59
-
60
- # 确保子进程已经退出
61
- agent_chat_process.join()
62
-
63
- # 如果没有收到中断信号,记录输出
64
- if not interrupt_flag:
65
- history.append(AIMessage(content=CHAT_DATA["output"]))
66
-
67
- # 重置中断标志
68
- interrupt_flag = False
69
- except json.JSONDecodeError:
70
- print("Invalid JSON format in input message.")
71
- except KeyError:
72
- print("Missing 'content' key in input message.")
73
- except Exception as e:
74
- print(f"An error occurred: {e}")
75
-
76
-
77
- def get_chat_response(bot_setting_file: str, input_text: str):
78
- history = [HumanMessage(input_text)]
79
- clear_chat_data()
80
- should_exit = threading.Event()
81
- asyncio.run(agent_chat(bot_setting_file, history, should_exit))
82
- return CHAT_DATA["output"]
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