fn
Browse files
app.py
CHANGED
|
@@ -1,14 +1,16 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
| 3 |
|
| 4 |
-
def simple(message,history):
|
| 5 |
-
|
| 6 |
-
|
| 7 |
|
| 8 |
chatbot = gr.ChatInterface(
|
|
|
|
| 9 |
title="Simple Pattern Bot",
|
| 10 |
description="I respond to basic patterns (try saying hi or asking a question)",
|
| 11 |
examples=["Hello", "How are you?", "What's your name?"],
|
| 12 |
)
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
| 3 |
|
| 4 |
+
def simple(message, history):
|
| 5 |
+
responses = ["Hello", "How are you?", "What's your name?"]
|
| 6 |
+
return random.choice(responses)
|
| 7 |
|
| 8 |
chatbot = gr.ChatInterface(
|
| 9 |
+
fn=simple, # 添加了fn参数指向你的聊天函数
|
| 10 |
title="Simple Pattern Bot",
|
| 11 |
description="I respond to basic patterns (try saying hi or asking a question)",
|
| 12 |
examples=["Hello", "How are you?", "What's your name?"],
|
| 13 |
)
|
| 14 |
|
| 15 |
+
if __name__ == "__main__":
|
| 16 |
+
chatbot.launch()
|