File size: 969 Bytes
e641e34
f48d575
 
6a397bd
92ad35f
f3af7d2
445e541
 
81effc8
445e541
 
cd7f54a
292ff41
5b6bdce
efdc6c0
6a397bd
 
292ff41
 
6a397bd
 
292ff41
6a397bd
445e541
6a397bd
 
5b6bdce
 
cd7f54a
e641e34
cd7f54a
92ad35f
 
 
 
ce2e0b4
 
e641e34
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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"
        }
    ])




#file1 = open("dialogs.txt", "r")
#training_data = file1.read().splitlines()


#trainer = ListTrainer(chatbot)
#trainer.train(training_data)

trainer = ChatterBotCorpusTrainer(chatbot)
trainer.train("chatterbot.corpus.english","chatterbot.corpus.english.ai")

#print(training_data)



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()