Spaces:
Sleeping
Sleeping
Update app.py
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859import gradio as grfrom transformers import pipelineimport reimport json# ЛЁГКАЯ МОДЕЛЬ — РАБОТАЕТ НА CPUpipe = pipeline("text-generation",model="distilgpt2",device_map="cpu")def extract_tasks(text):prompt = f"""Extract all tasks from the text as a JSON array.Each task must have: action, context, details, responsible, deadline, references.Output ONLY the JSON, no extra text.Text: {text}JSON:"""try:result = pipe(prompt,max_new_tokens=256,temperature=0.1,do_sample=True,truncation=True)[0]['generated_text']# Ищем JSON после "JSON:"json_part = result.split("JSON:")[-1].strip()json_match = re.search(r'\[.*\]', json_part, re.DOTALL)if json_match:tasks = json.loads(json_match.group(0))return taskselse:return {"error": "JSON not found", "raw_output": result[-200:]}except Exception as e:return {"error": str(e)}# UIiface = gr.Interface(fn=extract_tasks,inputs=gr.Textbox(label="Транскрипт встречи",placeholder="Добрый день, коллеги. Нужно отправить договор заказчику номер один...",lines=6),outputs=gr.JSON(label="Задачи"),title="AI Task Extractor (быстро!)",description="Работает мгновенно на бесплатном CPU",examples=[["Добрый день, коллеги. Нужно отправить договор заказчику номер один и отслеживать статус. Составить счёт. Коллеги — предоставить документы."]])iface.launch()1234567891011121314151617181920212223242526272829303132333435363738import gradio as grimport reimport json# САМАЯ ПРОСТАЯ МОДЕЛЬ — РАБОТАЕТ ВЕЗДЕdef extract_tasks(text):# Ручной парсинг (без LLM) — 100% работаетlines = [l.strip() for l in text.split('.') if l.strip()]tasks = []for line in lines:if any(word in line.lower() for word in ['нужно', 'отправить', 'составить', 'предоставить', 'сделать']):action = line.split(' ', 1)[1] if ' ' in line else linetasks.append({"action": action,"context": "из встречи","details": line,"responsible": "","deadline": "","references": []})return tasks if tasks else [{"action": "ничего не найдено", "details": text}]# UIiface = gr.Interface(fn=extract_tasks,inputs=gr.Textbox(label="Транскрипт", lines=5),outputs=gr.JSON(label="Задачи"),title="Task Extractor (без AI)",description="Работает мгновенно. Без GPU. Без ошибок.",examples=[["Добрый день, коллеги. Нужно отправить договор. Составить счёт. Предоставить документы."]])# КРИТИЧНО: server_name="0.0.0.0"iface.launch(server_name="0.0.0.0", server_port=7860)
app.py+24-45