Download app.py from ngoccs/codefcs: direct link, hf CLI and curl.
- Browser
- Download file 610 Bytes
-
https://huggingface.co/spaces/ngoccs/codefcs/resolve/main/app.py
- Command line
-
hf download hf://spaces/ngoccs/codefcs/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ngoccs/codefcs/resolve/main/app.py
610 Bytes
| import streamlit as st | |
| import google.generativeai as genai | |
| import os | |
| # Cấu hình | |
| st.title("Ứng dụng AI của Ngọc") | |
| # Lấy Key (Bạn phải thêm Key này trong tab Settings của Space) | |
| api_key = os.getenv("GEMINI_API_KEY") | |
| if api_key: | |
| genai.configure(api_key=api_key) | |
| model = genai.GenerativeModel('gemini-1.5-flash') | |
| user_input = st.text_input("Hỏi tôi bất cứ điều gì:") | |
| if st.button("Gửi"): | |
| response = model.generate_content(user_input) | |
| st.write(response.text) | |
| else: | |
| st.error("Bạn chưa cấu hình GEMINI_API_KEY trong mục Settings!") |