-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c75541
commit 58bdd77
Showing
18 changed files
with
639 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ model.pt | |
botive.egg-info/ | ||
dist/ | ||
build/ | ||
botive.egg-info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
"""Entry point for the botiverse package.""" | ||
from botiverse.basic_chatbot.basic_chatbot import basic_chatbot | ||
from botiverse.TODS.TODS import TODS | ||
from botiverse.gui.gui import chat_gui | ||
#from botiverse.TODS.DNN_DST.DNN_DST import DNNDST | ||
#from botiverse.TODS.DNN_TODS import DNNTODS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import tkinter as tk | ||
from tkinter import scrolledtext, messagebox | ||
|
||
class chat_gui: | ||
def __init__(self, chatbot_function, speak_function=None): | ||
self.chatbot_function = chatbot_function | ||
self.speak_function = speak_function | ||
|
||
# Create the main window | ||
self.root = tk.Tk() | ||
self.root.title("Botiverse Chat") | ||
self.root.geometry("600x500") | ||
self.root.configure(bg='#222222') | ||
# disable vertical resizing | ||
self.root.resizable(True, False) | ||
|
||
# Create the chat display area | ||
self.chat_display = scrolledtext.ScrolledText(self.root, width=40, height=30, state='disabled', bg='#1d1d1d', fg='#1d1d1d') | ||
self.chat_display.configure(state='disabled', borderwidth=0) | ||
self.chat_display.configure(highlightthickness=0, relief='flat') | ||
|
||
|
||
# Create the input area | ||
self.input_entry = tk.Entry(self.root, width=30, bg='#505050', fg='#ffffff') | ||
self.input_entry.bind('<Return>', self.process_input) | ||
# remove border form input | ||
self.input_entry.configure(highlightthickness=0, relief='flat') | ||
# increase height of input area | ||
self.input_entry.configure(font=("Avenir", 15)) | ||
|
||
# Create the send button | ||
self.send_button = tk.Button(self.root, text="Send", command=self.process_input, width=10) | ||
# make button grey | ||
self.send_button.configure(bg='#505050', fg='#1d1d1d', activebackground='#1d1d1d', activeforeground='#1d1d1d', background='#1d1d1d', foreground='#1d1d1d') | ||
# remove border from button | ||
#self.send_button.configure(highlightthickness=0, relief='flat') | ||
# set font | ||
self.send_button.configure(font=("Avenir", 18)) | ||
# remove send button | ||
self.send_button.pack_forget() | ||
|
||
# Position the widgets in the window | ||
self.chat_display.pack(fill="both", padx=10, pady=10) | ||
self.input_entry.pack(fill="x", padx=10, pady=5) | ||
self.send_button.pack(fill="x", pady=5) | ||
|
||
def process_input(self, event=None): | ||
# Get the user input | ||
user_input = self.input_entry.get() | ||
self.input_entry.delete(0, 'end') | ||
|
||
# Display user input in the chat area | ||
self.display_message(user_input, user=True) | ||
|
||
# Pass the user input to the chatbot function and get the response | ||
bot_response = self.chatbot_function(user_input) | ||
|
||
# Display bot response in the chat area | ||
self.display_message(bot_response, user=False) | ||
|
||
|
||
def display_message(self, message, user=True): | ||
# Enable the chat display area to insert text | ||
self.chat_display.configure(state='normal') | ||
|
||
# Insert the message into the chat display area with a chat bubble | ||
if user: | ||
self.chat_display.insert('end', message + '\n', 'user') | ||
else: | ||
self.chat_display.insert('end', message + '\n', 'bot') | ||
if self.speak_function is not None: | ||
self.speak_function(message) | ||
|
||
# Disable the chat display area to prevent editing | ||
self.chat_display.configure(state='disabled') | ||
|
||
# Scroll to the bottom of the chat display area | ||
self.chat_display.see('end') | ||
|
||
|
||
|
||
def run(self): | ||
# Configure the chat bubble styles | ||
self.chat_display.tag_configure('user', foreground='white', justify='left', font=('Avenir', 15, 'bold'), | ||
background='#505050', borderwidth=2, relief='solid', | ||
wrap='word', spacing3=10, spacing1=10, lmargin1=10, spacing2=5) | ||
|
||
self.chat_display.tag_configure('bot', foreground='white', justify='right', font=('Avenir', 15, 'bold'), | ||
background='#303030', borderwidth=2, relief='solid', | ||
wrap='word', spacing3=10, spacing1=10, rmargin=10, spacing2=5) | ||
|
||
|
||
|
||
# Start the main GUI loop | ||
self.root.mainloop() | ||
|
||
|
||
# Example usage: | ||
''' | ||
def chatbot_function(input): | ||
# Your chatbot logic goes here | ||
# Process the input and generate a response | ||
response = "Hello! You said: " + input | ||
return response | ||
chat_gui = ChatGUI(chatbot_function) | ||
chat_gui.run() | ||
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.