Skip to content

Commit

Permalink
Added dark mode to demo gradio #48
Browse files Browse the repository at this point in the history
  • Loading branch information
VRSEN committed Jan 29, 2024
1 parent 6bbd3c7 commit de75064
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions agency_swarm/agency/agency.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,33 @@ def get_completion(self, message: str, message_files=None, yield_messages=True):

return gen

def demo_gradio(self, height=600):
def demo_gradio(self, height=600, dark_mode=True):
"""
Launches a Gradio-based demo interface for the agency chatbot.
Parameters:
height (int, optional): The height of the chatbot widget in the Gradio interface. Default is 600.
dark_mode (bool, optional): Flag to determine if the interface should be displayed in dark mode. Default is True.
This method sets up and runs a Gradio interface, allowing users to interact with the agency's chatbot. It includes a text input for the user's messages and a chatbot interface for displaying the conversation. The method handles user input and chatbot responses, updating the interface dynamically.
"""
try:
import gradio as gr
except ImportError:
raise Exception("Please install gradio: pip install gradio")

with gr.Blocks() as demo:
js = """function () {
gradioURL = window.location.href
if (!gradioURL.endsWith('?__theme={theme}')) {
window.location.replace(gradioURL + '?__theme={theme}');
}
}"""

if dark_mode:
js = js.replace("{theme}", "dark")
else:
js = js.replace("{theme}", "light")

with gr.Blocks(js=js) as demo:
chatbot = gr.Chatbot(height=height)
msg = gr.Textbox()

Expand Down

0 comments on commit de75064

Please sign in to comment.