Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,36 @@ import os
|
|
| 2 |
import spaces
|
| 3 |
from huggingface_hub import login
|
| 4 |
import gradio as gr
|
| 5 |
-
from smolagents import HfApiModel, CodeAgent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
|
|
@@ -21,7 +50,7 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
|
| 21 |
|
| 22 |
with gr.Row():
|
| 23 |
with gr.Column(scale=1, min_width=300):
|
| 24 |
-
input_image =
|
| 25 |
input_text = gr.Textbox(label="Description", info="Please describe your concerns regarditng the situation",lines=3,value="On Monday the 5th of April...")
|
| 26 |
input_url = gr.Textbox(label="URLs", info="Please enter any suspicious URLs assosiated with the situation",lines=3,value="www.biz.xyz, www.freemasons.io, ...")
|
| 27 |
btn = gr.Button("Process submission")
|
|
@@ -29,13 +58,11 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
|
| 29 |
|
| 30 |
|
| 31 |
with gr.Column(scale=2, min_width=300):
|
| 32 |
-
#t1 = gr.Textbox(label='OCR text')
|
| 33 |
-
#t2 = gr.Textbox(label='Description')
|
| 34 |
t3 = gr.Textbox(label="Advice")
|
| 35 |
|
| 36 |
# Output button
|
| 37 |
btn.click(
|
| 38 |
-
fn=
|
| 39 |
inputs=[input_image, input_text, input_url],
|
| 40 |
outputs=[t3]
|
| 41 |
)
|
|
|
|
| 2 |
import spaces
|
| 3 |
from huggingface_hub import login
|
| 4 |
import gradio as gr
|
| 5 |
+
from smolagents import HfApiModel, CodeAgent
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
# Login to Hugging Face for access to LLama
|
| 10 |
+
login(token = os.getenv('hf_login'))
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
execute_firecrawl = firecrawler.execute_firecrawl
|
| 15 |
+
agent = CodeAgent(
|
| 16 |
+
tools=[execute_firecrawl], model=HfApiModel("meta-llama/Llama-3.3-70B-Instruct"), max_steps=4
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def get_answer(question):
|
| 21 |
+
"""
|
| 22 |
+
A function that takes any question as input and returns the answer using agent.run()
|
| 23 |
+
|
| 24 |
+
Args:
|
| 25 |
+
question (str): The question to be answered
|
| 26 |
+
|
| 27 |
+
Returns:
|
| 28 |
+
str: The answer to the question
|
| 29 |
+
"""
|
| 30 |
+
answer = agent.run(question)
|
| 31 |
+
answer = answer
|
| 32 |
+
print("Final output:")
|
| 33 |
+
print(answer)
|
| 34 |
+
return answer
|
| 35 |
|
| 36 |
|
| 37 |
|
|
|
|
| 50 |
|
| 51 |
with gr.Row():
|
| 52 |
with gr.Column(scale=1, min_width=300):
|
| 53 |
+
input_image = gr.Image(label="Upload a suspicious screenshot (email, text message, advertisement etc)", type="pil")
|
| 54 |
input_text = gr.Textbox(label="Description", info="Please describe your concerns regarditng the situation",lines=3,value="On Monday the 5th of April...")
|
| 55 |
input_url = gr.Textbox(label="URLs", info="Please enter any suspicious URLs assosiated with the situation",lines=3,value="www.biz.xyz, www.freemasons.io, ...")
|
| 56 |
btn = gr.Button("Process submission")
|
|
|
|
| 58 |
|
| 59 |
|
| 60 |
with gr.Column(scale=2, min_width=300):
|
|
|
|
|
|
|
| 61 |
t3 = gr.Textbox(label="Advice")
|
| 62 |
|
| 63 |
# Output button
|
| 64 |
btn.click(
|
| 65 |
+
fn=get_answer,
|
| 66 |
inputs=[input_image, input_text, input_url],
|
| 67 |
outputs=[t3]
|
| 68 |
)
|