| import gradio as gr | |
| from transformers import pipeline | |
| # 讬爪讬专转 爪讬谞讜专 AI (text-generation 讗讜 text2text) | |
| generator = pipeline("text2text-generation", model="google/flan-t5-small") | |
| def ai_reply(prompt): | |
| # 砖讜诇讞 讗转 讛讟拽住讟 诇诪讜讚诇 讜诪讞讝讬专 驻诇讟 | |
| result = generator(prompt, max_length=100)[0]['generated_text'] | |
| return result | |
| iface = gr.Interface( | |
| fn=ai_reply, | |
| inputs=gr.Textbox(label="讻转讜讘 诪砖讛讜"), | |
| outputs=gr.Textbox(label="转砖讜讘转 AI") | |
| ) | |
| iface.launch() |