|
import gradio as gr |
|
from chatterbot import ChatBot |
|
from chatterbot.trainers import ListTrainer |
|
from chatterbot.trainers import ChatterBotCorpusTrainer |
|
import wikipedia |
|
|
|
chatbot = ChatBot("Chatpot",storage_adapter='chatterbot.storage.SQLStorageAdapter',database_uri = 'sqlite:///database.sqlite3', |
|
logic_adapters=[ { |
|
"import_path": "chatterbot.logic.BestMatch" |
|
} |
|
]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trainer = ChatterBotCorpusTrainer(chatbot) |
|
trainer.train("chatterbot.corpus.english","chatterbot.corpus.english.ai") |
|
|
|
|
|
|
|
|
|
|
|
def greet(name): |
|
text = chatbot.get_response(name) |
|
|
|
if text == "wiki": |
|
result = wikipedia.summary(name, sentences =10) |
|
return result |
|
else: |
|
return str(text) |
|
|
|
iface = gr.Interface(fn=greet, inputs="text", outputs="text") |
|
iface.launch() |