Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import os
|
| 2 |
import spaces
|
| 3 |
-
import firecrawler
|
| 4 |
import rag
|
| 5 |
import img_process
|
| 6 |
from huggingface_hub import login
|
|
@@ -12,15 +12,19 @@ login(token = os.getenv('hf_login'))
|
|
| 12 |
claude = os.getenv('claude')
|
| 13 |
|
| 14 |
#Fetch tools
|
| 15 |
-
execute_firecrawl = firecrawler.FireCrawlTool()
|
| 16 |
-
retriever_tool = rag.retriever_tool
|
| 17 |
image_tool = img_process.ImageProcessor()
|
| 18 |
|
| 19 |
|
| 20 |
agent = CodeAgent(
|
| 21 |
-
tools=[
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
#model = LiteLLMModel(model_id="anthropic/claude-3-5-sonnet-latest", api_key=claude),
|
| 23 |
-
model=HfApiModel(),
|
| 24 |
max_steps=10
|
| 25 |
)
|
| 26 |
|
|
@@ -30,9 +34,9 @@ def get_answer(url, text, image):
|
|
| 30 |
A function that takes any question as input and returns the answer using agent.run()
|
| 31 |
|
| 32 |
Args:
|
| 33 |
-
|
| 34 |
text (str): Additional context about the situation
|
| 35 |
-
|
| 36 |
|
| 37 |
Returns:
|
| 38 |
str: Detailed analysis report
|
|
@@ -47,48 +51,21 @@ ANALYSIS FRAMEWORK:
|
|
| 47 |
1. RISK LEVEL
|
| 48 |
- Explicitly state an overall risk assessment (Low/Medium/High)
|
| 49 |
|
| 50 |
-
2. URL ANALYSIS (if there is a URL provided)
|
| 51 |
-
- Detailed breakdown of URL characteristics
|
| 52 |
-
- Domain reputation assessment
|
| 53 |
-
- Technical red flags
|
| 54 |
-
- Registrar and hosting information insights
|
| 55 |
|
| 56 |
-
|
| 57 |
- Image contents assessment, use ImageProcessor tool to obtain image OCR and label.
|
| 58 |
- Identify any red flags that could be related to scams
|
| 59 |
|
| 60 |
-
3.
|
| 61 |
-
- Content quality assessment (use execute_firecrawl to retrieve contents sample)
|
| 62 |
-
- Linguistic and communication pattern analysis
|
| 63 |
-
- Consistency and professionalism evaluation
|
| 64 |
-
|
| 65 |
-
4. SPECIFIC RED FLAGS
|
| 66 |
- List at least 5 concrete indicators of potential scam
|
| 67 |
- Use Scamwatch reference material (use retriever_tool)
|
| 68 |
- Provide specific evidence for each red flag
|
| 69 |
- Categorize red flags (e.g., Technical, Financial, Communication)
|
| 70 |
|
| 71 |
-
5. RECOMMENDED ACTIONS
|
| 72 |
-
- Specific, actionable steps for user protection
|
| 73 |
-
- Use Scamwatch reference material (use retriever_tool)
|
| 74 |
-
- Recommended verification methods
|
| 75 |
-
- Suggested reporting channels
|
| 76 |
-
- Personal safety guidelines
|
| 77 |
-
|
| 78 |
-
6. ADDITIONAL INSIGHTS
|
| 79 |
-
- Contextual background information
|
| 80 |
-
- Potential motivations behind suspicious activity
|
| 81 |
-
- Broader pattern recognition
|
| 82 |
-
|
| 83 |
-
CONTEXT:
|
| 84 |
-
- URL under investigation: {url}
|
| 85 |
-
- User-provided situation description: {text}
|
| 86 |
-
|
| 87 |
CRITICAL INSTRUCTIONS:
|
| 88 |
- Maintain objective, evidence-based analysis
|
| 89 |
- Talk in terms of risks rather then certainties.
|
| 90 |
- Focus on user empowerment and protection
|
| 91 |
-
- Use the retriever_tool tool to look up Scamwatch reference information scam types, reporting scams etc. Where possible prioritise this infomration.
|
| 92 |
|
| 93 |
'''
|
| 94 |
|
|
@@ -115,7 +92,7 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
|
| 115 |
with gr.Column(scale=1, min_width=300):
|
| 116 |
input_text = gr.Textbox(label="Description", info="Please describe your concerns regarding the situation", lines=3, value="Is this website a reliable source of investment information?")
|
| 117 |
input_image = gr.Image(label="Upload a suspicious screenshot (email, text message, advertisement etc)", type="pil")
|
| 118 |
-
input_url = gr.Textbox(label="URLs", info="Please enter a suspicious URL", lines=3, value="https://fliojinews.xyz/9tKwgmC7")
|
| 119 |
btn = gr.Button("Process submission")
|
| 120 |
|
| 121 |
with gr.Column(scale=2, min_width=300):
|
|
@@ -123,7 +100,7 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
|
| 123 |
|
| 124 |
btn.click(
|
| 125 |
fn=get_answer,
|
| 126 |
-
inputs=[
|
| 127 |
outputs=[t3]
|
| 128 |
)
|
| 129 |
|
|
|
|
| 1 |
import os
|
| 2 |
import spaces
|
| 3 |
+
#import firecrawler
|
| 4 |
import rag
|
| 5 |
import img_process
|
| 6 |
from huggingface_hub import login
|
|
|
|
| 12 |
claude = os.getenv('claude')
|
| 13 |
|
| 14 |
#Fetch tools
|
| 15 |
+
#execute_firecrawl = firecrawler.FireCrawlTool()
|
| 16 |
+
#retriever_tool = rag.retriever_tool
|
| 17 |
image_tool = img_process.ImageProcessor()
|
| 18 |
|
| 19 |
|
| 20 |
agent = CodeAgent(
|
| 21 |
+
tools=[
|
| 22 |
+
image_tool,
|
| 23 |
+
#execute_firecrawl,
|
| 24 |
+
#retriever_tool
|
| 25 |
+
],
|
| 26 |
#model = LiteLLMModel(model_id="anthropic/claude-3-5-sonnet-latest", api_key=claude),
|
| 27 |
+
model= HfApiModel(),
|
| 28 |
max_steps=10
|
| 29 |
)
|
| 30 |
|
|
|
|
| 34 |
A function that takes any question as input and returns the answer using agent.run()
|
| 35 |
|
| 36 |
Args:
|
| 37 |
+
image (PIL): An image to investigate
|
| 38 |
text (str): Additional context about the situation
|
| 39 |
+
|
| 40 |
|
| 41 |
Returns:
|
| 42 |
str: Detailed analysis report
|
|
|
|
| 51 |
1. RISK LEVEL
|
| 52 |
- Explicitly state an overall risk assessment (Low/Medium/High)
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
+
2. IMAGE ANALYSIS (if there is an image provided)
|
| 56 |
- Image contents assessment, use ImageProcessor tool to obtain image OCR and label.
|
| 57 |
- Identify any red flags that could be related to scams
|
| 58 |
|
| 59 |
+
3. SPECIFIC RED FLAGS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
- List at least 5 concrete indicators of potential scam
|
| 61 |
- Use Scamwatch reference material (use retriever_tool)
|
| 62 |
- Provide specific evidence for each red flag
|
| 63 |
- Categorize red flags (e.g., Technical, Financial, Communication)
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
CRITICAL INSTRUCTIONS:
|
| 66 |
- Maintain objective, evidence-based analysis
|
| 67 |
- Talk in terms of risks rather then certainties.
|
| 68 |
- Focus on user empowerment and protection
|
|
|
|
| 69 |
|
| 70 |
'''
|
| 71 |
|
|
|
|
| 92 |
with gr.Column(scale=1, min_width=300):
|
| 93 |
input_text = gr.Textbox(label="Description", info="Please describe your concerns regarding the situation", lines=3, value="Is this website a reliable source of investment information?")
|
| 94 |
input_image = gr.Image(label="Upload a suspicious screenshot (email, text message, advertisement etc)", type="pil")
|
| 95 |
+
#input_url = gr.Textbox(label="URLs", info="Please enter a suspicious URL", lines=3, value="https://fliojinews.xyz/9tKwgmC7")
|
| 96 |
btn = gr.Button("Process submission")
|
| 97 |
|
| 98 |
with gr.Column(scale=2, min_width=300):
|
|
|
|
| 100 |
|
| 101 |
btn.click(
|
| 102 |
fn=get_answer,
|
| 103 |
+
inputs=[input_image, input_text],
|
| 104 |
outputs=[t3]
|
| 105 |
)
|
| 106 |
|