Skip to content

Chatbot creator #21

Description

@rolandmezatsa-sys

python
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
import tkinter as tk

Création du chatbot
bot = chatbot(" Assistant ")
trainer = ChatterBotCorpusTrainer(bot)
trainer.train("chatterbot.corpus.french") # Tu peux aussi ajouter english

Interface graphique
fenetre = tk.Tk()
fenetre.title("ChatBot avec ChatterBot")

Zone d'affichage
conversation = tk.Text(fenetre)
conversation.pack()

champ_texte = tk.Entry(fenetre)
champ_texte.pack()

def envoyer():
question = champ_texte.get()
reponse = bot.get_response(question)

conversation.insert(tk.END, "Vous : " + question + "\n")
conversation.insert(tk.END, "Bot : " + str(reponse) + "\n\n")

champ_texte.delete(0, tk.END)

Bouton d'envoi
bouton_envoyer = tk.Button(fenetre, text="Envoyer", command=envoyer)
bouton_envoyer.pack()

fenetre.mainloop()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions