Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,34 +1,65 @@
|
|
1 |
-
|
2 |
-
from
|
3 |
-
from git_monitor import GitMonitor
|
4 |
-
from huggingface_models import HuggingFaceModels
|
5 |
|
6 |
-
|
7 |
-
github_monitor = GitMonitor()
|
8 |
-
huggingface_models = HuggingFaceModels()
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
# Repository monitoring
|
18 |
-
if st.button('Monitor'):
|
19 |
-
if selected_repo == 'enricoros/big-agi':
|
20 |
-
issues = github_monitor.get_issues(selected_repo)
|
21 |
-
for issue in issues:
|
22 |
-
st.write(f"Issue {issue.number}: {issue.title}")
|
23 |
-
st.write(issue.body)
|
24 |
-
# Replicate and resolve issues
|
25 |
-
if st.button('Replicate & Resolve'):
|
26 |
-
github_monitor.clone_repo(selected_repo)
|
27 |
-
github_monitor.replicate_issue(issue)
|
28 |
-
code_changes = huggingface_models.resolve_issue(issue)
|
29 |
-
github_monitor.apply_code_changes(code_changes)
|
30 |
-
github_monitor.push_changes()
|
31 |
-
github_monitor.create_pull_request(selected_repo)
|
32 |
-
st.write('Issue resolved and pull request created!')
|
33 |
-
elif selected_repo == 'Ig0tU/miagiii':
|
34 |
-
st.write('Monitoring the Ig0tU/miagiii repository. No issues to display.')
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
from huggingface_hub import hf_hub_url, cached_download, HfApi
|
|
|
|
|
3 |
|
4 |
+
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
|
|
|
|
5 |
|
6 |
+
def generate_code_from_model(input_text):
|
7 |
+
"""Generates code using the bigscience/T0_3B model."""
|
8 |
+
model_name = 'bigscience/T0_3B' # Choose your model
|
9 |
+
generator = pipeline('text-generation', model=model_name)
|
10 |
+
model_type = {
|
11 |
+
"model_type": "compositional",
|
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 |
+
code = generator(input_text, max_length=250, num_return_sequences=1, do_sample=True)[0]['generated_text']
|
64 |
+
code = code.strip()
|
65 |
+
return code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|