Spaces:
Runtime error
Runtime error
feat: improve general UI
Browse files
app.py
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
|
|
| 1 |
from typing import NamedTuple
|
| 2 |
|
| 3 |
import gradio as gr
|
|
|
|
|
|
|
| 4 |
|
| 5 |
from tdagent.tools.get_domain_information import (
|
| 6 |
dns_enumeration_tool,
|
|
@@ -26,6 +29,21 @@ from tdagent.tools.virus_total import gr_virus_total_url_info
|
|
| 26 |
## Tools to load into the application interface ##
|
| 27 |
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
class ToolInfo(NamedTuple):
|
| 30 |
"""Gradio MCP tool info."""
|
| 31 |
|
|
@@ -55,11 +73,60 @@ TOOLS = (
|
|
| 55 |
)
|
| 56 |
|
| 57 |
## Application Interface ##
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
if __name__ == "__main__":
|
| 65 |
gr_app.launch(mcp_server=True)
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
from typing import NamedTuple
|
| 3 |
|
| 4 |
import gradio as gr
|
| 5 |
+
import gradio.themes as gr_themes
|
| 6 |
+
import markdown
|
| 7 |
|
| 8 |
from tdagent.tools.get_domain_information import (
|
| 9 |
dns_enumeration_tool,
|
|
|
|
| 29 |
## Tools to load into the application interface ##
|
| 30 |
|
| 31 |
|
| 32 |
+
def _read_markdown_body_as_html(path: str = "README.md") -> str:
|
| 33 |
+
with Path(path).open(encoding="utf-8") as f: # Default mode is "r"
|
| 34 |
+
lines = f.readlines()
|
| 35 |
+
|
| 36 |
+
# Skip YAML front matter if present
|
| 37 |
+
if lines and lines[0].strip() == "---":
|
| 38 |
+
for i in range(1, len(lines)):
|
| 39 |
+
if lines[i].strip() == "---":
|
| 40 |
+
lines = lines[i + 1 :] # skip metadata block
|
| 41 |
+
break
|
| 42 |
+
|
| 43 |
+
markdown_body = "".join(lines).strip()
|
| 44 |
+
return markdown.markdown(markdown_body)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
class ToolInfo(NamedTuple):
|
| 48 |
"""Gradio MCP tool info."""
|
| 49 |
|
|
|
|
| 73 |
)
|
| 74 |
|
| 75 |
## Application Interface ##
|
| 76 |
+
|
| 77 |
+
custom_css = """
|
| 78 |
+
.main-header {
|
| 79 |
+
background: linear-gradient(135deg, #00a388 0%, #ffae00 100%);
|
| 80 |
+
padding: 30px;
|
| 81 |
+
border-radius: 5px;
|
| 82 |
+
margin-bottom: 20px;
|
| 83 |
+
text-align: center;
|
| 84 |
+
}
|
| 85 |
+
"""
|
| 86 |
+
with (
|
| 87 |
+
gr.Blocks(
|
| 88 |
+
theme=gr_themes.Origin(
|
| 89 |
+
primary_hue="teal",
|
| 90 |
+
spacing_size="sm",
|
| 91 |
+
font="sans-serif",
|
| 92 |
+
),
|
| 93 |
+
title="TDAgent",
|
| 94 |
+
fill_height=True,
|
| 95 |
+
fill_width=True,
|
| 96 |
+
css=custom_css,
|
| 97 |
+
) as gr_app,
|
| 98 |
+
):
|
| 99 |
+
gr.HTML(
|
| 100 |
+
"""
|
| 101 |
+
<div class="main-header">
|
| 102 |
+
<h1>👩💻 TDAgentTools & TDAgent 👨💻</h1>
|
| 103 |
+
<p style="font-size: 1.2em; margin: 10px 0 0 0;">
|
| 104 |
+
Empowering Cybersecurity with Agentic AI
|
| 105 |
+
</p>
|
| 106 |
+
</div>
|
| 107 |
+
""",
|
| 108 |
+
)
|
| 109 |
+
with gr.Tabs():
|
| 110 |
+
with gr.TabItem("About"):
|
| 111 |
+
html_content = _read_markdown_body_as_html("README.md")
|
| 112 |
+
gr.Markdown(html_content)
|
| 113 |
+
with gr.TabItem("TDAgentTools"):
|
| 114 |
+
gr.TabbedInterface(
|
| 115 |
+
interface_list=[t_info.interface for t_info in TOOLS],
|
| 116 |
+
tab_names=[t_info.name for t_info in TOOLS],
|
| 117 |
+
title="TDAgentTools",
|
| 118 |
+
)
|
| 119 |
+
with gr.TabItem("Demo"):
|
| 120 |
+
gr.Markdown(
|
| 121 |
+
"""
|
| 122 |
+
This is a demo of TDAgentTools, a simple MCP server.
|
| 123 |
+
Be carefull with using well-known urls for malware distribution
|
| 124 |
+
when using the url content extractor tool.
|
| 125 |
+
""",
|
| 126 |
+
)
|
| 127 |
+
gr.HTML(
|
| 128 |
+
"""<iframe width="560" height="315" src="https://youtube.com/embed/c7Yg_jOD6J0" frameborder="0" allowfullscreen></iframe>""", # noqa: E501
|
| 129 |
+
)
|
| 130 |
|
| 131 |
if __name__ == "__main__":
|
| 132 |
gr_app.launch(mcp_server=True)
|