|
import tkinter as tk |
|
from tkinter import messagebox |
|
import asyncio |
|
from ai_system.ai_core import AICore |
|
|
|
class AIApplication(tk.Tk): |
|
def __init__(self): |
|
super().__init__() |
|
self.ai = AICore() |
|
self.title("AI Assistant - Ultimate Edition") |
|
self.geometry("1200x700") |
|
self._init_ui() |
|
|
|
def _init_ui(self): |
|
self.query_entry = tk.Entry(self, width=100) |
|
self.query_entry.pack(pady=10) |
|
tk.Button(self, text="Submit", command=self._submit_query).pack() |
|
self.response_area = tk.Text(self, width=120, height=30) |
|
self.response_area.pack(pady=10) |
|
|
|
def _submit_query(self): |
|
query = self.query_entry.get() |
|
if not query: |
|
return |
|
async def process(): |
|
result = await self.ai.generate_response(query, 1) |
|
self.response_area.insert(tk.END, f"Response: {result['response']} |
|
|
|
") |
|
asyncio.run_coroutine_threadsafe(process(), asyncio.get_event_loop()) |
|
|
|
if __name__ == "__main__": |
|
app = AIApplication() |
|
app.mainloop() |
|
|