Kaaaaaaa commited on
Commit
6d3c376
·
verified ·
1 Parent(s): af3e7fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -1,8 +1,16 @@
1
- # Use a pipeline as a high-level helper
2
  from transformers import pipeline
3
 
4
- messages = [
5
- {"role": "user", "content": "Who are you?"},
6
- ]
7
  pipe = pipeline("text-generation", model="IndexTeam/Index-1.9B-Character", trust_remote_code=True)
8
- pipe(messages)
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # 加载模型
 
 
5
  pipe = pipeline("text-generation", model="IndexTeam/Index-1.9B-Character", trust_remote_code=True)
6
+
7
+ # 定义Gradio接口
8
+ def generate_text(prompt):
9
+ messages = [
10
+ {"role": "user", "content": prompt},
11
+ ]
12
+ result = pipe(messages)
13
+ return result[0]['generated_text']
14
+
15
+ iface = gr.Interface(fn=generate_text, inputs="text", outputs="text")
16
+ iface.launch()