Spaces:
Sleeping
Sleeping
Download src/streamlit_app.py from fuerr18/Smart-File-Organizer: direct link, hf CLI and curl.
- Browser
- Download file 3.59 kB
-
https://huggingface.co/spaces/fuerr18/Smart-File-Organizer/resolve/main/src/streamlit_app.py
- Command line
-
hf download hf://spaces/fuerr18/Smart-File-Organizer/src/streamlit_app.py
-
curl -L -o streamlit_app.py https://huggingface.co/spaces/fuerr18/Smart-File-Organizer/resolve/main/src/streamlit_app.py
3.59 kB
| import streamlit as st | |
| from groq import Groq | |
| st.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="llama-3.3-70b-versatile", | |
| messages=[{"role": "user", "content": prompt}] | |
| ) | |
| return response.choices[0].message.content | |
| st.title("مجموعة ادوات الذكاء الاصطناعي") | |
| tab1, tab2 = st.tabs(["تلخيص النصوص", "محتوى سوشال ميديا"]) | |
| with tab1: | |
| st.header("تلخيص النصوص") | |
| text = st.text_area("ادخل النص هنا:") | |
| if st.button("لخص النص"): | |
| if text: | |
| with st.spinner("جاري التلخيص..."): | |
| result = ask_ai(f"لخص هذا النص باللغة العربية بشكل مختصر ومفيد: {text}") | |
| st.session_state.summary = result | |
| else: | |
| st.warning("ادخل نصا اول") | |
| if "summary" in st.session_state: | |
| st.text_area("الملخص:", value=st.session_state.summary, height=200) | |
| with tab2: | |
| st.header("توليد محتوى سوشال ميديا") | |
| col1, col2 = st.columns(2) | |
| with col1: | |
| topic = st.text_input("موضوع المنشور:") | |
| platform = st.selectbox("المنصة:", ["انستاغرام", "تويتر/X", "فيسبوك", "تيك توك", "لينكدان"]) | |
| with col2: | |
| tone = st.selectbox("نبرة المنشور:", ["رسمي", "ودي", "مرح", "تحفيزي", "اخباري"]) | |
| lang = st.selectbox("اللغة:", ["العربية", "الانكليزية", "كلاهما"]) | |
| hashtags = st.checkbox("اضف هاشتاقات") | |
| emoji = st.checkbox("اضف ايموجي") | |
| cta = st.checkbox("اضف دعوة للتفاعل") | |
| if st.button("ولد المحتوى"): | |
| if topic: | |
| extras = [] | |
| if hashtags: extras.append("مع هاشتاقات مناسبة") | |
| if emoji: extras.append("مع ايموجي مناسبة") | |
| if cta: extras.append("مع دعوة للتفاعل في النهاية") | |
| prompt = f"اكتب منشور {tone} لمنصة {platform} عن: {topic}. باللغة {lang}. {' '.join(extras)}" | |
| with st.spinner("جاري توليد المحتوى..."): | |
| st.session_state.post = ask_ai(prompt) | |
| else: | |
| st.warning("ادخل موضوعا اول") | |
| if "post" in st.session_state: | |
| st.success("تم توليد المحتوى!") | |
| st.text_area("المحتوى:", value=st.session_state.post, height=200, key="post_display") | |
| st.divider() | |
| st.subheader("حسن المحتوى") | |
| feedback = st.text_input("اكتب طلبك (مثل: اجعله اقصر، غير النبرة، اضف فكرة عن كذا):") | |
| if st.button("عدل المحتوى"): | |
| if feedback: | |
| with st.spinner("جاري التعديل..."): | |
| new_result = ask_ai(f"هذا المنشور:\n{st.session_state.post}\n\nالطلب: {feedback}\n\nعدل المنشور حسب الطلب.") | |
| st.session_state.post = new_result | |
| st.rerun() | |
| st.download_button( | |
| label="تحميل المحتوى", | |
| data=st.session_state.post, | |
| file_name="content.txt", | |
| mime="text/plain" | |
| ) |