creatore_app / app.py
Pierber's picture
Update app.py
a0a46d7 verified
Raw History Blame Contribute Delete
955 Bytes
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}")