Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions ga.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def stream_reader(proc, logs):
except UnicodeDecodeError: line = line_bytes.decode('gbk', errors='ignore')
logs.append(line)
try: print(line, end="")
except: pass
except: pass
except Exception: pass
except Exception: pass

try:
process = subprocess.Popen(
Expand Down Expand Up @@ -156,7 +156,7 @@ def log_memory_access(path):
stats_file = os.path.join(script_dir, 'memory/file_access_stats.json')
try:
with open(stats_file, 'r', encoding='utf-8') as f: stats = json.load(f)
except: stats = {}
except Exception: stats = {}
fname = os.path.basename(path)
stats[fname] = {'count': stats.get(fname, {}).get('count', 0) + 1, 'last': datetime.now().strftime('%Y-%m-%d')}
with open(stats_file, 'w', encoding='utf-8') as f: json.dump(stats, f, indent=2, ensure_ascii=False)
Expand Down Expand Up @@ -286,7 +286,7 @@ def do_code_run(self, args, response):
code = self._extract_code_block(response, code_type)
if not code: return StepOutcome("[Error] Code missing. Must use reply code block or 'script' arg.", next_prompt="\n")
try: timeout = int(args.get("timeout", 60))
except: timeout = 60
except Exception: timeout = 60
raw_path = os.path.join(self.cwd, args.get("cwd", './'))
cwd = os.path.normpath(os.path.abspath(raw_path))
code_cwd = os.path.normpath(self.cwd)
Expand Down Expand Up @@ -345,10 +345,10 @@ def do_web_execute_js(self, args, response):
try:
with open(abs_path, 'w', encoding='utf-8') as f: f.write(str(content))
result["js_return"] += f"\n\n[已保存完整内容到 {abs_path}]"
except: result['js_return'] += f"\n\n[保存失败,无法写入文件 {abs_path}]"
except Exception: result['js_return'] += f"\n\n[保存失败,无法写入文件 {abs_path}]"
show = smart_format(json.dumps(result, ensure_ascii=False, indent=2, default=json_default), max_str_len=300)
try: print("Web Execute JS Result:", show)
except: pass
except Exception: pass
yield f"JS 执行结果:\n{show}\n"
next_prompt = self._get_anchor_prompt(skip=args.get('_index', 0) > 0)
result = json.dumps(result, ensure_ascii=False, default=json_default)
Expand Down Expand Up @@ -430,7 +430,7 @@ def enter_plan_mode(self, plan_path):
def _check_plan_completion(self):
if not os.path.isfile(p:=self._in_plan_mode() or ''): return None
try: return len(re.findall(r'\[ \]', open(p, encoding='utf-8', errors='replace').read()))
except: return None
except Exception: return None

def do_update_working_checkpoint(self, args, response):
'''为整个任务设定后续需要临时记忆的重点。'''
Expand Down Expand Up @@ -541,7 +541,7 @@ def _get_anchor_prompt(self, skip=False):
if self.working.get('related_sop'): prompt += f"\n有不清晰的地方请再次读取{self.working.get('related_sop')}"
if getattr(self.parent, 'verbose', False):
try: print(prompt)
except: pass
except Exception: pass
return prompt

def turn_end_callback(self, response, tool_calls, tool_results, turn, next_prompt, exit_reason):
Expand Down