Fix Gradio 6.0: removed css from Blocks, removed show_api from launch
Browse files
app.py
CHANGED
|
@@ -44,10 +44,10 @@ def run_command(command: str, cwd: str = ".") -> str:
|
|
| 44 |
|
| 45 |
def execute(tool_name: str, tool_args: dict) -> str:
|
| 46 |
fns = {
|
| 47 |
-
"calculator":
|
| 48 |
"get_current_time": get_current_time,
|
| 49 |
-
"search_files":
|
| 50 |
-
"run_command":
|
| 51 |
}
|
| 52 |
return fns.get(tool_name, lambda: f"Unknown: {tool_name}")()
|
| 53 |
|
|
@@ -69,11 +69,11 @@ def respond(message: str):
|
|
| 69 |
cmd = m.group(1) if m else message.split()[-1]
|
| 70 |
tool, args = "run_command", {"command": cmd, "cwd": "."}
|
| 71 |
else:
|
| 72 |
-
return "This is a demo of Stack X Ultimate's tool-calling capability. The fine-tuned model processes your message and
|
| 73 |
|
| 74 |
result = execute(tool, args)
|
| 75 |
call = f"π§ Calling `{tool}`...\n\n```json\n{json.dumps(args, indent=2)}\n```"
|
| 76 |
-
res
|
| 77 |
return [[call, res]]
|
| 78 |
|
| 79 |
# βββ Gradio UI ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -86,23 +86,15 @@ EXAMPLES = [
|
|
| 86 |
"Calculate 15% tip on a $87 bill",
|
| 87 |
]
|
| 88 |
|
| 89 |
-
DARK = """
|
| 90 |
-
body { background: #0a0a0a; color: #e0e0e0; font-family: system-ui, sans-serif; }
|
| 91 |
-
.gradio-container { background: #0a0a0a; }
|
| 92 |
-
.chat { background: #0a0a0a; }
|
| 93 |
-
"""
|
| 94 |
-
|
| 95 |
def build():
|
| 96 |
-
with gr.Blocks(
|
| 97 |
gr.Markdown(
|
| 98 |
-
"## π€ Stack X Ultimate\n"
|
| 99 |
"**Open-source agentic model with tool calling.** Deploy on your own GPU β no API key, no data leaving your server.\n\n"
|
| 100 |
-
"π’ `calculator` Β· π `get_current_time` Β· π `search_files` Β· β‘ `run_command`"
|
| 101 |
-
|
| 102 |
)
|
| 103 |
|
| 104 |
-
gr.Markdown("**3B params Β· Q4 GGUF Β· V100 1 GPU Β· $0 API Cost Β· 8K context**")
|
| 105 |
-
|
| 106 |
chatbot = gr.Chatbot(height=400)
|
| 107 |
|
| 108 |
with gr.Row():
|
|
@@ -125,9 +117,4 @@ def build():
|
|
| 125 |
|
| 126 |
if __name__ == "__main__":
|
| 127 |
demo = build()
|
| 128 |
-
demo.launch(
|
| 129 |
-
server_name="0.0.0.0",
|
| 130 |
-
server_port=7860,
|
| 131 |
-
max_threads=4,
|
| 132 |
-
show_api=False,
|
| 133 |
-
)
|
|
|
|
| 44 |
|
| 45 |
def execute(tool_name: str, tool_args: dict) -> str:
|
| 46 |
fns = {
|
| 47 |
+
"calculator": lambda: calculator(tool_args.get("expression", "")),
|
| 48 |
"get_current_time": get_current_time,
|
| 49 |
+
"search_files": lambda: search_files(tool_args.get("path", "."), tool_args.get("pattern", "*")),
|
| 50 |
+
"run_command": lambda: run_command(tool_args.get("command", ""), tool_args.get("cwd", ".")),
|
| 51 |
}
|
| 52 |
return fns.get(tool_name, lambda: f"Unknown: {tool_name}")()
|
| 53 |
|
|
|
|
| 69 |
cmd = m.group(1) if m else message.split()[-1]
|
| 70 |
tool, args = "run_command", {"command": cmd, "cwd": "."}
|
| 71 |
else:
|
| 72 |
+
return "This is a demo of Stack X Ultimate's tool-calling capability. The fine-tuned model processes your message and decides whether to call a tool. Try one of the examples below! π§"
|
| 73 |
|
| 74 |
result = execute(tool, args)
|
| 75 |
call = f"π§ Calling `{tool}`...\n\n```json\n{json.dumps(args, indent=2)}\n```"
|
| 76 |
+
res = f"β
**{tool}** result:\n\n```\n{result}\n```"
|
| 77 |
return [[call, res]]
|
| 78 |
|
| 79 |
# βββ Gradio UI ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 86 |
"Calculate 15% tip on a $87 bill",
|
| 87 |
]
|
| 88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
def build():
|
| 90 |
+
with gr.Blocks(title="Stack X Ultimate") as demo:
|
| 91 |
gr.Markdown(
|
| 92 |
+
"## π€ Stack X Ultimate\n\n"
|
| 93 |
"**Open-source agentic model with tool calling.** Deploy on your own GPU β no API key, no data leaving your server.\n\n"
|
| 94 |
+
"π’ `calculator` Β· π `get_current_time` Β· π `search_files` Β· β‘ `run_command`\n\n"
|
| 95 |
+
"**3B params Β· Q4 GGUF Β· V100 1 GPU Β· $0 API Cost Β· 8K context**"
|
| 96 |
)
|
| 97 |
|
|
|
|
|
|
|
| 98 |
chatbot = gr.Chatbot(height=400)
|
| 99 |
|
| 100 |
with gr.Row():
|
|
|
|
| 117 |
|
| 118 |
if __name__ == "__main__":
|
| 119 |
demo = build()
|
| 120 |
+
demo.launch(server_name="0.0.0.0", server_port=7860, max_threads=4)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|