Diego Carpintero commited on
Commit
f868efb
1 Parent(s): 7210215

add sample labels

Browse files
Files changed (1) hide show
  1. app.py +31 -15
app.py CHANGED
@@ -7,16 +7,32 @@ from formatter import AutoGenFormatter
7
 
8
  title = "Minerva: AI Guardian for Scam Protection"
9
  description = """
10
- Built with AutoGen 0.4.0 and OpenAI. </br>
11
- Analysis might take up to 30s. </br>
12
- https://github.com/dcarpintero/minerva
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  """
14
  inputs = gr.components.Image()
15
  outputs = [
16
  gr.components.Textbox(label="Analysis Result"),
17
  gr.HTML(label="Agentic Workflow (Streaming)")
18
  ]
19
- examples = "samples"
 
20
 
21
  model = Minerva()
22
  formatter = AutoGenFormatter()
@@ -30,16 +46,14 @@ def to_html(texts):
30
  async def predict(img):
31
  try:
32
  img = Image.fromarray(img)
33
-
34
  stream = await model.analyze(img)
35
 
36
  streams = []
37
  messages = []
38
  async for s in stream:
39
- msg = await formatter.to_output(s)
40
  streams.append(s)
41
- messages.append(msg)
42
- yield ["", to_html(messages)]
43
 
44
  if streams[-1]:
45
  prediction = streams[-1].messages[-1].content
@@ -56,12 +70,14 @@ async def predict(img):
56
 
57
  with gr.Blocks() as demo:
58
  with gr.Tab("Minerva: AI Guardian for Scam Protection"):
59
- gr.Interface(
60
- fn=predict,
61
- inputs=inputs,
62
- outputs=outputs,
63
- examples=examples,
64
- description=description,
65
- ).queue(default_concurrency_limit=5)
 
 
66
 
67
  demo.launch()
 
7
 
8
  title = "Minerva: AI Guardian for Scam Protection"
9
  description = """
10
+ Built with AutoGen 0.4.0 and OpenAI. </br></br>
11
+
12
+ Minerva analyzes the content of a screenshot for potential scams </br>
13
+ and provides an analysis in the language of the extracted text</br></br>
14
+
15
+ Agents coordinated as an AutoGen Team in a RoundRobin fashion: </br>
16
+ - *OCR Specialist* </br>
17
+ - *Link Checker* </br>
18
+ - *Content Analyst* </br>
19
+ - *Decision Maker* </br>
20
+ - *Summary Specialist* </br>
21
+ - *Language Translation Specialist* </br></br>
22
+
23
+ Try out one of the examples to perform a scam analysis. </br>
24
+ Agentic Workflow is streamed for demonstration purposes. </br></br>
25
+
26
+ https://github.com/dcarpintero/minerva </br>
27
+ Submission for RBI Berkeley, CS294/194-196, LLM Agents (Diego Carpintero)
28
  """
29
  inputs = gr.components.Image()
30
  outputs = [
31
  gr.components.Textbox(label="Analysis Result"),
32
  gr.HTML(label="Agentic Workflow (Streaming)")
33
  ]
34
+ examples = "examples"
35
+ example_labels = ["EN:Gift:Social", "ES:Banking:Social", "EN:Billing:SMS", "EN:Multifactor:Email", "EN:CustomerService:Twitter"]
36
 
37
  model = Minerva()
38
  formatter = AutoGenFormatter()
 
46
  async def predict(img):
47
  try:
48
  img = Image.fromarray(img)
 
49
  stream = await model.analyze(img)
50
 
51
  streams = []
52
  messages = []
53
  async for s in stream:
 
54
  streams.append(s)
55
+ messages.append(await formatter.to_output(s))
56
+ yield ["Pondering, stand by...", to_html(messages)]
57
 
58
  if streams[-1]:
59
  prediction = streams[-1].messages[-1].content
 
70
 
71
  with gr.Blocks() as demo:
72
  with gr.Tab("Minerva: AI Guardian for Scam Protection"):
73
+ with gr.Row():
74
+ gr.Interface(
75
+ fn=predict,
76
+ inputs=inputs,
77
+ outputs=outputs,
78
+ examples=examples,
79
+ example_labels=example_labels,
80
+ description=description,
81
+ ).queue(default_concurrency_limit=5)
82
 
83
  demo.launch()