requirements.txt
Browse files
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# 讬爪讬专转 爪讬谞讜专 AI (text-generation 讗讜 text2text)
|
| 5 |
+
generator = pipeline("text2text-generation", model="google/flan-t5-small")
|
| 6 |
+
|
| 7 |
+
def ai_reply(prompt):
|
| 8 |
+
# 砖讜诇讞 讗转 讛讟拽住讟 诇诪讜讚诇 讜诪讞讝讬专 驻诇讟
|
| 9 |
+
result = generator(prompt, max_length=100)[0]['generated_text']
|
| 10 |
+
return result
|
| 11 |
+
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
fn=ai_reply,
|
| 14 |
+
inputs=gr.Textbox(label="讻转讜讘 诪砖讛讜"),
|
| 15 |
+
outputs=gr.Textbox(label="转砖讜讘转 AI")
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
iface.launch()
|