daqc commited on
Commit
5a945fb
·
1 Parent(s): a28b847

Update config

Browse files
app.py CHANGED
@@ -38,7 +38,7 @@ def create_agent():
38
  config = load_agent_config()
39
  prompts = load_prompts()
40
 
41
- # Configure model a
42
  model_config = config['agent_config']['model']
43
  model = HfApiModel(
44
  model_id=model_config['model_id'],
@@ -59,20 +59,13 @@ def create_agent():
59
 
60
  return agent, prompts
61
 
62
- def process_query(query, analysis_type="general"):
63
- """Process a user query"""
64
  agent, prompts = create_agent()
65
 
66
- # Select appropriate template
67
- if analysis_type == "vulnerability":
68
- template = prompts['vulnerability_analysis']
69
- formatted_prompt = template.format(cve_id=query)
70
- elif analysis_type == "threat":
71
- template = prompts['threat_report']
72
- formatted_prompt = template.format(target=query)
73
- else:
74
- template = prompts['user_prompt']
75
- formatted_prompt = template.format(query=query)
76
 
77
  # Execute agent
78
  system_prompt = prompts['system_prompt']
@@ -80,32 +73,30 @@ def process_query(query, analysis_type="general"):
80
 
81
  return result
82
 
83
- # Gradio Interface
84
  def create_interface():
85
- """Create the Gradio user interface"""
86
  with gr.Blocks(title="Vulnerability Intelligence Agent") as interface:
87
  gr.Markdown("# Vulnerability Intelligence Agent (VIA)")
88
 
89
- with gr.Row():
90
- with gr.Column():
91
- query_input = gr.Textbox(
92
- label="Query",
93
- placeholder="Enter your security query..."
94
- )
95
- analysis_type = gr.Radio(
96
- choices=["general", "vulnerability", "threat"],
97
- label="Analysis Type",
98
- value="general"
99
- )
100
- submit_btn = gr.Button("Analyze")
101
-
102
- with gr.Column():
103
- output = gr.Markdown(label="Result")
104
 
105
- submit_btn.click(
106
- fn=process_query,
107
- inputs=[query_input, analysis_type],
108
- outputs=output
109
  )
110
 
111
  return interface
 
38
  config = load_agent_config()
39
  prompts = load_prompts()
40
 
41
+ # Configure model
42
  model_config = config['agent_config']['model']
43
  model = HfApiModel(
44
  model_id=model_config['model_id'],
 
59
 
60
  return agent, prompts
61
 
62
+ def process_query(message, history):
63
+ """Process a user query in chat format"""
64
  agent, prompts = create_agent()
65
 
66
+ # Format the prompt
67
+ template = prompts['user_prompt']
68
+ formatted_prompt = template.format(query=message)
 
 
 
 
 
 
 
69
 
70
  # Execute agent
71
  system_prompt = prompts['system_prompt']
 
73
 
74
  return result
75
 
76
+ # Gradio Chat Interface
77
  def create_interface():
78
+ """Create the Gradio chat interface"""
79
  with gr.Blocks(title="Vulnerability Intelligence Agent") as interface:
80
  gr.Markdown("# Vulnerability Intelligence Agent (VIA)")
81
 
82
+ chatbot = gr.Chatbot(
83
+ [],
84
+ elem_id="chatbot",
85
+ bubble_full_width=False,
86
+ avatar_images=(None, "🤖"),
87
+ height=600,
88
+ )
89
+
90
+ txt = gr.Textbox(
91
+ show_label=False,
92
+ placeholder="Enter your security query...",
93
+ container=False
94
+ )
 
 
95
 
96
+ txt.submit(
97
+ process_query,
98
+ [txt, chatbot],
99
+ [chatbot]
100
  )
101
 
102
  return interface
tools/__pycache__/vuln_search.cpython-310.pyc CHANGED
Binary files a/tools/__pycache__/vuln_search.cpython-310.pyc and b/tools/__pycache__/vuln_search.cpython-310.pyc differ
 
tools/vuln_search.py CHANGED
@@ -14,11 +14,21 @@ class VulnerabilitySearchTool(Tool):
14
  name = "vuln_search"
15
  description = "Search for vulnerabilities in security databases (NVD, MISP if configured)"
16
  inputs = {
17
- 'query': {'type': 'str', 'description': 'Search term or CVE ID'},
18
- 'sources': {'type': 'list', 'description': 'List of sources to query (nvd, misp)', 'default': ['nvd']},
19
- 'max_results': {'type': 'int', 'description': 'Maximum number of results per source', 'default': 5}
 
 
 
 
 
 
 
 
 
 
20
  }
21
- output_type = Dict[str, Any]
22
 
23
  def __init__(self):
24
  """Initialize API connections"""
 
14
  name = "vuln_search"
15
  description = "Search for vulnerabilities in security databases (NVD, MISP if configured)"
16
  inputs = {
17
+ 'query': {'type': 'string', 'description': 'Search term or CVE ID'},
18
+ 'sources': {
19
+ 'type': 'array',
20
+ 'description': 'List of sources to query (nvd, misp)',
21
+ 'default': ['nvd'],
22
+ 'nullable': True
23
+ },
24
+ 'max_results': {
25
+ 'type': 'integer',
26
+ 'description': 'Maximum number of results per source',
27
+ 'default': 5,
28
+ 'nullable': True
29
+ }
30
  }
31
+ output_type = "object"
32
 
33
  def __init__(self):
34
  """Initialize API connections"""