From 62bec63cc988bb43b6eeadf39a22b156cce80036 Mon Sep 17 00:00:00 2001 From: Nathan Date: Wed, 12 Feb 2025 10:53:44 -0600 Subject: [PATCH] add gui --- flake.nix | 2 ++ src/siren.py | 45 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/flake.nix b/flake.nix index ccfb748..80ebf48 100644 --- a/flake.nix +++ b/flake.nix @@ -19,6 +19,8 @@ buildInputs = with pkgs; [ (python311.withPackages (ps: with ps; [ ollama + tkinter + customtkinter ])) ]; diff --git a/src/siren.py b/src/siren.py index 89168a3..91a8be1 100644 --- a/src/siren.py +++ b/src/siren.py @@ -1,23 +1,46 @@ import ollama +import sys +import customtkinter as ctk -client = ollama.Client( +class App(ctk.CTk): + def __init__(self): + super().__init__() + self.geometry('600x500') + self.title('Siren') + +def chat(): + return client.chat(model=model, messages=messages)['message']['content'] + + +if __name__ == '__main__': + client = ollama.Client( host='https://ollama.blunkall.us' ) -messages = [] + messages = [] -response = '' + response = '' -model = 'llama3.2' + model = 'llama3.2' -userInput = '' + userInput = '' -print('Enter a prompt!') + gui = False -while(userInput != 'stop'): - userInput = input() - if(userInput != 'stop'): - messages += [{ 'role': 'user', 'content': userInput, 'stream': False }] - print(client.chat(model=model, messages=messages)['message']['content']) + for a in sys.argv: + if a == '--gui': + gui = True + + print('Enter a prompt!') + + while(gui == False and userInput != 'stop'): + userInput = input() + if(userInput != 'stop'): + messages += [{ 'role': 'user', 'content': userInput, 'stream': False }] + print(chat()) + + if(gui): + app = App() + app.mainloop()