Spaces:
Sleeping
Sleeping
Update appaaa.py
Browse files
appaaa.py
CHANGED
@@ -1,290 +1,258 @@
|
|
1 |
-
|
2 |
-
from fastapi.responses import FileResponse
|
3 |
-
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
4 |
-
from zipfile import ZipFile, BadZipfile
|
5 |
-
import os
|
6 |
-
import shutil
|
7 |
-
import subprocess
|
8 |
from datetime import datetime
|
9 |
-
import
|
10 |
-
import
|
11 |
-
from
|
12 |
-
from
|
13 |
-
from
|
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 |
-
app.add_middleware(
|
55 |
-
CORSMiddleware,
|
56 |
-
allow_origins=origins,
|
57 |
-
allow_credentials=True,
|
58 |
-
allow_methods=["*"],
|
59 |
-
allow_headers=["*"],
|
60 |
-
)
|
61 |
-
|
62 |
-
# Serve static files
|
63 |
-
app.mount("/static", StaticFiles(directory="static"), name="static")
|
64 |
-
|
65 |
-
# Template engine
|
66 |
-
templates = Jinja2Templates(directory="templates")
|
67 |
-
|
68 |
-
# Define supported frameworks and their associated extensions
|
69 |
-
FRAMEWORKS = {
|
70 |
-
"Python": ".py",
|
71 |
-
"JavaScript": ".js",
|
72 |
-
"PHP": ".php",
|
73 |
-
"Go": ".go",
|
74 |
-
"Ruby": ".rb",
|
75 |
-
"Java": ".java",
|
76 |
-
"C#": ".cs",
|
77 |
-
"C++": ".cpp",
|
78 |
-
"Rust": ".rs",
|
79 |
-
}
|
80 |
-
|
81 |
-
INTERPRETER_COMMANDS = {
|
82 |
-
"Python": "python {file_path}",
|
83 |
-
"JavaScript": "node {file_path}",
|
84 |
-
"PHP": "php -l {file_path}",
|
85 |
-
"Go": "go build {file_path}",
|
86 |
-
"Ruby": "ruby -c {file_path}",
|
87 |
-
"Java": "javac {file_path}",
|
88 |
-
"C#": "mcs {file_path}",
|
89 |
-
"C++": "g++ -c {file_path}",
|
90 |
-
"Rust": "rustc {file_path}",
|
91 |
-
}
|
92 |
-
|
93 |
-
# Database setup
|
94 |
-
SQLALCHEMY_DATABASE_URL = "sqlite:///errors.db" # Use SQLite for simplicity
|
95 |
-
engine = create_engine(
|
96 |
-
SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
|
97 |
-
)
|
98 |
-
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
99 |
-
Base = declarative_base()
|
100 |
-
|
101 |
-
# Database model for errors
|
102 |
-
class TranslationError(Base):
|
103 |
-
__tablename__ = "translation_errors"
|
104 |
-
|
105 |
-
id = Column(Integer, primary_key=True, index=True)
|
106 |
-
timestamp = Column(DateTime, default=datetime.utcnow)
|
107 |
-
file = Column(String)
|
108 |
-
error = Column(String)
|
109 |
-
resolved = Column(Boolean, default=False)
|
110 |
-
|
111 |
-
# Create tables if they don't exist
|
112 |
-
Base.metadata.create_all(bind=engine)
|
113 |
-
|
114 |
-
# Dependency for database session
|
115 |
-
def get_db():
|
116 |
-
db = SessionLocal()
|
117 |
-
try:
|
118 |
-
yield db
|
119 |
-
finally:
|
120 |
-
db.close()
|
121 |
-
|
122 |
-
# Load models at startup
|
123 |
-
@app.on_event("startup")
|
124 |
-
async def load_models():
|
125 |
-
app.state.translation_models = {
|
126 |
-
"Python": AutoModelForSeq2SeqLM.from_pretrained("microsoft/codebert-base"),
|
127 |
-
"JavaScript": AutoModelForSeq2SeqLM.from_pretrained("microsoft/codebert-base"),
|
128 |
-
# Add other frameworks as needed
|
129 |
}
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
-
#
|
140 |
-
|
141 |
-
|
142 |
-
|
|
|
|
|
|
|
|
|
143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
try:
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
def generate_ai_response(message, errors=None):
|
180 |
-
if "error" in message.lower() and errors:
|
181 |
-
return """f"Your translation failed with: {', '.join(errors[:3])}"""
|
182 |
-
elif "support" in message.lower():
|
183 |
-
return """f"Supported frameworks: {', '.join(FRAMEWORKS.keys())}"""
|
184 |
-
return "Ask about translation errors or framework support"
|
185 |
|
186 |
-
#
|
187 |
-
|
188 |
-
async def translate(files: List[UploadFile] = File(...), framework: str = Form(...), retries: int = 3):
|
189 |
-
if framework not in FRAMEWORKS:
|
190 |
-
logging.error(f"Unsupported framework: {framework}")
|
191 |
-
raise HTTPException(status_code=400, detail="Unsupported framework.")
|
192 |
|
193 |
-
|
194 |
-
file_path = os.path.join(os.getcwd(), file.filename)
|
195 |
-
with open(file_path, "wb") as buffer:
|
196 |
-
shutil.copyfileobj(file.file, buffer)
|
197 |
|
198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
try:
|
200 |
-
|
201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
except Exception as e:
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
try:
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
log_error(file_path, result.stderr) # Store in persistent storage
|
223 |
-
return False, result.stderr
|
224 |
-
return True, ""
|
225 |
except Exception as e:
|
226 |
-
|
227 |
-
|
228 |
-
# Error logging function
|
229 |
-
def log_error(file_path, error, db: SessionLocal):
|
230 |
-
error_entry = TranslationError(file=file_path, error=error)
|
231 |
-
db.add(error_entry)
|
232 |
-
db.commit()
|
233 |
-
|
234 |
-
# Function to retrieve last translation errors
|
235 |
-
def get_last_translation_errors(db: SessionLocal):
|
236 |
-
errors = db.query(TranslationError).order_by(TranslationError.timestamp.desc()).limit(5).all()
|
237 |
-
return [error.error for error in errors]
|
238 |
-
|
239 |
-
# Chat input model
|
240 |
-
class ChatInput(BaseModel):
|
241 |
-
message: str
|
242 |
-
|
243 |
-
# Chat endpoint with HTML template
|
244 |
-
@app.get("/chat")
|
245 |
-
async def chat_page(request: ChatInput, db: SessionLocal = Depends(get_db)):
|
246 |
-
error_context = get_last_translation_errors(db)
|
247 |
-
response = generate_ai_response(request.message, error_context)
|
248 |
-
return templates.TemplateResponse("chat.html", {"request": request, "response": response})
|
249 |
-
|
250 |
-
# Home page
|
251 |
-
@app.get("/")
|
252 |
-
async def home_page(request: ChatInput):
|
253 |
-
return templates.TemplateResponse("index.html", {"request": request})
|
254 |
-
|
255 |
-
# Translation page
|
256 |
-
@app.get("/translate")
|
257 |
-
async def translate_page(request: ChatInput):
|
258 |
-
return templates.TemplateResponse("translate.html", {"request": request})
|
259 |
-
|
260 |
-
# Handle translation form submission
|
261 |
-
@app.post("/translate")
|
262 |
-
async def handle_translate(files: List[UploadFile] = File(...), framework: str = Form(...), retries: int = 3, db: SessionLocal = Depends(get_db)):
|
263 |
-
if framework not in FRAMEWORKS:
|
264 |
-
logging.error(f"Unsupported framework: {framework}")
|
265 |
-
raise HTTPException(status_code=400, detail="Unsupported framework.")
|
266 |
-
|
267 |
-
for file in files:
|
268 |
-
file_path = os.path.join(os.getcwd(), file.filename)
|
269 |
-
with open(file_path, "wb") as buffer:
|
270 |
-
shutil.copyfileobj(file.file, buffer)
|
271 |
-
|
272 |
-
for attempt in range(retries):
|
273 |
-
try:
|
274 |
-
translated_zip = process_zip(file_path, framework)
|
275 |
-
return FileResponse(translated_zip)
|
276 |
-
except Exception as e:
|
277 |
-
logging.error(f"Translation attempt {attempt + 1} failed: {e}")
|
278 |
-
log_error(file_path, str(e), db)
|
279 |
-
if attempt < retries - 1:
|
280 |
-
# Exponential backoff (adjust as needed)
|
281 |
-
wait_time = 2 ** attempt
|
282 |
-
print(f"Retrying translation in {wait_time} seconds...")
|
283 |
-
await asyncio.sleep(wait_time)
|
284 |
-
else:
|
285 |
-
return {"error": "Translation failed after multiple attempts."}
|
286 |
|
287 |
-
#
|
288 |
-
if
|
289 |
-
|
290 |
-
uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
|
1 |
+
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
from datetime import datetime
|
3 |
+
import os
|
4 |
+
import json
|
5 |
+
from pathlib import Path
|
6 |
+
from json import JSONDecodeError
|
7 |
+
from FreeLLM import HuggingChatAPI, ChatGPTAPI, BingChatAPI
|
8 |
+
|
9 |
+
# Page Configuration
|
10 |
+
st.set_page_config(
|
11 |
+
page_title="FREE AUTOHUGGS π€",
|
12 |
+
page_icon="π€",
|
13 |
+
layout="wide",
|
14 |
+
menu_items={
|
15 |
+
"Get help": "[email protected]",
|
16 |
+
"About": "# *π€ FREE AUTOHUGGS π€*"
|
17 |
+
}
|
18 |
+
)
|
|
|
19 |
|
20 |
+
# Modern Dark Theme CSS
|
21 |
+
st.markdown("""
|
22 |
+
<style>
|
23 |
+
/* Base theme */
|
24 |
+
.main {
|
25 |
+
background-color: #0e1117;
|
26 |
+
color: #e0e0e0;
|
27 |
+
}
|
28 |
|
29 |
+
/* Sidebar styling */
|
30 |
+
.css-1d391kg {
|
31 |
+
background-color: #1e1e2e;
|
32 |
+
}
|
|
|
33 |
|
34 |
+
/* Input fields */
|
35 |
+
.stTextInput input, .stTextArea textarea, .stNumberInput input {
|
36 |
+
background-color: #262630;
|
37 |
+
color: #ffffff;
|
38 |
+
border: 1px solid #464660;
|
39 |
+
border-radius: 8px;
|
40 |
+
padding: 12px;
|
41 |
+
}
|
42 |
|
43 |
+
/* Buttons */
|
44 |
+
.stButton>button {
|
45 |
+
background: linear-gradient(90deg, #ff4b4b 0%, #ff6b6b 100%);
|
46 |
+
color: white;
|
47 |
+
border: none;
|
48 |
+
padding: 0.6em 1.2em;
|
49 |
+
border-radius: 8px;
|
50 |
+
font-weight: 600;
|
51 |
+
transition: all 0.3s ease;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
}
|
53 |
+
|
54 |
+
.stButton>button:hover {
|
55 |
+
transform: translateY(-2px);
|
56 |
+
box-shadow: 0 4px 12px rgba(255, 75, 75, 0.3);
|
57 |
+
}
|
58 |
+
|
59 |
+
/* Chat messages */
|
60 |
+
.chat-message {
|
61 |
+
padding: 1rem;
|
62 |
+
border-radius: 12px;
|
63 |
+
margin: 1rem 0;
|
64 |
+
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
65 |
+
}
|
66 |
+
|
67 |
+
.user-message {
|
68 |
+
background-color: #2a2a3a;
|
69 |
+
border-left: 4px solid #ff4b4b;
|
70 |
+
}
|
71 |
+
|
72 |
+
.assistant-message {
|
73 |
+
background-color: #323242;
|
74 |
+
border-left: 4px solid #4b8bff;
|
75 |
+
}
|
76 |
+
|
77 |
+
/* Headers */
|
78 |
+
h1, h2, h3 {
|
79 |
+
color: #ffffff;
|
80 |
+
}
|
81 |
+
</style>
|
82 |
+
""", unsafe_allow_html=True)
|
83 |
|
84 |
+
# Sidebar Configuration
|
85 |
+
with st.sidebar:
|
86 |
+
st.header("π οΈ Agent Configuration")
|
87 |
+
|
88 |
+
assistant_role_name = st.text_input("π€ Assistant Role", "Python Programmer")
|
89 |
+
user_role_name = st.text_input("π₯ User Role", "Stock Trader")
|
90 |
+
task = st.text_area("π Task", "Develop a trading bot for the stock market")
|
91 |
+
word_limit = st.slider("π€ Word Limit", 10, 1500, 50)
|
92 |
|
93 |
+
st.markdown("---")
|
94 |
+
|
95 |
+
st.header("βοΈ Advanced Options")
|
96 |
+
llm_choice = st.selectbox("π€ Select LLM API", ["HuggingChat", "ChatGPT", "BingChat"])
|
97 |
+
auto_save = st.checkbox("πΎ Auto-save conversation", value=True)
|
98 |
+
transcript_filename = st.text_input("π Transcript filename", "conversation_transcript.txt")
|
99 |
+
|
100 |
+
# Cookie File Validation
|
101 |
+
COOKIE_FILE = "cookiesHuggingChat.json"
|
102 |
+
try:
|
103 |
+
if not Path(COOKIE_FILE).exists():
|
104 |
+
st.error(f"β File '{COOKIE_FILE}' not found! Please create it with your cookies in JSON format.")
|
105 |
+
st.stop()
|
106 |
+
|
107 |
+
with open(COOKIE_FILE, "r") as file:
|
108 |
+
cookies = json.loads(file.read())
|
109 |
+
except JSONDecodeError:
|
110 |
+
st.error(f"β Invalid JSON in '{COOKIE_FILE}'. Please check your file format!")
|
111 |
+
st.stop()
|
112 |
+
except Exception as e:
|
113 |
+
st.error(f"β Error reading cookie file: {str(e)}")
|
114 |
+
st.stop()
|
115 |
+
|
116 |
+
# LLM API Initialization
|
117 |
+
def get_llm(api_choice: str):
|
118 |
+
llm_map = {
|
119 |
+
"HuggingChat": HuggingChatAPI.HuggingChat,
|
120 |
+
"ChatGPT": ChatGPTAPI.ChatGPT,
|
121 |
+
"BingChat": BingChatAPI.BingChat
|
122 |
+
}
|
123 |
+
|
124 |
+
if api_choice not in llm_map:
|
125 |
+
st.error("β Invalid LLM API selection.")
|
126 |
+
st.stop()
|
127 |
+
|
128 |
try:
|
129 |
+
return llm_map[api_choice](cookiepath=str(Path(COOKIE_FILE)))
|
130 |
+
except Exception as e:
|
131 |
+
st.error(f"β Error initializing {api_choice}: {str(e)}")
|
132 |
+
st.stop()
|
133 |
+
|
134 |
+
llm = get_llm(llm_choice)
|
135 |
+
|
136 |
+
# Initialize session state
|
137 |
+
if "chat_history" not in st.session_state:
|
138 |
+
st.session_state.chat_history = []
|
139 |
+
if "conversation_start" not in st.session_state:
|
140 |
+
st.session_state.conversation_start = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
141 |
+
|
142 |
+
# Main chat interface
|
143 |
+
st.title("π¬ AI Chat Interface")
|
144 |
+
|
145 |
+
# Display chat history
|
146 |
+
for message in st.session_state.chat_history:
|
147 |
+
if message["role"] == "assistant":
|
148 |
+
st.markdown(
|
149 |
+
f"<div class='chat-message assistant-message'><strong>{assistant_role_name}:</strong> {message['content']}</div>",
|
150 |
+
unsafe_allow_html=True
|
151 |
+
)
|
152 |
+
elif message["role"] == "user":
|
153 |
+
st.markdown(
|
154 |
+
f"<div class='chat-message user-message'><strong>{user_role_name}:</strong> {message['content']}</div>",
|
155 |
+
unsafe_allow_html=True
|
156 |
+
)
|
157 |
+
else:
|
158 |
+
st.markdown(
|
159 |
+
f"<div class='chat-message'><em>{message['content']}</em></div>",
|
160 |
+
unsafe_allow_html=True
|
161 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
|
163 |
+
# Input area
|
164 |
+
user_input = st.text_input("π Your message:", key="user_input")
|
|
|
|
|
|
|
|
|
165 |
|
166 |
+
col1, col2, col3 = st.columns(3)
|
|
|
|
|
|
|
167 |
|
168 |
+
with col1:
|
169 |
+
if st.button("π€ Send"):
|
170 |
+
if user_input:
|
171 |
+
# Add user message to history
|
172 |
+
st.session_state.chat_history.append({"role": "user", "content": user_input})
|
173 |
+
|
174 |
+
# Get AI response
|
175 |
try:
|
176 |
+
with st.spinner("π€ AI is thinking..."):
|
177 |
+
response = llm(user_input)
|
178 |
+
st.session_state.chat_history.append({"role": "assistant", "content": response})
|
179 |
+
|
180 |
+
# Auto-save if enabled
|
181 |
+
if auto_save:
|
182 |
+
with open(transcript_filename, "a", encoding="utf-8") as f:
|
183 |
+
f.write(f":User {user_input}\n")
|
184 |
+
f.write(f"Assistant: {response}\n")
|
185 |
+
|
186 |
+
st.experimental_rerun()
|
187 |
except Exception as e:
|
188 |
+
st.error(f"β Error getting AI response: {str(e)}")
|
189 |
+
with col2:
|
190 |
+
if st.button("π Clear Chat"):
|
191 |
+
st.session_state.chat_history = []
|
192 |
+
st.experimental_rerun()
|
193 |
+
with col3:
|
194 |
+
if st.button("πΎ Save Transcript"):
|
195 |
+
try:
|
196 |
+
transcript = "\n".join([
|
197 |
+
f"{msg['role'].capitalize()}: {msg['content']}"
|
198 |
+
for msg in st.session_state.chat_history
|
199 |
+
])
|
200 |
+
with open(transcript_filename, "w", encoding="utf-8") as f:
|
201 |
+
f.write(transcript)
|
202 |
+
st.success("β
Transcript saved successfully!")
|
203 |
+
except Exception as e:
|
204 |
+
st.error(f"β Error saving transcript: {str(e)}") ```python
|
205 |
+
# Additional Features
|
206 |
+
# Function to display the current time
|
207 |
+
def display_time():
|
208 |
+
current_time = datetime.now().strftime("%H:%M:%S")
|
209 |
+
st.sidebar.markdown(f"π Current Time: {current_time}")
|
210 |
+
|
211 |
+
# Call the function to display time
|
212 |
+
display_time()
|
213 |
+
|
214 |
+
# Function to handle user input and AI response
|
215 |
+
def handle_input(user_input):
|
216 |
+
if user_input:
|
217 |
+
st.session_state.chat_history.append({"role": "user", "content": user_input})
|
218 |
+
try:
|
219 |
+
with st.spinner("π€ AI is thinking..."):
|
220 |
+
response = llm(user_input)
|
221 |
+
st.session_state.chat_history.append({"role": "assistant", "content": response})
|
222 |
+
if auto_save:
|
223 |
+
with open(transcript_filename, "a", encoding="utf-8") as f:
|
224 |
+
f.write(f":User {user_input}\n")
|
225 |
+
f.write(f"Assistant: {response}\n")
|
226 |
+
st.experimental_rerun()
|
227 |
+
except Exception as e:
|
228 |
+
st.error(f"β Error getting AI response: {str(e)}")
|
229 |
+
|
230 |
+
# Input area with button to send message
|
231 |
+
if st.button("π€ Send"):
|
232 |
+
handle_input(user_input)
|
233 |
+
|
234 |
+
# Function to clear chat history
|
235 |
+
def clear_chat():
|
236 |
+
st.session_state.chat_history = []
|
237 |
+
st.experimental_rerun()
|
238 |
+
|
239 |
+
# Clear chat button
|
240 |
+
if st.button("π Clear Chat"):
|
241 |
+
clear_chat()
|
242 |
+
|
243 |
+
# Function to save transcript
|
244 |
+
def save_transcript():
|
245 |
try:
|
246 |
+
transcript = "\n".join([
|
247 |
+
f"{msg['role'].capitalize()}: {msg['content']}"
|
248 |
+
for msg in st.session_state.chat_history
|
249 |
+
])
|
250 |
+
with open(transcript_filename, "w", encoding="utf-8") as f:
|
251 |
+
f.write(transcript)
|
252 |
+
st.success("β
Transcript saved successfully!")
|
|
|
|
|
|
|
253 |
except Exception as e:
|
254 |
+
st.error(f"β Error saving transcript: {str(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
|
256 |
+
# Save transcript button
|
257 |
+
if st.button("πΎ Save Transcript"):
|
258 |
+
save_transcript()
|
|