beswarm 0.2.72__py3-none-any.whl → 0.2.75__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.
- beswarm/agents/planact.py +5 -4
- beswarm/aient/aient/core/response.py +5 -6
- beswarm/aient/aient/models/chatgpt.py +19 -1
- beswarm/tools/subtasks.py +4 -1
- {beswarm-0.2.72.dist-info → beswarm-0.2.75.dist-info}/METADATA +1 -1
- {beswarm-0.2.72.dist-info → beswarm-0.2.75.dist-info}/RECORD +8 -8
- {beswarm-0.2.72.dist-info → beswarm-0.2.75.dist-info}/WHEEL +0 -0
- {beswarm-0.2.72.dist-info → beswarm-0.2.75.dist-info}/top_level.txt +0 -0
beswarm/agents/planact.py
CHANGED
@@ -12,10 +12,10 @@ from typing import List, Dict, Union
|
|
12
12
|
|
13
13
|
from ..broker import MessageBroker
|
14
14
|
from ..aient.aient.models import chatgpt
|
15
|
-
from ..aient.aient.models.chatgpt import ModelNotFoundError, TaskComplete, RetryFailedError
|
16
15
|
from ..aient.aient.plugins import get_function_call_list, registry
|
17
16
|
from ..prompt import worker_system_prompt, instruction_system_prompt
|
18
17
|
from ..utils import extract_xml_content, get_current_screen_image_message, replace_xml_content, register_mcp_tools, setup_logger
|
18
|
+
from ..aient.aient.models.chatgpt import ModelNotFoundError, TaskComplete, RetryFailedError, InputTokenCountExceededError, BadRequestError
|
19
19
|
|
20
20
|
try:
|
21
21
|
from importlib import metadata
|
@@ -154,11 +154,12 @@ class InstructionAgent(BaseAgent):
|
|
154
154
|
self.logger.error("❌ Commander retry failed, retrying...")
|
155
155
|
self.broker.publish(message, self.error_topic)
|
156
156
|
return
|
157
|
-
|
158
|
-
if "'status_code': 413" in raw_response or \
|
159
|
-
"'status_code': 400" in raw_response:
|
157
|
+
except InputTokenCountExceededError as e:
|
160
158
|
self.broker.publish({"status": "error", "result": "The request body is too long, please try again."}, self.status_topic)
|
161
159
|
return
|
160
|
+
except BadRequestError as e:
|
161
|
+
self.broker.publish({"status": "error", "result": "Bad request error!"}, self.status_topic)
|
162
|
+
return
|
162
163
|
|
163
164
|
self.broker.publish({"status": "new_message", "result": "\n🤖 指令智能体:\n" + raw_response}, self.status_topic)
|
164
165
|
|
@@ -21,13 +21,12 @@ async def check_response(response, error_log):
|
|
21
21
|
return {"error": f"{error_log} HTTP Error", "status_code": response.status_code, "details": error_json}
|
22
22
|
return None
|
23
23
|
|
24
|
-
async def gemini_json_poccess(
|
24
|
+
async def gemini_json_poccess(response_json):
|
25
25
|
promptTokenCount = 0
|
26
26
|
candidatesTokenCount = 0
|
27
27
|
totalTokenCount = 0
|
28
28
|
image_base64 = None
|
29
29
|
|
30
|
-
response_json = await asyncio.to_thread(json.loads, response_str)
|
31
30
|
json_data = safe_get(response_json, "candidates", 0, "content", default=None)
|
32
31
|
finishReason = safe_get(response_json, "candidates", 0 , "finishReason", default=None)
|
33
32
|
if finishReason:
|
@@ -48,7 +47,7 @@ async def gemini_json_poccess(response_str):
|
|
48
47
|
|
49
48
|
function_call_name = safe_get(json_data, "functionCall", "name", default=None)
|
50
49
|
function_full_response = safe_get(json_data, "functionCall", "args", default="")
|
51
|
-
function_full_response = json.dumps
|
50
|
+
function_full_response = await asyncio.to_thread(json.dumps, function_full_response) if function_full_response else None
|
52
51
|
|
53
52
|
blockReason = safe_get(json_data, 0, "promptFeedback", "blockReason", default=None)
|
54
53
|
|
@@ -77,7 +76,7 @@ async def fetch_gemini_response_stream(client, url, headers, payload, model, tim
|
|
77
76
|
if line.startswith("data: "):
|
78
77
|
parts_json = line.lstrip("data: ").strip()
|
79
78
|
try:
|
80
|
-
await asyncio.to_thread(json.loads, parts_json)
|
79
|
+
response_json = await asyncio.to_thread(json.loads, parts_json)
|
81
80
|
except json.JSONDecodeError:
|
82
81
|
logger.error(f"JSON decode error: {parts_json}")
|
83
82
|
continue
|
@@ -85,12 +84,12 @@ async def fetch_gemini_response_stream(client, url, headers, payload, model, tim
|
|
85
84
|
parts_json += line
|
86
85
|
parts_json = parts_json.lstrip("[,")
|
87
86
|
try:
|
88
|
-
await asyncio.to_thread(json.loads, parts_json)
|
87
|
+
response_json = await asyncio.to_thread(json.loads, parts_json)
|
89
88
|
except json.JSONDecodeError:
|
90
89
|
continue
|
91
90
|
|
92
91
|
# https://ai.google.dev/api/generate-content?hl=zh-cn#FinishReason
|
93
|
-
is_thinking, reasoning_content, content, image_base64, function_call_name, function_full_response, finishReason, blockReason, promptTokenCount, candidatesTokenCount, totalTokenCount = await gemini_json_poccess(
|
92
|
+
is_thinking, reasoning_content, content, image_base64, function_call_name, function_full_response, finishReason, blockReason, promptTokenCount, candidatesTokenCount, totalTokenCount = await gemini_json_poccess(response_json)
|
94
93
|
|
95
94
|
if is_thinking:
|
96
95
|
sse_string = await generate_sse_response(timestamp, model, reasoning_content=reasoning_content)
|
@@ -37,10 +37,18 @@ class RateLimitError(Exception):
|
|
37
37
|
"""Custom exception for rate limit (429) errors."""
|
38
38
|
pass
|
39
39
|
|
40
|
+
class BadRequestError(Exception):
|
41
|
+
"""Custom exception for bad request (400) errors."""
|
42
|
+
pass
|
43
|
+
|
40
44
|
class HTTPError(Exception):
|
41
45
|
"""Custom exception for HTTP 500 errors."""
|
42
46
|
pass
|
43
47
|
|
48
|
+
class InputTokenCountExceededError(Exception):
|
49
|
+
"""Custom exception for input token count exceeding the maximum."""
|
50
|
+
pass
|
51
|
+
|
44
52
|
class ConfigurationError(Exception):
|
45
53
|
"""Custom exception for configuration errors."""
|
46
54
|
pass
|
@@ -802,6 +810,10 @@ class chatgpt(BaseLLM):
|
|
802
810
|
raise ModelNotFoundError(f"Model: {model or self.engine} not found!")
|
803
811
|
if "HTTP Error', 'status_code': 429" in processed_chunk:
|
804
812
|
raise RateLimitError(f"Rate limit exceeded for model: {model or self.engine}")
|
813
|
+
if "HTTP Error', 'status_code': 413" in processed_chunk:
|
814
|
+
raise InputTokenCountExceededError(processed_chunk)
|
815
|
+
if "HTTP Error', 'status_code': 400" in processed_chunk:
|
816
|
+
raise BadRequestError(f"Bad Request: {processed_chunk}")
|
805
817
|
if "HTTP Error', 'status_code': " in processed_chunk:
|
806
818
|
raise HTTPError(f"HTTP Error: {processed_chunk}")
|
807
819
|
yield processed_chunk
|
@@ -814,7 +826,7 @@ class chatgpt(BaseLLM):
|
|
814
826
|
return # Stop iteration
|
815
827
|
except httpx.RemoteProtocolError:
|
816
828
|
continue
|
817
|
-
except httpx.ReadError:
|
829
|
+
except httpx.ReadError as e:
|
818
830
|
self.logger.warning(f"{e}, retrying...")
|
819
831
|
continue
|
820
832
|
except APITimeoutError:
|
@@ -826,6 +838,12 @@ class chatgpt(BaseLLM):
|
|
826
838
|
except RateLimitError as e:
|
827
839
|
self.logger.warning(f"{e}, retrying...")
|
828
840
|
continue
|
841
|
+
except InputTokenCountExceededError as e:
|
842
|
+
self.logger.error(f"The request body is too long: {e}")
|
843
|
+
raise
|
844
|
+
except BadRequestError as e:
|
845
|
+
self.logger.error(f"Bad request error: {e}")
|
846
|
+
raise
|
829
847
|
except ValidationError as e:
|
830
848
|
self.logger.warning(f"Validation failed: {e}. Retrying with corrective prompt.")
|
831
849
|
need_done_prompt = [
|
beswarm/tools/subtasks.py
CHANGED
@@ -36,11 +36,14 @@ def create_task(goal, tools, work_dir):
|
|
36
36
|
}
|
37
37
|
]
|
38
38
|
|
39
|
+
if work_dir == str(task_manager.root_path):
|
40
|
+
return f"<tool_error>子任务的工作目录位置在主任务的工作目录的子目录。子任务工作目录**禁止**设置为主任务目录本身。请重新创建子任务。当前主任务工作目录:{task_manager.root_path}</tool_error>"
|
41
|
+
|
39
42
|
# 调用新的批量创建接口
|
40
43
|
task_ids = task_manager.create_tasks_batch(worker_fun, tasks_params)
|
41
44
|
|
42
45
|
# 返回新创建的单个任务ID
|
43
|
-
return f"子任务已提交到队列,ID: {task_ids[0]}" if task_ids else "
|
46
|
+
return f"子任务已提交到队列,ID: {task_ids[0]}" if task_ids else "<tool_error>任务提交失败</tool_error>"
|
44
47
|
|
45
48
|
@register_tool()
|
46
49
|
def resume_task(task_id, goal):
|
@@ -6,13 +6,13 @@ beswarm/prompt.py,sha256=qlH-yYCGv9j9-5grnMXl0B53CDZgfTpe4ncwBwgWg7o,32816
|
|
6
6
|
beswarm/taskmanager.py,sha256=vMmcoZ4FlNvjEliRkv3AniPji50NcY4Q1_2HETzR0DU,12226
|
7
7
|
beswarm/utils.py,sha256=0J-b38P5QGT-A_38co7FjzaUNJykaskI7mbbcQ4w_68,8215
|
8
8
|
beswarm/agents/chatgroup.py,sha256=PzrmRcDKAbB7cxL16nMod_CzPosDV6bfTmXxQVuv-AQ,12012
|
9
|
-
beswarm/agents/planact.py,sha256=
|
9
|
+
beswarm/agents/planact.py,sha256=F5ocxYU9F70yJo3fPvm3RFcUMWUQFtkrnF_DHD9vbC4,20799
|
10
10
|
beswarm/aient/aient/__init__.py,sha256=SRfF7oDVlOOAi6nGKiJIUK6B_arqYLO9iSMp-2IZZps,21
|
11
11
|
beswarm/aient/aient/core/__init__.py,sha256=NxjebTlku35S4Dzr16rdSqSTWUvvwEeACe8KvHJnjPg,34
|
12
12
|
beswarm/aient/aient/core/log_config.py,sha256=kz2_yJv1p-o3lUQOwA3qh-LSc3wMHv13iCQclw44W9c,274
|
13
13
|
beswarm/aient/aient/core/models.py,sha256=KMlCRLjtq1wQHZTJGqnbWhPS2cHq6eLdnk7peKDrzR8,7490
|
14
14
|
beswarm/aient/aient/core/request.py,sha256=QnDhyrjzcJOEQU2oauMQi_HHMRR5NxdkrX7nn5JMwTc,76675
|
15
|
-
beswarm/aient/aient/core/response.py,sha256=
|
15
|
+
beswarm/aient/aient/core/response.py,sha256=waC-i5i04bwooqNAgjmX30nx0IJ1nLITPeF0RCYwRs0,35620
|
16
16
|
beswarm/aient/aient/core/utils.py,sha256=okDFj8S4r71vnkEBYxiOqoKee63UzNyk2y_p4uhWBvY,28848
|
17
17
|
beswarm/aient/aient/core/test/test_base_api.py,sha256=pWnycRJbuPSXKKU9AQjWrMAX1wiLC_014Qc9hh5C2Pw,524
|
18
18
|
beswarm/aient/aient/core/test/test_geminimask.py,sha256=HFX8jDbNg_FjjgPNxfYaR-0-roUrOO-ND-FVsuxSoiw,13254
|
@@ -21,7 +21,7 @@ beswarm/aient/aient/core/test/test_payload.py,sha256=8jBiJY1uidm1jzL-EiK0s6UGmW9
|
|
21
21
|
beswarm/aient/aient/models/__init__.py,sha256=ZTiZgbfBPTjIPSKURE7t6hlFBVLRS9lluGbmqc1WjxQ,43
|
22
22
|
beswarm/aient/aient/models/audio.py,sha256=kRd-8-WXzv4vwvsTGwnstK-WR8--vr9CdfCZzu8y9LA,1934
|
23
23
|
beswarm/aient/aient/models/base.py,sha256=-nnihYnx-vHZMqeVO9ljjt3k4FcD3n-iMk4tT-10nRQ,7232
|
24
|
-
beswarm/aient/aient/models/chatgpt.py,sha256
|
24
|
+
beswarm/aient/aient/models/chatgpt.py,sha256=-3bOA_jLsePy3B77Q5C1C3UglY0NDc9dRMDi7bAdcNw,47056
|
25
25
|
beswarm/aient/aient/plugins/__init__.py,sha256=p3KO6Aa3Lupos4i2SjzLQw1hzQTigOAfEHngsldrsyk,986
|
26
26
|
beswarm/aient/aient/plugins/arXiv.py,sha256=yHjb6PS3GUWazpOYRMKMzghKJlxnZ5TX8z9F6UtUVow,1461
|
27
27
|
beswarm/aient/aient/plugins/config.py,sha256=TGgZ5SnNKZ8MmdznrZ-TEq7s2ulhAAwTSKH89bci3dA,7079
|
@@ -113,10 +113,10 @@ beswarm/tools/request_input.py,sha256=3n2UW8m8Q7dxGhd7L7hzSJ1kk4ekMbtdtNZZT3dJf2
|
|
113
113
|
beswarm/tools/screenshot.py,sha256=hyL6F8_k9Y03Nb_X18cY-klCpWWdkqyC-iGXfKX-7jc,1007
|
114
114
|
beswarm/tools/search_arxiv.py,sha256=NLiJV1B7Um6EuZXLxnL950d837_he2LGG7qaGACSgwg,10750
|
115
115
|
beswarm/tools/search_web.py,sha256=NYrb5KL_WUGPm-fOKT8Cyjon04lxBU-gaLdrVjeYgGo,16143
|
116
|
-
beswarm/tools/subtasks.py,sha256=
|
116
|
+
beswarm/tools/subtasks.py,sha256=OclAorPuuG9vnySoBN2ISzzoInZJV3wmLAVzdMF3FXM,10220
|
117
117
|
beswarm/tools/worker.py,sha256=_cSkRUKRJMAiZiTfnBze_e9Kc7k7KvbB5hdxdvp4FW4,2009
|
118
118
|
beswarm/tools/write_csv.py,sha256=u0Hq18Ksfheb52MVtyLNCnSDHibITpsYBPs2ub7USYA,1466
|
119
|
-
beswarm-0.2.
|
120
|
-
beswarm-0.2.
|
121
|
-
beswarm-0.2.
|
122
|
-
beswarm-0.2.
|
119
|
+
beswarm-0.2.75.dist-info/METADATA,sha256=FG-4-x8JV4k06CSWCF7nUFSeqVgWSP-y_-CAZl2lQ1k,3878
|
120
|
+
beswarm-0.2.75.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
121
|
+
beswarm-0.2.75.dist-info/top_level.txt,sha256=pJw4O87wvt5882smuSO6DfByJz7FJ8SxxT8h9fHCmpo,8
|
122
|
+
beswarm-0.2.75.dist-info/RECORD,,
|
File without changes
|
File without changes
|