jslin09 commited on
Commit
28f307c
1 Parent(s): 8c28f7d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -11
app.py CHANGED
@@ -5,8 +5,8 @@ import random
5
  generator = pipeline('text-generation', model='jslin09/bloom-560m-finetuned-fraud')
6
 
7
  def generate(text):
8
- seed = random.randint(10, 500)
9
- set_seed(seed)
10
  result = generator(text,
11
  max_length=500,
12
  num_return_sequences=1,
@@ -22,14 +22,19 @@ examples = [
22
  ["王大明意圖為自己不法所有,基於竊盜之犯意,"]
23
  ]
24
 
25
- demo = gr.Interface(
26
- fn=generate,
27
- title="Legal Document Drafting",
28
- inputs=gr.components.Textbox(lines=5, label="輸入提示文字",placeholder=examples[0]),
29
- outputs=gr.components.Textbox(label="生成的草稿"),
30
- examples=examples,
31
- cache_examples=False
32
- )
 
 
 
 
 
33
 
34
  if __name__ == "__main__":
35
- demo.launch()
 
5
  generator = pipeline('text-generation', model='jslin09/bloom-560m-finetuned-fraud')
6
 
7
  def generate(text):
8
+ rnd_seed = random.randint(10, 500)
9
+ set_seed(rnd_seed)
10
  result = generator(text,
11
  max_length=500,
12
  num_return_sequences=1,
 
22
  ["王大明意圖為自己不法所有,基於竊盜之犯意,"]
23
  ]
24
 
25
+ with gr.Blocks() as demo:
26
+ gr.Markdown(
27
+ """
28
+ # <p style="text-align: center;">Legal Document Drafting</p>
29
+ """)
30
+ with gr.Row():
31
+ with gr.Column():
32
+ prompt = gr.components.Textbox(lines=5, label="輸入提示文字", placeholder=examples[0])
33
+ btn = gr.Button("生成草稿")
34
+ gr.Examples(examples, inputs=[prompt])
35
+ with gr.Column():
36
+ result = gr.components.Textbox(label="生成的草稿")
37
+ btn.click(generate, inputs=[prompt], outputs=[result])
38
 
39
  if __name__ == "__main__":
40
+ demo.launch() # 在遠端啟動時,需要 share=True 。