import streamlit as st from huggingface_hub import InferenceClient import os st.set_page_config(page_title="Edu-App Architect", page_icon="🎓") st.title("🎓 Edu-App Architect") hf_token = os.environ.get("HF_TOKEN") if not hf_token: st.error("ERRORE: Manca il token HF_TOKEN nei Settings.") st.stop() client = InferenceClient(api_key=hf_token) prompt = st.text_area("Descrivi l'app didattica:", height=150) if st.button("🚀 Genera Codice"): try: messages = [ {"role": "system", "content": "Sei un esperto Python Streamlit. Scrivi SOLO codice. Inizia con 'import streamlit'."}, {"role": "user", "content": f"Crea app Streamlit per: {prompt}"} ] response = client.chat_completion(model="Qwen/Qwen2.5-Coder-32B-Instruct", messages=messages, max_tokens=2000) st.code(response.choices[0].message.content, language="python") except Exception as e: st.error(f"Errore: {e}")