import os from huggingface_hub import InferenceClient import gradio as gr # Настраиваем HF‑клиент HF_TOKEN = os.getenv("HF_HUB_TOKEN") if not HF_TOKEN: raise RuntimeError("Не задан HF_HUB_TOKEN в настройках Space") client = InferenceClient(token=HF_TOKEN) def generate_bpmn(description: str) -> str: prompt = ( "You are a BPMN 2.0 XML generator.\n" "Given this plain-text process description:\n" f"{description}\n" "Output ONLY valid BPMN 2.0 XML, without any extra text." ) # Вызываем HF Inference API (без FastAPI) result = client.text_generation( prompt, model="ministral/Ministral-3b-instruct", max_new_tokens=1024, temperature=0.0, do_sample=False, details=True ) xml = result[0].generated_text # отрезаем всё до if "