saisha09 commited on
Commit
69dc898
·
1 Parent(s): 5d97677

Testing creation of agent with runtime detector and model selector

Browse files
Files changed (1) hide show
  1. test_env.py +61 -0
test_env.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from dotenv import load_dotenv
3
+ load_dotenv()
4
+ from src.manager import GeminiManager
5
+ from src.tool_manager import ToolManager
6
+ import gradio as gr
7
+ import base64
8
+
9
+ _logo_bytes = open("HASHIRU_LOGO.png", "rb").read()
10
+ _logo_b64 = base64.b64encode(_logo_bytes).decode()
11
+ _header_html = f"""
12
+ <div style="
13
+ display: flex;
14
+ flex-direction: column;
15
+ align-items: center;
16
+ padding-right: 24px;
17
+ ">
18
+ <img src="data:image/png;base64,{_logo_b64}" width="20" height="20" />
19
+ <span style="margin-top: 8px; font-size: 20px; font-weight: bold; color: white;">
20
+ HASHIRU AI - Runtime Test
21
+ </span>
22
+ </div>
23
+ """
24
+
25
+ # -------------------------------
26
+ # ToolManager Agent Creation
27
+ # -------------------------------
28
+ def create_agent_callback():
29
+ print("\n[INFO] Creating agent using ToolManager...")
30
+ manager = ToolManager()
31
+
32
+ response = manager.runTool("AgentCreator", {
33
+ "agent_name": "ui-runtime-agent",
34
+ "system_prompt": "You answer questions.",
35
+ "description": "Agent created via ToolManager",
36
+ # No base_model passed — will trigger dynamic selection
37
+ })
38
+
39
+ print("[TOOL RESPONSE]", response)
40
+ return response["message"]
41
+
42
+ # -------------------------------
43
+ # Gradio UI
44
+ # -------------------------------
45
+ if __name__ == "__main__":
46
+ css = """
47
+ #title-row { background: #2c2c2c; border-radius: 8px; padding: 8px; }
48
+ """
49
+ with gr.Blocks(css=css, fill_width=True, fill_height=True) as demo:
50
+ with gr.Column():
51
+ gr.HTML(_header_html)
52
+ agent_create_button = gr.Button("🧪 Create Agent via ToolManager")
53
+ result_output = gr.Textbox(label="Tool Response")
54
+
55
+ agent_create_button.click(
56
+ fn=create_agent_callback,
57
+ inputs=[],
58
+ outputs=[result_output]
59
+ )
60
+
61
+ demo.launch()