Spaces:
Running
Running
Kunal Pai commited on
Commit ·
b27e104
1
Parent(s): 81fafc1
Add HASHIRU logo and update UI header in main.py
Browse files- HASHIRU_LOGO.png +3 -0
- main.py +44 -4
HASHIRU_LOGO.png
ADDED
|
Git LFS Details
|
main.py
CHANGED
|
@@ -3,13 +3,30 @@ from src.manager import GeminiManager
|
|
| 3 |
from src.tool_loader import ToolLoader
|
| 4 |
import gradio as gr
|
| 5 |
import time
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
if __name__ == "__main__":
|
| 8 |
# Define the tool metadata for orchestration.
|
| 9 |
# Load the tools using the ToolLoader class.
|
| 10 |
tool_loader = ToolLoader()
|
| 11 |
|
| 12 |
-
model_manager = GeminiManager(toolsLoader=tool_loader, gemini_model="gemini-2.
|
| 13 |
|
| 14 |
def user_message(msg: str, history: list) -> tuple[str, list]:
|
| 15 |
"""Adds user message to chat history"""
|
|
@@ -29,10 +46,33 @@ if __name__ == "__main__":
|
|
| 29 |
new_history[-1]['content'] = edit_data.value
|
| 30 |
# yield new_history, gr.update(interactive=False,)
|
| 31 |
yield from model_manager.run(new_history)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
chatbot = gr.Chatbot(
|
| 37 |
avatar_images=("HASHIRU_2.png", "HASHIRU.png"),
|
| 38 |
type="messages",
|
|
|
|
| 3 |
from src.tool_loader import ToolLoader
|
| 4 |
import gradio as gr
|
| 5 |
import time
|
| 6 |
+
import base64
|
| 7 |
+
|
| 8 |
+
_logo_bytes = open("HASHIRU_LOGO.png", "rb").read()
|
| 9 |
+
_logo_b64 = base64.b64encode(_logo_bytes).decode()
|
| 10 |
+
_header_html = f"""
|
| 11 |
+
<div style="
|
| 12 |
+
display: flex;
|
| 13 |
+
flex-direction: column;
|
| 14 |
+
align-items: center;
|
| 15 |
+
padding-right: 24px;
|
| 16 |
+
">
|
| 17 |
+
<img src="data:image/png;base64,{_logo_b64}" width="20" height="20" />
|
| 18 |
+
<span style="margin-top: 8px; font-size: 20px; font-weight: bold; color: white;">
|
| 19 |
+
HASHIRU AI
|
| 20 |
+
</span>
|
| 21 |
+
</div>
|
| 22 |
+
"""
|
| 23 |
|
| 24 |
if __name__ == "__main__":
|
| 25 |
# Define the tool metadata for orchestration.
|
| 26 |
# Load the tools using the ToolLoader class.
|
| 27 |
tool_loader = ToolLoader()
|
| 28 |
|
| 29 |
+
model_manager = GeminiManager(toolsLoader=tool_loader, gemini_model="gemini-2.0-flash")
|
| 30 |
|
| 31 |
def user_message(msg: str, history: list) -> tuple[str, list]:
|
| 32 |
"""Adds user message to chat history"""
|
|
|
|
| 46 |
new_history[-1]['content'] = edit_data.value
|
| 47 |
# yield new_history, gr.update(interactive=False,)
|
| 48 |
yield from model_manager.run(new_history)
|
| 49 |
+
|
| 50 |
+
def update_model(model_name):
|
| 51 |
+
print(f"Model changed to: {model_name}")
|
| 52 |
+
pass
|
| 53 |
|
| 54 |
+
css = """
|
| 55 |
+
#title-row { background: #2c2c2c; border-radius: 8px; padding: 8px; }
|
| 56 |
+
"""
|
| 57 |
+
with gr.Blocks(css=css) as demo:
|
| 58 |
+
with gr.Row():
|
| 59 |
+
gr.HTML(_header_html)
|
| 60 |
+
model_dropdown = gr.Dropdown(
|
| 61 |
+
choices=[
|
| 62 |
+
"HASHIRU",
|
| 63 |
+
"Static-HASHIRU",
|
| 64 |
+
"Cloud-Only HASHIRU",
|
| 65 |
+
"Local-Only HASHIRU",
|
| 66 |
+
"No-Economy HASHIRU",
|
| 67 |
+
],
|
| 68 |
+
value="HASHIRU",
|
| 69 |
+
# label="HASHIRU",
|
| 70 |
+
scale=4,
|
| 71 |
+
interactive=True,
|
| 72 |
+
)
|
| 73 |
+
|
| 74 |
+
model_dropdown.change(fn=update_model, inputs=model_dropdown, outputs=[])
|
| 75 |
+
|
| 76 |
chatbot = gr.Chatbot(
|
| 77 |
avatar_images=("HASHIRU_2.png", "HASHIRU.png"),
|
| 78 |
type="messages",
|