Spaces:
Build error
Build error
acecalisto3
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,65 +1,68 @@
|
|
|
|
|
|
1 |
from transformers import pipeline
|
2 |
-
|
3 |
|
4 |
-
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
"task": "Develop a cybersecurity tool for detecting and mitigating supply-chain attacks",
|
13 |
-
"history": "",
|
14 |
-
"history_additions": [
|
15 |
-
"Set the task description to 'Develop a cybersecurity tool for detecting and mitigating supply-chain attacks'",
|
16 |
-
"Updated the task description to 'Identify common supply-chain attack techniques'",
|
17 |
-
"Completed the task: Identify common supply-chain attack techniques",
|
18 |
-
"Updated the task description to 'Design and implement detection mechanisms for supply-chain attacks'",
|
19 |
-
"Completed the task: Design and implement detection mechanisms for supply-chain attacks",
|
20 |
-
"Updated the task description to 'Integrate threat intelligence feeds to improve attack detection'",
|
21 |
-
"Completed the task: Integrate threat intelligence feeds to improve attack detection",
|
22 |
-
"Updated the task description to 'Implement mitigation techniques to minimize the impact of supply-chain attacks'",
|
23 |
-
"Completed the task: Implement mitigation techniques to minimize the impact of supply-chain attacks",
|
24 |
-
"Updated the task description to 'Conduct testing and validation to ensure tool effectiveness'",
|
25 |
-
"Completed the task: Conduct testing and validation to ensure tool effectiveness",
|
26 |
-
"Updated the task description to 'Prepare documentation to help users understand and get started with the tool'",
|
27 |
-
"Completed the task: Prepare documentation to help users understand and get started with the tool",
|
28 |
-
"Updated the task description to 'Integrate the tool with security monitoring and incident response workflows'"
|
29 |
-
],
|
30 |
-
"history_removals": [],
|
31 |
-
"model_log": [
|
32 |
-
"Model prompt: You are attempting to complete the task task: Develop a cybersecurity tool for detecting and mitigating supply-chain attacks Progress: Identify common supply-chain attack techniques",
|
33 |
-
"Model response: Identify common supply-chain attack techniques",
|
34 |
-
"Model prompt: Updated the task description to 'Design and implement detection mechanisms for supply-chain attacks'",
|
35 |
-
"Model response: Design and implement detection mechanisms for supply-chain attacks",
|
36 |
-
"Model prompt: Completed the task: Design and implement detection mechanisms for supply-chain attacks Progress: Identify common supply-chain attack techniques\nDesign and implement detection mechanisms for supply-chain attacks",
|
37 |
-
"Model response: You have successfully completed the task: Design and implement detection mechanisms for supply-chain attacks",
|
38 |
-
"Model prompt: Updated the task description to 'Integrate threat intelligence feeds to improve attack detection'",
|
39 |
-
"Model response: Integrate threat intelligence feeds to improve attack detection",
|
40 |
-
"Model prompt: Completed the task: Integrate threat intelligence feeds to improve attack detection Progress: Identify common supply-chain attack techniques\nDesign and implement detection mechanisms for supply-chain attacks\nIntegrate threat intelligence feeds to improve attack detection",
|
41 |
-
"Model response: You have successfully completed the task: Integrate threat intelligence feeds to improve attack detection",
|
42 |
-
"Model prompt: Updated the task description to 'Implement mitigation techniques to minimize the impact of supply-chain attacks'",
|
43 |
-
"Model response: Implement mitigation techniques to minimize the impact of supply-chain attacks",
|
44 |
-
"Model prompt: Completed the task: Implement mitigation techniques to minimize the impact of supply-chain attacks Progress: Identify common supply-chain attack techniques\nDesign and implement detection mechanisms for supply-chain attacks\nIntegrate threat intelligence feeds to improve attack detection\nImplement mitigation techniques to minimize the impact of supply-chain attacks",
|
45 |
-
"Model response: You have successfully completed the task: Implement mitigation techniques to minimize the impact of supply-chain attacks",
|
46 |
-
"Model prompt: Updated the task description to 'Conduct testing and validation to ensure tool effectiveness'",
|
47 |
-
"Model response: Conduct testing and validation to ensure tool effectiveness",
|
48 |
-
"Model prompt: Completed the task: Conduct testing and validation to ensure tool effectiveness",
|
49 |
-
"Model response: Conduct testing and validation to ensure tool effectiveness",
|
50 |
-
"Model prompt: Updated the task description to 'Prepare documentation to help users understand and get started with the tool'",
|
51 |
-
"Model response: Prepare documentation to help users understand and get started with the tool",
|
52 |
-
"Model prompt: Completed the task: Prepare documentation to help users understand and get started with the tool Progress: Identify common supply-chain attack techniques\nDesign and implement detection mechanisms for supply-chain attacks\nIntegrate threat intelligence feeds to improve attack detection\nImplement mitigation techniques to minimize the impact of supply-chain attacks\nConduct testing and validation to ensure tool effectiveness\nPrepare documentation to help users understand and get started with the tool",
|
53 |
-
"Model response: You have successfully completed the task: Prepare documentation to help users understand and get started with the tool",
|
54 |
-
"Model prompt: Updated the task description to 'Integrate the tool with security monitoring and incident response workflows'",
|
55 |
-
"Model response: Integrate the tool with security monitoring and incident response workflows",
|
56 |
-
"Model prompt: Completed the task: Integrate the tool with security monitoring and incident response workflows Progress: Identify common supply-chain attack techniques\nDesign and implement detection mechanisms for supply-chain attacks\nIntegrate threat intelligence feeds to improve attack detection\nImplement mitigation techniques to minimize the impact of supply-chain attacks\nConduct testing and validation to ensure tool effectiveness\nPrepare documentation to help users understand and get started with the tool\nIntegrate the tool with security monitoring and incident response workflows",
|
57 |
-
"Model response: You have successfully completed the task: Integrate the tool with security monitoring and incident response workflows",
|
58 |
-
"Model prompt: Task complete. Tool development for detecting and mitigating supply-chain attacks has been completed.",
|
59 |
-
"Model response: Task complete. Tool development for detecting and mitigating supply-chain attacks has been completed."
|
60 |
-
]
|
61 |
-
}
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import tkinter as tk
|
2 |
+
from tkinter import ttk, scrolledtext, filedialog
|
3 |
from transformers import pipeline
|
4 |
+
import logging
|
5 |
|
6 |
+
# Logging Setup
|
7 |
+
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
8 |
|
9 |
+
class CodeGeneratorApp:
|
10 |
+
def __init__(self, master):
|
11 |
+
self.master = master
|
12 |
+
master.title("Advanced Code Generator")
|
13 |
+
self.create_widgets()
|
14 |
+
self.generator = pipeline('text-generation', model='bigscience/T0_3B')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
def create_widgets(self):
|
17 |
+
# Input Frame
|
18 |
+
input_frame = ttk.LabelFrame(self.master, text="Task Description")
|
19 |
+
input_frame.pack(padx=10, pady=10)
|
20 |
+
self.input_area = scrolledtext.ScrolledText(input_frame, wrap=tk.WORD, width=80, height=10)
|
21 |
+
self.input_area.pack(padx=5, pady=5)
|
22 |
+
|
23 |
+
# Options Frame
|
24 |
+
options_frame = ttk.LabelFrame(self.master, text="Options")
|
25 |
+
options_frame.pack(padx=10, pady=5)
|
26 |
+
ttk.Label(options_frame, text="Max Length:").grid(row=0, column=0, sticky="w")
|
27 |
+
self.max_length_var = tk.IntVar(value=250)
|
28 |
+
ttk.Entry(options_frame, textvariable=self.max_length_var, width=5).grid(row=0, column=1)
|
29 |
+
self.temp_var = tk.DoubleVar(value=0.7)
|
30 |
+
ttk.Label(options_frame, text="Temperature:").grid(row=1, column=0, sticky="w")
|
31 |
+
ttk.Entry(options_frame, textvariable=self.temp_var, width=5).grid(row=1, column=1)
|
32 |
+
|
33 |
+
# Buttons
|
34 |
+
ttk.Button(self.master, text="Generate Code", command=self.generate_code).pack(pady=10)
|
35 |
+
ttk.Button(self.master, text="Save Code", command=self.save_code).pack()
|
36 |
+
|
37 |
+
# Output Frame
|
38 |
+
output_frame = ttk.LabelFrame(self.master, text="Generated Code")
|
39 |
+
output_frame.pack(padx=10, pady=10, expand=True, fill="both")
|
40 |
+
self.output_area = scrolledtext.ScrolledText(output_frame, wrap=tk.WORD, width=80)
|
41 |
+
self.output_area.pack(padx=5, pady=5, expand=True, fill="both")
|
42 |
+
|
43 |
+
def generate_code(self):
|
44 |
+
input_text = self.input_area.get("1.0", tk.END).strip()
|
45 |
+
max_length = self.max_length_var.get()
|
46 |
+
temperature = self.temp_var.get()
|
47 |
+
|
48 |
+
try:
|
49 |
+
logging.info(f"Generating code with input: {input_text}") # Log the input
|
50 |
+
prompt = f"Develop code for the following task: {input_text}"
|
51 |
+
code = self.generator(prompt, max_length=max_length, num_return_sequences=1, temperature=temperature)[0]['generated_text'].strip()
|
52 |
+
self.output_area.delete("1.0", tk.END)
|
53 |
+
self.output_area.insert(tk.END, code)
|
54 |
+
logging.info("Code generation completed successfully.") # Log successful generation
|
55 |
+
except Exception as e:
|
56 |
+
logging.error(f"Error generating code: {e}")
|
57 |
+
self.output_area.insert(tk.END, f"Error generating code: {e}")
|
58 |
+
|
59 |
+
def save_code(self):
|
60 |
+
file_path = filedialog.asksaveasfilename(defaultextension=".py")
|
61 |
+
if file_path:
|
62 |
+
with open(file_path, "w") as file:
|
63 |
+
file.write(self.output_area.get("1.0", tk.END))
|
64 |
+
logging.info(f"Code saved to {file_path}")
|
65 |
+
|
66 |
+
root = tk.Tk()
|
67 |
+
app = CodeGeneratorApp(root)
|
68 |
+
root.mainloop()
|