backzone1 commited on
Commit
b669844
·
1 Parent(s): 137d911

Add application file

Browse files
Files changed (1) hide show
  1. app.py +21 -4
app.py CHANGED
@@ -1,7 +1,24 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ pipe = pipeline("text-generation", model="openchat/openchat_3.5")
 
5
 
6
+ # Prompt แบบ role-play
7
+ prompt = """[INST] Extract structured data from the following message using this form:
8
+ - วันที่ขึ้นของ
9
+ - วันที่ส่งของ
10
+ - ต้นทาง
11
+ - ปลายทาง
12
+
13
+ Message:
14
+ เข้ารับของวัน พุธ ที่ 28/05/2568
15
+ ส่งโหลด วัน พฤหัส ที่ 29/05/2568
16
+ ห้วยกระเจา - BBL
17
+ เข้ารับของวัน พฤหัส ที่ 29/05/2568
18
+ ส่งโหลด วัน ศุกร์ ที่ 30/05/2568
19
+ ห้วยกระเจา - BBL
20
+ [/INST]
21
+ """
22
+
23
+ result = pipe(prompt, max_new_tokens=300, do_sample=False)
24
+ print(result[0]["generated_text"])