import streamlit as st import json import requests # Sidebar for options st.sidebar.title("Settings") # model_options = ["GPT-3.5-turbo", "GPT-4o"] # selected_model = st.sidebar.selectbox("Choose the AI model:", model_options) language_options = ["Français","English"] selected_language = st.sidebar.radio("Choose the language:", language_options) if 'mots_cles_associes' not in st.session_state: st.session_state.mots_cles_associes = "" # Main container st.title('Générateur d’articles SEO' if selected_language == "Français" else 'SEO Article Generator') if selected_language == "Français": st.subheader('Entrez les détails de votre article:') titre_article = st.text_input('Sujet:') mot_cle_principal = st.text_input('Mot-clé principal:') ton_cible = st.text_input('Ton ciblé:') optionnel_data = st.text_input('Ajoutez des données (optionnel):') else: st.subheader('Enter the details of your article:') titre_article = st.text_input('Article Title:') mot_cle_principal = st.text_input('Main Keyword:') ton_cible = st.text_input('Target Tone:') optionnel_data = st.text_input('Add content (optional):') # Display the text field with the value from session state # mots_cles_associes = st.text_input('Mots-clés associés (séparés par des virgules):', value=st.session_state.mots_cles_associes) if st.button('Générer l’article' if selected_language == "Français" else 'Generated Article'): if titre_article and mot_cle_principal and ton_cible : if selected_language =="Français": url = "https://nechba-seo-article-generate.hf.space/generate_article_fr" headers = { "titre_article": titre_article, "mot_cle_principal": mot_cle_principal, "ton_cible": ton_cible, "optionnel_data": optionnel_data } else: url = "https://nechba-seo-article-generate.hf.space/generate_article_eng" headers = { "article_title": titre_article, "main_keyword": mot_cle_principal, "target_tone": ton_cible, "optionnel_data": optionnel_data } response = requests.post(url, json=headers) if response.status_code != 200: st.error('Gemini quota reached (Think about upgrading Gemini)' if selected_language == "Français" else 'Gemini failed to generate article.') st.stop() else: article = response.text json_data = json.loads(article) article = json_data['article'] st.subheader('Article généré' if selected_language == "Français" else 'Generated Article') #st.markdown(article) st.markdown(article, unsafe_allow_html=True) #st.markdown("Copiez le texte Markdown ci-dessus!" if selected_language == "Français" else "Copy the above Markdown text!", unsafe_allow_html=True) else: st.error('Veuillez entrer à la fois un sujet et des mots-clés.' if selected_language == "Français" else 'Please enter both a topic and some keywords.')