Refactor: improve run.sh startup logic and ensure proper permissions
This commit is contained in:
58
frontend/ui.py
Normal file
58
frontend/ui.py
Normal file
@@ -0,0 +1,58 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
import streamlit as st
|
||||
|
||||
st.set_page_config(page_title="DevOps AI Assistant", page_icon="🚀")
|
||||
|
||||
st.title("🤖 AI CI/CD Pipeline Generator")
|
||||
st.markdown("Прототип сервиса для генерации и валидации конфигураций")
|
||||
|
||||
|
||||
def _env(name: str, default: str) -> str:
|
||||
value = os.getenv(name)
|
||||
return value if value else default
|
||||
|
||||
|
||||
default_backend_url = _env("BACKEND_URL", "http://backend:8000/generate")
|
||||
|
||||
with st.sidebar:
|
||||
st.header("Настройки")
|
||||
api_url = st.text_input("Backend URL", default_backend_url)
|
||||
model = st.selectbox(
|
||||
"LLM Модель",
|
||||
["deepseek-r1:1.5b", "qwen2.5-coder:1.5b", "llama3.1:8b", "Arena Model"],
|
||||
)
|
||||
platform = st.radio("Платформа", ["GitHub Actions", "GitLab CI"])
|
||||
|
||||
user_input = st.text_area(
|
||||
"Опишите пайплайн (например: 'Python app with pytest and docker build')", height=150
|
||||
)
|
||||
|
||||
if st.button("Сгенерировать конфигурацию", type="primary"):
|
||||
if user_input:
|
||||
with st.spinner("LLM думает..."):
|
||||
try:
|
||||
res = requests.post(
|
||||
api_url,
|
||||
json={"description": user_input, "platform": platform, "model": model},
|
||||
timeout=90,
|
||||
)
|
||||
res.raise_for_status()
|
||||
data = res.json()
|
||||
|
||||
if data.get("status") == "ok":
|
||||
st.success("✅ Конфигурация валидна!")
|
||||
st.code(data.get("config", ""), language="yaml")
|
||||
st.download_button(
|
||||
"Скачать .yml",
|
||||
data.get("config", ""),
|
||||
file_name="pipeline.yml",
|
||||
)
|
||||
else:
|
||||
st.error(f"❌ Ошибка валидации: {data.get('validation_error')}")
|
||||
st.code(data.get("config", ""), language="yaml")
|
||||
except Exception as e:
|
||||
st.error(f"Ошибка подключения к бекенду: {e}")
|
||||
else:
|
||||
st.warning("Пожалуйста, введите описание.")
|
||||
Reference in New Issue
Block a user