Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- app.py +5 -20
- clear_outputs.sh +20 -0
- investigators/src/investigators/crew.py +21 -2
app.py
CHANGED
|
@@ -1,37 +1,22 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from investigators.src.investigators.crew import Investigators
|
| 3 |
|
| 4 |
-
def investigate(target_name, affiliations):
|
| 5 |
inputs = {
|
| 6 |
'target': target_name,
|
| 7 |
'affiliations': affiliations,
|
| 8 |
# 'current_year': str(datetime.now().year)
|
| 9 |
}
|
| 10 |
-
|
| 11 |
try:
|
| 12 |
-
|
|
|
|
| 13 |
except Exception as e:
|
| 14 |
raise Exception(f"An error occurred while running the crew: {e}")
|
| 15 |
|
| 16 |
return crew_output.raw
|
| 17 |
|
| 18 |
-
# view = gr.Interface(
|
| 19 |
-
# fn=investigate,
|
| 20 |
-
# inputs=[
|
| 21 |
-
# gr.Textbox(label="Target name:"),
|
| 22 |
-
# gr.Textbox(label="Target Affiliations (comma separated):")],
|
| 23 |
-
# outputs=[gr.Markdown(label="Risk Assessment Report:")],
|
| 24 |
-
# flagging_mode="never",
|
| 25 |
-
# examples=[
|
| 26 |
-
# ["Raz Nissim", "Ben Gurion University, General Motors"],
|
| 27 |
-
# ],
|
| 28 |
-
# title="OSINT Investigator",
|
| 29 |
-
# description="Enter the name of your target and their affiliations (to make search easier), and get a AML Risk assessment based on their public information.",
|
| 30 |
-
# layout="vertical")
|
| 31 |
-
#
|
| 32 |
-
# view.launch(inbrowser=True)
|
| 33 |
|
| 34 |
-
# Clear button functionality
|
| 35 |
def clear_inputs():
|
| 36 |
return "", ""
|
| 37 |
|
|
@@ -50,7 +35,7 @@ with gr.Blocks() as view:
|
|
| 50 |
|
| 51 |
|
| 52 |
with gr.Row():
|
| 53 |
-
output = gr.Markdown(label="Risk Assessment Report:", container=True, show_copy_button=True)
|
| 54 |
|
| 55 |
submit_btn.click(
|
| 56 |
fn=investigate,
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from investigators.src.investigators.crew import Investigators
|
| 3 |
|
| 4 |
+
def investigate(target_name, affiliations, progress=gr.Progress()):
|
| 5 |
inputs = {
|
| 6 |
'target': target_name,
|
| 7 |
'affiliations': affiliations,
|
| 8 |
# 'current_year': str(datetime.now().year)
|
| 9 |
}
|
| 10 |
+
progress(0.1, desc=f"Created AI Crew and launched investigation of {target_name}..")
|
| 11 |
try:
|
| 12 |
+
investigators = Investigators(progress)
|
| 13 |
+
crew_output = investigators.crew().kickoff(inputs=inputs)
|
| 14 |
except Exception as e:
|
| 15 |
raise Exception(f"An error occurred while running the crew: {e}")
|
| 16 |
|
| 17 |
return crew_output.raw
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
|
|
|
| 20 |
def clear_inputs():
|
| 21 |
return "", ""
|
| 22 |
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
with gr.Row():
|
| 38 |
+
output = gr.Markdown(label="Risk Assessment Report:", container=True, show_copy_button=True, min_height=50)
|
| 39 |
|
| 40 |
submit_btn.click(
|
| 41 |
fn=investigate,
|
clear_outputs.sh
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
if [ -d "output" ]; then
|
| 5 |
+
rm -rf output
|
| 6 |
+
echo "Cleaned main output directory"
|
| 7 |
+
else
|
| 8 |
+
echo "Main output directory does not exist"
|
| 9 |
+
fi
|
| 10 |
+
|
| 11 |
+
# Clear investigators output directory
|
| 12 |
+
if [ -d "investigators/output" ]; then
|
| 13 |
+
rm -rf investigators/output
|
| 14 |
+
echo "Cleaned investigators output directory"
|
| 15 |
+
else
|
| 16 |
+
echo "Investigators output directory does not exist"
|
| 17 |
+
fi
|
| 18 |
+
|
| 19 |
+
rm -rf search_results_*
|
| 20 |
+
echo "Output directories and search logs are cleaned"
|
investigators/src/investigators/crew.py
CHANGED
|
@@ -10,6 +10,8 @@ from crewai.memory import LongTermMemory, EntityMemory
|
|
| 10 |
from crewai.memory.storage.rag_storage import RAGStorage
|
| 11 |
from crewai.memory.storage.ltm_sqlite_storage import LTMSQLiteStorage
|
| 12 |
|
|
|
|
|
|
|
| 13 |
NO_INFORMATION_FOUND="no information found"
|
| 14 |
|
| 15 |
def validate_researcher_content(result: TaskOutput) -> Tuple[bool, Any]:
|
|
@@ -35,6 +37,8 @@ def validate_researcher_content(result: TaskOutput) -> Tuple[bool, Any]:
|
|
| 35 |
@CrewBase
|
| 36 |
class Investigators():
|
| 37 |
"""Investigators crew"""
|
|
|
|
|
|
|
| 38 |
|
| 39 |
#Agents
|
| 40 |
agents_config = 'config/agents.yaml'
|
|
@@ -66,27 +70,42 @@ class Investigators():
|
|
| 66 |
# Tasks
|
| 67 |
tasks_config = 'config/tasks.yaml'
|
| 68 |
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
@task
|
| 72 |
def research_target(self) -> Task:
|
| 73 |
|
| 74 |
-
|
| 75 |
return Task(
|
| 76 |
config=self.tasks_config['research_target'],
|
| 77 |
guardrail=validate_researcher_content,
|
|
|
|
| 78 |
)
|
| 79 |
|
| 80 |
@task
|
| 81 |
def analyze_target(self) -> Task:
|
| 82 |
return Task(
|
| 83 |
config=self.tasks_config['analyze_target'],
|
|
|
|
| 84 |
)
|
| 85 |
|
| 86 |
@task
|
| 87 |
def reporting_task(self) -> Task:
|
| 88 |
return Task(
|
| 89 |
config=self.tasks_config['reporting_task'],
|
|
|
|
| 90 |
)
|
| 91 |
|
| 92 |
@crew
|
|
|
|
| 10 |
from crewai.memory.storage.rag_storage import RAGStorage
|
| 11 |
from crewai.memory.storage.ltm_sqlite_storage import LTMSQLiteStorage
|
| 12 |
|
| 13 |
+
import gradio as gr
|
| 14 |
+
|
| 15 |
NO_INFORMATION_FOUND="no information found"
|
| 16 |
|
| 17 |
def validate_researcher_content(result: TaskOutput) -> Tuple[bool, Any]:
|
|
|
|
| 37 |
@CrewBase
|
| 38 |
class Investigators():
|
| 39 |
"""Investigators crew"""
|
| 40 |
+
def __init__(self, progress: gr.Progress):
|
| 41 |
+
self.progress = progress
|
| 42 |
|
| 43 |
#Agents
|
| 44 |
agents_config = 'config/agents.yaml'
|
|
|
|
| 70 |
# Tasks
|
| 71 |
tasks_config = 'config/tasks.yaml'
|
| 72 |
|
| 73 |
+
def callback_function(self, output: TaskOutput):
|
| 74 |
+
# print(f"""
|
| 75 |
+
# Task completed!
|
| 76 |
+
# Name: {output.name}
|
| 77 |
+
# Agent: {output.agent}
|
| 78 |
+
# Output: {output.raw}
|
| 79 |
+
# """)
|
| 80 |
+
if output.name == "research_target":
|
| 81 |
+
self.progress(0.4, "Finished gathering information, performing money laundering analysis..")
|
| 82 |
+
if output.name == "analyze_target":
|
| 83 |
+
self.progress(0.7, "Finished ML analysis, writing summary report..")
|
| 84 |
+
if output.name == "reporting_task":
|
| 85 |
+
self.progress(0.99, desc="Report completed")
|
| 86 |
|
| 87 |
@task
|
| 88 |
def research_target(self) -> Task:
|
| 89 |
|
| 90 |
+
|
| 91 |
return Task(
|
| 92 |
config=self.tasks_config['research_target'],
|
| 93 |
guardrail=validate_researcher_content,
|
| 94 |
+
callback=self.callback_function
|
| 95 |
)
|
| 96 |
|
| 97 |
@task
|
| 98 |
def analyze_target(self) -> Task:
|
| 99 |
return Task(
|
| 100 |
config=self.tasks_config['analyze_target'],
|
| 101 |
+
callback=self.callback_function
|
| 102 |
)
|
| 103 |
|
| 104 |
@task
|
| 105 |
def reporting_task(self) -> Task:
|
| 106 |
return Task(
|
| 107 |
config=self.tasks_config['reporting_task'],
|
| 108 |
+
callback=self.callback_function
|
| 109 |
)
|
| 110 |
|
| 111 |
@crew
|