Spaces:
Runtime error
Runtime error
File size: 2,315 Bytes
d2b2451 | 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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | from enum import Enum
# 定义处理状态枚举
class ProcessStatus(Enum):
IDLE = "idle"
INITIALIZING = "initializing"
COPYING_FILES = "copying_files"
OCR_PROCESSING = "ocr_processing"
LLM_PROCESSING = "llm_processing"
EXTRACTING_QUESTIONS = "extracting_questions"
SAVING_RESULTS = "saving_results"
MOVING_FILES = "moving_files"
COMPLETED = "completed"
UPLOADING = "uploading"
ERROR = "error"
# 状态显示配置
STATUS_CONFIG = {
ProcessStatus.IDLE: {
"text": "🟢 待机中",
"color": "green",
"bold": False
},
ProcessStatus.INITIALIZING: {
"text": "🔄 初始化中...",
"color": "blue",
"bold": True
},
ProcessStatus.COPYING_FILES: {
"text": "📁 复制文件中...",
"color": "blue",
"bold": True
},
ProcessStatus.OCR_PROCESSING: {
"text": "🔍 OCR识别中...",
"color": "orange",
"bold": True
},
ProcessStatus.LLM_PROCESSING: {
"text": "🤖 LLM处理中...",
"color": "purple",
"bold": True
},
ProcessStatus.EXTRACTING_QUESTIONS: {
"text": "📝 提取题目中...",
"color": "purple",
"bold": True
},
ProcessStatus.SAVING_RESULTS: {
"text": "💾 保存结果中...",
"color": "blue",
"bold": True
},
ProcessStatus.MOVING_FILES: {
"text": "📦 移动文件中...",
"color": "blue",
"bold": True
},
ProcessStatus.COMPLETED: {
"text": "✅ 处理完成",
"color": "green",
"bold": True
},
ProcessStatus.UPLOADING: {
"text": "✅ 开始上传至存储",
"color": "green",
"bold": True
},
ProcessStatus.ERROR: {
"text": "❌ 处理出错",
"color": "red",
"bold": True
}
}
def format_status_display(status: ProcessStatus, detail: str = ""):
"""格式化状态显示"""
config = STATUS_CONFIG[status]
text = config["text"]
if detail:
text += f" - {detail}"
# 根据颜色和粗体设置返回HTML格式的文本
style = f"color: {config['color']};"
if config["bold"]:
style += " font-weight: bold;"
return f'<span style="{style}">{text}</span>' |