Download app.py from neste/nextchat: direct link, hf CLI and curl.
- Browser
- Download file 2.93 kB
-
https://huggingface.co/spaces/neste/nextchat/resolve/main/app.py
- Command line
-
hf download hf://spaces/neste/nextchat/app.py
-
curl -L -o app.py https://huggingface.co/spaces/neste/nextchat/resolve/main/app.py
2.93 kB
| import streamlit as st | |
| import platform | |
| import subprocess | |
| import os | |
| from gettext import gettext as _ | |
| # Definicje zmiennych globalnych | |
| optional_modules = ["numpy", "requests", "flask"] | |
| dependencies = ["git", "curl", "python3"] | |
| # Funkcje | |
| def detect_os(): | |
| os_name = platform.system() | |
| if os_name == "Linux": | |
| return "Linux" | |
| elif os_name == "Windows": | |
| return "Windows" | |
| elif os_name == "Darwin": | |
| return "macOS" | |
| else: | |
| return _("Nieznany") | |
| current_os = detect_os() | |
| def install_dependencies(dependencies): | |
| commands = [] | |
| if current_os == "Linux": | |
| for dep in dependencies: | |
| commands.append(f"sudo apt-get install -y {dep}") # Adjust if needed | |
| elif current_os == "Windows": | |
| for dep in dependencies: | |
| commands.append(f"choco install {dep}") # Ensure Chocolatey works | |
| elif current_os == "macOS": | |
| for dep in dependencies: | |
| commands.append(f"brew install {dep}") | |
| return commands | |
| def suggest_optional_modules(modules): | |
| return [f"- {mod}" for mod in modules] | |
| def check_version(command): | |
| try: | |
| result = subprocess.run([command, "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
| return result.stdout.decode() | |
| except FileNotFoundError: | |
| return f"{command} " + _("nie jest zainstalowany.") | |
| # Funkcja do wyboru języka | |
| def set_language(): | |
| language = st.sidebar.radio( | |
| _("Wybierz język / Choose language"), | |
| ["Polski", "English"], | |
| index=0 # Domyślny język to polski | |
| ) | |
| if language == "Polski": | |
| return "pl" | |
| else: | |
| return "en" | |
| # Ustawienie języka | |
| language = set_language() | |
| if language == "pl": | |
| import locale | |
| locale.setlocale(locale.LC_ALL, 'pl_PL.UTF-8') | |
| # Aplikacja Streamlit | |
| def main(): | |
| # Menu | |
| st.sidebar.title(_("Menu")) | |
| selected_page = st.sidebar.radio(_("Wybierz stronę / Choose page"), [_("Instalacja"), _("Informacje")]) | |
| if selected_page == _("Instalacja"): | |
| st.title(_("Asystent instalacji")) | |
| st.write(_("Wykryty system operacyjny: {}").format(current_os)) | |
| if st.button(_("Sprawdź zależności / Check dependencies")): | |
| deps_output = install_dependencies(dependencies) | |
| for line in deps_output: | |
| st.code(line, language='bash') | |
| optional_modules_output = suggest_optional_modules(optional_modules) | |
| st.write(_("Sugerowane moduły opcjonalne / Suggested Optional Modules:")) | |
| for line in optional_modules_output: | |
| st.write(line) | |
| st.write(_("Sprawdź wersje / Check Versions:")) | |
| st.code(check_version("python3"), language='bash') | |
| st.code(check_version("git"), language='bash') | |
| elif selected_page == _("Informacje"): | |
| st.title(_("Informacje / Information")) | |
| # ... (kod wyświetlający informacje) | |
| if __name__ == "__main__": | |
| main() |