1414
1515@app .route ("/" )
1616def index ():
17- """主页面 """
17+ """Main page """
1818 return render_template ("index.html" )
1919
2020
2121@app .route ("/api/list_files" , methods = ["GET" ])
2222def list_files ():
23- """列出可用的JSON文件 """
23+ """List available JSON files """
2424 try :
2525 directory = request .args .get ("directory" , "" )
2626
@@ -35,10 +35,10 @@ def list_files():
3535 directory = os .path .abspath (directory )
3636
3737 if not os .path .exists (directory ):
38- return jsonify ({"error" : f"目录不存在 : { directory } " }), 404
38+ return jsonify ({"error" : f"Directory does not exist : { directory } " }), 404
3939
4040 if not os .path .isdir (directory ):
41- return jsonify ({"error" : f"路径不是目录 : { directory } " }), 400
41+ return jsonify ({"error" : f"Path is not a directory : { directory } " }), 400
4242
4343 try :
4444 json_files = []
@@ -68,54 +68,54 @@ def list_files():
6868 {
6969 "files" : json_files ,
7070 "directory" : directory ,
71- "message" : f'在目录 " { directory } " 中找到 { len (json_files )} 个JSON文件 ' ,
71+ "message" : f'Found { len (json_files )} JSON files in directory " { directory } " ' ,
7272 }
7373 )
7474 except PermissionError :
75- return jsonify ({"error" : f"没有权限访问目录 : { directory } " }), 403
75+ return jsonify ({"error" : f"No permission to access directory : { directory } " }), 403
7676 except Exception as e :
77- return jsonify ({"error" : f"读取目录失败 : { str (e )} " }), 500
77+ return jsonify ({"error" : f"Failed to read directory : { str (e )} " }), 500
7878
7979 except Exception as e :
8080 return jsonify ({"error" : str (e )}), 500
8181
8282
8383@app .route ("/api/load_trace" , methods = ["POST" ])
8484def load_trace ():
85- """加载trace文件 """
85+ """Load trace file """
8686 global analyzer
8787
8888 data = request .get_json ()
8989 file_path = data .get ("file_path" )
9090
9191 if not file_path :
92- return jsonify ({"error" : "请提供文件路径 " }), 400
92+ return jsonify ({"error" : "Please provide file path " }), 400
9393
9494 # If it's a relative path, convert to absolute path
9595 if not os .path .isabs (file_path ):
9696 file_path = os .path .abspath (file_path )
9797
9898 if not os .path .exists (file_path ):
99- return jsonify ({"error" : f"文件不存在 : { file_path } " }), 404
99+ return jsonify ({"error" : f"File does not exist : { file_path } " }), 404
100100
101101 try :
102102 analyzer = TraceAnalyzer (file_path )
103103 return jsonify (
104104 {
105- "message" : "文件加载成功 " ,
105+ "message" : "File loaded successfully " ,
106106 "file_path" : file_path ,
107107 "file_name" : os .path .basename (file_path ),
108108 }
109109 )
110110 except Exception as e :
111- return jsonify ({"error" : f"加载文件失败 : { str (e )} " }), 500
111+ return jsonify ({"error" : f"Failed to load file : { str (e )} " }), 500
112112
113113
114114@app .route ("/api/basic_info" )
115115def get_basic_info ():
116- """获取基本信息 """
116+ """Get basic information """
117117 if not analyzer :
118- return jsonify ({"error" : "请先加载trace文件 " }), 400
118+ return jsonify ({"error" : "Please load trace file first " }), 400
119119
120120 try :
121121 return jsonify (analyzer .get_basic_info ())
@@ -125,9 +125,9 @@ def get_basic_info():
125125
126126@app .route ("/api/performance_summary" )
127127def get_performance_summary ():
128- """获取性能摘要 """
128+ """Get performance summary """
129129 if not analyzer :
130- return jsonify ({"error" : "请先加载trace文件 " }), 400
130+ return jsonify ({"error" : "Please load trace file first " }), 400
131131
132132 try :
133133 return jsonify (analyzer .get_performance_summary ())
@@ -137,9 +137,9 @@ def get_performance_summary():
137137
138138@app .route ("/api/execution_flow" )
139139def get_execution_flow ():
140- """获取执行流程 """
140+ """Get execution flow """
141141 if not analyzer :
142- return jsonify ({"error" : "请先加载trace文件 " }), 400
142+ return jsonify ({"error" : "Please load trace file first " }), 400
143143
144144 try :
145145 return jsonify (analyzer .analyze_conversation_flow ())
@@ -149,9 +149,9 @@ def get_execution_flow():
149149
150150@app .route ("/api/execution_summary" )
151151def get_execution_summary ():
152- """获取执行摘要 """
152+ """Get execution summary """
153153 if not analyzer :
154- return jsonify ({"error" : "请先加载trace文件 " }), 400
154+ return jsonify ({"error" : "Please load trace file first " }), 400
155155
156156 try :
157157 return jsonify (analyzer .get_execution_summary ())
@@ -161,9 +161,9 @@ def get_execution_summary():
161161
162162@app .route ("/api/spans_summary" )
163163def get_spans_summary ():
164- """获取spans摘要 """
164+ """Get spans summary """
165165 if not analyzer :
166- return jsonify ({"error" : "请先加载trace文件 " }), 400
166+ return jsonify ({"error" : "Please load trace file first " }), 400
167167
168168 try :
169169 return jsonify (analyzer .get_spans_summary ())
@@ -173,9 +173,9 @@ def get_spans_summary():
173173
174174@app .route ("/api/step_logs_summary" )
175175def get_step_logs_summary ():
176- """获取步骤日志摘要 """
176+ """Get step logs summary """
177177 if not analyzer :
178- return jsonify ({"error" : "请先加载trace文件 " }), 400
178+ return jsonify ({"error" : "Please load trace file first " }), 400
179179
180180 try :
181181 return jsonify (analyzer .get_step_logs_summary ())
@@ -185,9 +185,9 @@ def get_step_logs_summary():
185185
186186@app .route ("/api/debug/raw_messages" )
187187def get_raw_messages ():
188- """获取原始消息数据用于调试 """
188+ """Get raw message data for debugging """
189189 if not analyzer :
190- return jsonify ({"error" : "请先加载trace文件 " }), 400
190+ return jsonify ({"error" : "Please load trace file first " }), 400
191191
192192 try :
193193 main_history = analyzer .get_main_agent_history ()
@@ -220,7 +220,7 @@ def get_raw_messages():
220220 "raw_main_history" : main_history ,
221221 "raw_browser_sessions" : {
222222 k : v for k , v in list (browser_sessions .items ())[:2 ]
223- }, # 只显示前两个会话
223+ }, # Only show first two sessions
224224 }
225225 )
226226 except Exception as e :
0 commit comments