You are on page 1of 1

import tkinter as tk

def handle_input(event):
# Get the user's input
user_input = entry_field.get()

# Generate a response from the AI


ai_response = generate_ai_response(user_input)

# Display the AI's response


chat_box.insert(tk.END, f"AI: {ai_response}\n")

# Create the main window


root = tk.Tk()
root.title("AI Chatbot")

# Create the chat box


chat_box = tk.Text(root, height=20, width=80, border=2)
chat_box.pack(side=tk.TOP)

# Create the input field


entry_field = tk.Entry(root, width=80)
entry_field.bind("<Return>", handle_input)
entry_field.pack(side=tk.BOTTOM)

# Create the send button


send_button = tk.Button(root, text="Send", command=handle_input)
send_button.pack(side=tk.BOTTOM)

def generate_ai_response(user_input):
# This is where you would implement your AI code
# For now, just return a simple response
return f"You said: {user_input}"

# Start the main loop


root.mainloop()

You might also like