| import gradio as gr |
| from transformers import pipeline |
|
|
| |
| pipe = pipeline("text-generation", model="openchat/openchat_3.5") |
|
|
| |
| def extract_fields(msg): |
| prompt = f"""[INST] Extract structured data from the following message using this form: |
| - วันที่ขึ้นของ |
| - วันที่ส่งของ |
| - ต้นทาง |
| - ปลายทาง |
| |
| Message: |
| {msg} |
| [/INST] |
| """ |
| result = pipe(prompt, max_new_tokens=300, do_sample=False, temperature=0.3) |
| return result[0]["generated_text"] |
|
|
| |
| demo = gr.Interface( |
| fn=extract_fields, |
| inputs=gr.Textbox(lines=10, label="พิมพ์ข้อความจาก LINE"), |
| outputs=gr.Textbox(label="ข้อมูลที่สรุปได้"), |
| title="สรุปข้อมูลจากข้อความ LINE", |
| description="ระบบจะดึงข้อมูล วันที่ขึ้นของ, วันที่ส่งของ, ต้นทาง, ปลายทาง จากข้อความที่ได้รับ" |
| ) |
|
|
| demo.launch() |
|
|