Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # 日本語T5モデルをロード(サイズは base。必要なら large に変更可) | |
| pipe = pipeline("text2text-generation", model="sonoisa/t5-base-japanese") | |
| def format_report(memo): | |
| if not memo.strip(): | |
| return "⚠️ 入力が空です。事故メモを入力してください。" | |
| # プロンプトを工夫して「報告書風」に整えるよう指示 | |
| input_text = f"以下のメモを特養での事故報告書の文章に整えてください。\n{memo}" | |
| try: | |
| result = pipe(input_text, max_length=512, do_sample=False) | |
| return result[0]["generated_text"] | |
| except Exception as e: | |
| return f"⚠️ エラーが発生しました: {str(e)}" | |
| iface = gr.Interface( | |
| fn=format_report, | |
| inputs=gr.Textbox(lines=8, placeholder="ここに事故のメモを入力してください"), | |
| outputs="text", | |
| title="事故報告書整理AI", | |
| description="介護現場での事故メモを、報告書形式の文章に整えます。" | |
| ) | |
| iface.launch() | |