pycoze 0.1.440__py3-none-any.whl → 0.1.442__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/chat.py +5 -1
- pycoze/bot/chat_base.py +1 -2
- pycoze/bot/lib.py +1 -0
- pycoze/bot/prompt.md +4 -0
- pycoze/bot/tools.py +23 -2
- {pycoze-0.1.440.dist-info → pycoze-0.1.442.dist-info}/METADATA +1 -1
- {pycoze-0.1.440.dist-info → pycoze-0.1.442.dist-info}/RECORD +10 -10
- {pycoze-0.1.440.dist-info → pycoze-0.1.442.dist-info}/LICENSE +0 -0
- {pycoze-0.1.440.dist-info → pycoze-0.1.442.dist-info}/WHEEL +0 -0
- {pycoze-0.1.440.dist-info → pycoze-0.1.442.dist-info}/top_level.txt +0 -0
pycoze/bot/chat.py
CHANGED
@@ -8,7 +8,7 @@ from pycoze import utils
|
|
8
8
|
import tempfile
|
9
9
|
import re
|
10
10
|
import datetime
|
11
|
-
|
11
|
+
import atexit
|
12
12
|
|
13
13
|
|
14
14
|
def eclipse_tool_result(text, threshold=100):
|
@@ -78,6 +78,10 @@ async def run_with_interrupt_check(
|
|
78
78
|
check_task = asyncio.create_task(
|
79
79
|
check_interrupt_file(0.5, interrupt_file, chat_task)
|
80
80
|
)
|
81
|
+
def cleanup():
|
82
|
+
chat_task.cancel()
|
83
|
+
check_task.cancel()
|
84
|
+
atexit.register(cleanup)
|
81
85
|
result = await chat_task
|
82
86
|
return result
|
83
87
|
except asyncio.CancelledError:
|
pycoze/bot/chat_base.py
CHANGED
pycoze/bot/lib.py
CHANGED
pycoze/bot/prompt.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
{{ prompt }}
|
2
2
|
|
3
|
+
{% if use_draft %}
|
4
|
+
Think step by step, but only keep a minimum draft for each thinking step, with 5 words at most. Return the answer at the end of the response after a separator ####.
|
5
|
+
{% endif %}
|
6
|
+
|
3
7
|
{% if has_any_tool %}
|
4
8
|
==== Tool Usage
|
5
9
|
You have access to a set of tools running on the {{ system }} system that are executed upon user approval. Only one tool can be used per message, and you will receive the result of the tool's execution in the user's response. You progressively use these tools to accomplish tasks, with each tool's usage being based on the outcome of the previous tool.
|
pycoze/bot/tools.py
CHANGED
@@ -132,17 +132,38 @@ class ReplaceInFileTool(Tool):
|
|
132
132
|
with open(path, "r", encoding="utf-8") as f:
|
133
133
|
content = f.read()
|
134
134
|
|
135
|
+
# 初始化成功和失败的计数器
|
136
|
+
success_count = 0
|
137
|
+
failure_count = 0
|
138
|
+
failure_details = [] # 用于记录匹配失败的详细信息
|
139
|
+
|
135
140
|
# 处理差异内容
|
136
141
|
diff_content = self.params["diff"]
|
137
142
|
for diff_block in diff_content.split("<<<<<<< SEARCH")[1:]:
|
138
143
|
search, replace = diff_block.split("=======")
|
139
144
|
search = search.strip()
|
140
145
|
replace = replace.split(">>>>>>> REPLACE")[0].strip()
|
141
|
-
|
146
|
+
if search in content:
|
147
|
+
content = content.replace(search, replace, 1)
|
148
|
+
success_count += 1
|
149
|
+
else:
|
150
|
+
failure_count += 1
|
151
|
+
# 记录匹配失败的前20个字符
|
152
|
+
failure_details.append(f"Failed to match: '{search[:20]}...'")
|
142
153
|
|
143
154
|
with open(path, "w", encoding="utf-8") as f:
|
144
155
|
f.write(content)
|
145
|
-
|
156
|
+
|
157
|
+
# 构建返回结果
|
158
|
+
result = (
|
159
|
+
f"The content of the file {path} has been replaced successfully. "
|
160
|
+
f"Successfully replaced {success_count} occurrences. "
|
161
|
+
f"Failed to replace {failure_count} occurrences."
|
162
|
+
)
|
163
|
+
if failure_details:
|
164
|
+
result += "\nFailure details:\n" + "\n".join(failure_details)
|
165
|
+
|
166
|
+
return result
|
146
167
|
|
147
168
|
|
148
169
|
class SearchFilesTool(Tool):
|
@@ -10,12 +10,12 @@ pycoze/api/lib/view.py,sha256=_PIpTfeuTPPlMDKshMGsqFQYMq7ZiO4Hg5XwHwDoU60,7357
|
|
10
10
|
pycoze/api/lib/web.py,sha256=l56koyd7RUzK-4mQE_5W-POyqSD79mvwusIN0rxND-Q,2347
|
11
11
|
pycoze/api/lib/window.py,sha256=dkzWfLwn5pE_L0DfQ38K8nx9tQyT5KO-GYyXi0rytFc,2073
|
12
12
|
pycoze/bot/__init__.py,sha256=rL3Q-ycczRpSFfKn84fg3QBl5k22WpyeIU5qOEjEby8,79
|
13
|
-
pycoze/bot/chat.py,sha256=
|
14
|
-
pycoze/bot/chat_base.py,sha256=
|
15
|
-
pycoze/bot/lib.py,sha256=
|
13
|
+
pycoze/bot/chat.py,sha256=bScsMc0hGh2NlvhQxzWEbnA_WXU9JdAJv-rx27SpEB8,6554
|
14
|
+
pycoze/bot/chat_base.py,sha256=I_QOB22Ud1HpBDg8kip9AW4stGbbLOrKpZPSMCHEMAE,12567
|
15
|
+
pycoze/bot/lib.py,sha256=RivPA2f5fqzqbW6jL0sx9X9pwgFPxwkk8lt62CWvaZo,7255
|
16
16
|
pycoze/bot/message.py,sha256=udnIi-h4QgGzkbr_5VcAsVGjoLp9wXJSfBCeuOz7_Bk,802
|
17
|
-
pycoze/bot/prompt.md,sha256=
|
18
|
-
pycoze/bot/tools.py,sha256=
|
17
|
+
pycoze/bot/prompt.md,sha256=UtwZ31wFvNtvM9ZTA4BU2yT1Rb-qnUdU3Ny1O37Tt3Q,14077
|
18
|
+
pycoze/bot/tools.py,sha256=BWMdwvqLzvcyaW38lzxUWtc0K1V-C_qPSEZ3OKlAQvU,11108
|
19
19
|
pycoze/reference/__init__.py,sha256=zgqGqvmA9HaqytEM33B6vi0kQVk8IiCwJaXa22xsFz8,114
|
20
20
|
pycoze/reference/bot.py,sha256=UZK24Qm8kpqpwXJy_zNZeTEEDee05luXdSBeUm0NCt0,2029
|
21
21
|
pycoze/reference/lib.py,sha256=T-oBOKxkus5dTouc0oDgfRzUyi6aTyY-FF4yX7SzF5M,3755
|
@@ -31,8 +31,8 @@ pycoze/utils/arg.py,sha256=jop1tBfe5hYkHW1NSpCeaZBEznkgguBscj_7M2dWfrs,503
|
|
31
31
|
pycoze/utils/env.py,sha256=5pWlXfM1F5ZU9hhv1rHlDEanjEW5wf0nbyez9bNRqqA,559
|
32
32
|
pycoze/utils/socket.py,sha256=bZbFFRH4mfThzRqt55BAAGQ6eICx_ja4x8UGGrUdAm8,2428
|
33
33
|
pycoze/utils/text_or_file.py,sha256=gpxZVWt2DW6YiEg_MnMuwg36VNf3TX383QD_1oZNB0Y,551
|
34
|
-
pycoze-0.1.
|
35
|
-
pycoze-0.1.
|
36
|
-
pycoze-0.1.
|
37
|
-
pycoze-0.1.
|
38
|
-
pycoze-0.1.
|
34
|
+
pycoze-0.1.442.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
|
35
|
+
pycoze-0.1.442.dist-info/METADATA,sha256=j6lqjhDVXZyB9H-3cykwPuOvfKK4AWr5ji9ct9VFpEc,854
|
36
|
+
pycoze-0.1.442.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
37
|
+
pycoze-0.1.442.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
|
38
|
+
pycoze-0.1.442.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|