diff --git a/omni_ui.py b/omni_ui.py index 05ac8194..f3e0c4f6 100644 --- a/omni_ui.py +++ b/omni_ui.py @@ -1,18 +1,25 @@ -#Import required libraries +# Import required libraries from gradio import Interface, Textbox, HTML import threading import os import glob import base64 -from langchain.llms import OpenAIChat -from swarms.agents import OmniModalAgent +from langchain.llms import OpenAIChat +from swarms.agents import OmniModalAgent +import gradio_client as grc + +grc.Client("Wawaa/omniagent").deploy_discord() + +# Function to convert image to base64 + -#Function to convert image to base64 def image_to_base64(image_path): with open(image_path, "rb") as image_file: return base64.b64encode(image_file.read()).decode() -#Function to get the most recently created image in the directory +# Function to get the most recently created image in the directory + + def get_latest_image(): list_of_files = glob.glob('./*.png') # Replace with your image file type if not list_of_files: @@ -20,19 +27,22 @@ def get_latest_image(): latest_file = max(list_of_files, key=os.path.getctime) return latest_file -#Initialize your OmniModalAgent + +# Initialize your OmniModalAgent llm = OpenAIChat(model_name="gpt-4") # Replace with your actual initialization agent = OmniModalAgent(llm) # Replace with your actual initialization -#Global variable to store chat history +# Global variable to store chat history chat_history = [] -#Function to update chat +# Function to update chat + + def update_chat(user_input): global chat_history chat_history.append({"type": "user", "content": user_input}) - #Get agent response + # Get agent response agent_response = agent.run(user_input) # Handle the case where agent_response is not in the expected dictionary format @@ -48,7 +58,8 @@ def update_chat(user_input): return render_chat(chat_history) -#Function to render chat as HTML +# Function to render chat as HTML + def render_chat(chat_history): chat_str = "