HALcom commited on
Commit
0363d82
·
verified ·
1 Parent(s): ae7af21

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -3
app.py CHANGED
@@ -1,7 +1,33 @@
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
+ # 日本語対応の Llama3 系モデル(無料)を使用
5
+ model = pipeline(
6
+ "text-generation",
7
+ model="meta-llama/Llama-3-8b-instruct",
8
+ max_new_tokens=300
9
+ )
10
+
11
+ def chat(history, user_input):
12
+ # モデルに文章を投げて回答を生成
13
+ response = model(user_input)[0]["generated_text"]
14
+ history.append((user_input, response))
15
+ return history, ""
16
+
17
+ with gr.Blocks() as demo:
18
+ gr.Markdown("## 📘 日本語文章の要約・質問チャット")
19
+
20
+ chatbot = gr.Chatbot(height=500)
21
+ text_input = gr.Textbox(
22
+ label="ここに文章を貼り付けて質問してください",
23
+ placeholder="例:この文章を要約して、など"
24
+ )
25
+
26
+ text_input.submit(
27
+ chat,
28
+ inputs=[chatbot, text_input],
29
+ outputs=[chatbot, text_input]
30
+ )
31
 
 
32
  demo.launch()
33
+