Spaces:
Runtime error

File size: 1,963 Bytes
ce06eb4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
"""
从聊天记录 JSONL 文件中提取原始的 app.py 内容
查找最后一次成功读取完整 app.py 的记录
"""
import json
import re

jsonl_file = r"C:\Users\41930\.workbuddy\projects\c-Users-41930-WorkBuddy-2026-05-11-task-4\4134032d-101d-4c31-b4da-53dfc4305be7.jsonl"

print("🔍 正在搜索聊天记录中的 app.py 原始内容...")
print("查找条件:包含完整 Python 代码(import streamlit as st)且长度 > 10KB\n")

found_contents = []

with open(jsonl_file, 'r', encoding='utf-8') as f:
    for line_num, line in enumerate(f, 1):
        try:
            data = json.loads(line)
            
            # 搜索所有文本内容
            content_str = json.dumps(data, ensure_ascii=False)
            
            # 查找包含 app.py 完整代码的内容
            if ('import streamlit as st' in content_str and 
                'def main()' in content_str and
                len(content_str) > 10000):
                
                # 尝试提取 app.py 的内容
                # 查找形如 "file_content": "..." 或完整的 Python 代码块
                matches = re.findall(r'""".*?数据指标建模助手.*?""".*?if __name__', content_str, re.DOTALL)
                
                for match in matches:
                    if len(match) > 5000:  # 确保是完整文件
                        found_contents.append({
                            'line': line_num,
                            'length': len(match),
                            'content_preview': match[:200]
                        })
                        print(f"✅ 在第 {line_num} 行找到可能的完整代码(长度: {len(match)} 字符)")
                        
        except json.JSONDecodeError:
            continue
        except Exception as e:
            continue

print(f"\n📊 共找到 {len(found_contents)} 处可能的完整代码")
print("\n建议:查看最大的那一个")