File size: 955 Bytes
637925e
 
 
 
 
 
 
 
 
a0a46d7
637925e
 
 
 
a0a46d7
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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}")