Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950import streamlit as stimport osimport zipfileimport hashlibimport iost.set_page_config(page_title="منظم الملفات الاحترافي", page_icon="rocket")st.title("منظم الملفات الذكي وموفر المساحة (النسخة الشاملة)")st.write("ارفع ملفاتك الفوضوية، أو ارفع ملف ZIP يحتوي على اي نوع من الملفات وسيتولى البرنامج تنظيفها وحذف المكرر فورا!")uploaded_files = st.file_uploader("اختر الملفات الفوضوية او ملف ZIP من جهازك (الحد الاقصى 200MB):", accept_multiple_files=True, type=None)if uploaded_files:if st.button("ابدا المعالجة والتنظيف الذكي"):processed_files = {}with st.spinner("جاري فحص وتطهير الملفات من التكرار..."):for uploaded_file in uploaded_files:file_bytes = uploaded_file.read()if uploaded_file.name.endswith('.zip'):with zipfile.ZipFile(io.BytesIO(file_bytes)) as z:for z_info in z.infolist():if z_info.is_dir():continuez_file_bytes = z.read(z_info.filename)file_hash = hashlib.md5(z_file_bytes).hexdigest()if file_hash not in processed_files:clean_name = os.path.basename(z_info.filename)processed_files[file_hash] = (clean_name, z_file_bytes)else:file_hash = hashlib.md5(file_bytes).hexdigest()if file_hash not in processed_files:processed_files[file_hash] = (uploaded_file.name, file_bytes)zip_buffer = io.BytesIO()with zipfile.ZipFile(zip_buffer, "w", zipfile.ZIP_DEFLATED) as zip_file:for file_hash, (file_name, file_data) in processed_files.items():zip_file.writestr(file_name, file_data)st.success("تمت العملية بنجاح! تم فحص وتصفية الملفات بدقة.")st.download_button(label="تحميل الملفات المنظمة والمصفاة (ZIP)",data=zip_buffer.getvalue(),file_name="Smart_Organized_Files.zip",mime="application/zip")123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657import streamlit as stfrom groq import Groqimport pandas as pdst.set_page_config(page_title="مجموعة ادوات الذكاء الاصطناعي", page_icon="robot")client = Groq(api_key="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")def ask_ai(prompt):response = client.chat.completions.create(model="llama3-8b-8192",messages=[{"role": "user", "content": prompt}])return response.choices[0].message.contentst.title("مجموعة ادوات الذكاء الاصطناعي")tab1, tab2, tab3 = st.tabs(["تلخيص النصوص", "محتوى سوشال ميديا", "تحليل Excel"])with tab1:st.header("تلخيص النصوص")text = st.text_area("ادخل النص هنا:")if st.button("لخص النص"):if text:with st.spinner("جاري التلخيص..."):result = ask_ai(f"لخص هذا النص باللغة العربية بشكل مختصر ومفيد: {text}")st.success(result)else:st.warning("ادخل نصا اول")with tab2:st.header("توليد محتوى سوشال ميديا")topic = st.text_input("موضوع المنشور:")platform = st.selectbox("المنصة:", ["انستاغرام", "تويتر", "فيسبوك", "تيك توك"])if st.button("ولد المحتوى"):if topic:with st.spinner("جاري توليد المحتوى..."):result = ask_ai(f"اكتب منشور احترافي لمنصة {platform} عن موضوع: {topic} باللغة العربية مع هاشتاقات مناسبة")st.success(result)else:st.warning("ادخل موضوعا اول")with tab3:st.header("تحليل Excel")file = st.file_uploader("ارفع ملف Excel او CSV:", type=["xlsx", "csv"])if file:if file.name.endswith(".csv"):df = pd.read_csv(file)else:df = pd.read_excel(file)st.dataframe(df)question = st.text_input("اسال سوالا عن البيانات:")if st.button("حلل"):if question:with st.spinner("جاري التحليل..."):result = ask_ai(f"عندي بيانات: {df.head(10).to_string()} - {question}")st.success(result)
src/streamlit_app.py+56-49