Spaces:
Runtime error
Runtime error
Download app.py from Pierber/creatore_app: direct link, hf CLI and curl.
- Browser
- Download file 955 Bytes
-
https://huggingface.co/spaces/Pierber/creatore_app/resolve/main/app.py
- Command line
-
hf download hf://spaces/Pierber/creatore_app/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Pierber/creatore_app/resolve/main/app.py
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}") |