Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,16 @@
|
|
1 |
-
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
|
5 |
-
{"role": "user", "content": "Who are you?"},
|
6 |
-
]
|
7 |
pipe = pipeline("text-generation", model="IndexTeam/Index-1.9B-Character", trust_remote_code=True)
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|