Spaces:
Sleeping
Sleeping
Update app.py
Browse files1234567891011121314151617181920212223242526272829303132333435363738import gradio as grfrom transformers import pipelineimport json# МАЛЕНЬКАЯ, НО УМНАЯ МОДЕЛЬpipe = pipeline("text2text-generation",model="google/flan-t5-small",max_length=512)def extract_tasks(text):prompt = f"""Extract tasks as JSON array. Each task: action, context, details, responsible, deadline, references.Text: {text}JSON:"""try:result = pipe(prompt)[0]['generated_text']# Ищем JSONstart = result.find('[')end = result.rfind(']') + 1if start != -1 and end > start:json_str = result[start:end]return json.loads(json_str)return {"error": "JSON not found", "raw": result}except Exception as e:return {"error": str(e)}iface = gr.Interface(fn=extract_tasks,inputs=gr.Textbox(label="Транскрипт", lines=5),outputs=gr.JSON(label="Задачи"),title="AI Task Extractor (flan-t5-small)",examples=[["Добрый день. Нужно отправить договор. Составить счёт."]])iface.launch(server_name="0.0.0.0", server_port=7860)123456789101112131415161718192021import gradio as grfrom transformers import pipelineimport reimport jsonpipe = pipeline("text2text-generation", model="google/flan-t5-small")def extract_tasks(text):prompt = f"Extract tasks as JSON: [{{\"action\":\"\", \"context\":\"\", \"details\":\"\", \"responsible\":\"\", \"deadline\":\"\", \"references\":[]}}]\nText: {text}\nJSON:"result = pipe(prompt, max_length=512)[0]['generated_text']try:start = result.find('[')end = result.rfind(']') + 1json_str = result[start:end]return json.loads(json_str)except:return {"error": "JSON not found", "raw": result}iface = gr.Interface(fn=extract_tasks, inputs="text", outputs="json", title="Task Extractor")iface.launch(server_name="0.0.0.0")
app.py+10-27