import os import shutil import tempfile def save_uploaded_file(uploaded_path: str) -> str: temp_dir = tempfile.mkdtemp() filename = os.path.basename(uploaded_path) new_path = os.path.join(temp_dir, filename) shutil.copy(uploaded_path, new_path) return new_path def read_text_file(file_path: str) -> str: try: with open(file_path, "r", encoding="utf-8", errors="ignore") as f: return f.read() except Exception as e: return f"Could not read text file: {str(e)}"