Spaces:
Runtime error
Runtime error
fikird
commited on
Commit
Β·
71e076d
1
Parent(s):
15a525a
Enhance result formatting with better OSINT result handling
Browse files
app.py
CHANGED
@@ -23,7 +23,73 @@ def format_results(results):
|
|
23 |
return "\n---\n".join(formatted_results)
|
24 |
elif isinstance(results, dict):
|
25 |
# Format OSINT results
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
else:
|
28 |
return str(results)
|
29 |
|
@@ -167,7 +233,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
167 |
Try these example searches:
|
168 |
- Web Search: "Latest developments in artificial intelligence"
|
169 |
- Username: "johndoe"
|
170 |
-
- Image URL: "https://
|
171 |
- Social Media: "techuser" on Twitter
|
172 |
- Historical Data: "example.com"
|
173 |
""")
|
|
|
23 |
return "\n---\n".join(formatted_results)
|
24 |
elif isinstance(results, dict):
|
25 |
# Format OSINT results
|
26 |
+
if "error" in results:
|
27 |
+
return f"Error: {results['error']}"
|
28 |
+
|
29 |
+
formatted = []
|
30 |
+
|
31 |
+
# Web results
|
32 |
+
if "web" in results:
|
33 |
+
formatted.append(format_results(results["web"]))
|
34 |
+
|
35 |
+
# Username/Platform results
|
36 |
+
if "platforms" in results:
|
37 |
+
platforms = results["platforms"]
|
38 |
+
if platforms:
|
39 |
+
formatted.append("\n### π Platform Results\n")
|
40 |
+
for platform in platforms:
|
41 |
+
formatted.append(f"""
|
42 |
+
- **Platform:** {platform['platform']}
|
43 |
+
**URL:** [{platform['url']}]({platform['url']})
|
44 |
+
**Status:** {'Found β
' if platform.get('exists', False) else 'Not Found β'}
|
45 |
+
""")
|
46 |
+
|
47 |
+
# Image analysis
|
48 |
+
if "analysis" in results:
|
49 |
+
analysis = results["analysis"]
|
50 |
+
if analysis:
|
51 |
+
formatted.append("\n### πΌοΈ Image Analysis\n")
|
52 |
+
for key, value in analysis.items():
|
53 |
+
formatted.append(f"- **{key.title()}:** {value}")
|
54 |
+
|
55 |
+
# Similar images
|
56 |
+
if "similar_images" in results:
|
57 |
+
similar = results["similar_images"]
|
58 |
+
if similar:
|
59 |
+
formatted.append("\n### π Similar Images\n")
|
60 |
+
for img in similar:
|
61 |
+
formatted.append(f"- [{img['source']}]({img['url']})")
|
62 |
+
|
63 |
+
# Location info
|
64 |
+
if "location" in results:
|
65 |
+
location = results["location"]
|
66 |
+
if location and not isinstance(location, str):
|
67 |
+
formatted.append("\n### π Location Information\n")
|
68 |
+
for key, value in location.items():
|
69 |
+
if key != 'raw':
|
70 |
+
formatted.append(f"- **{key.title()}:** {value}")
|
71 |
+
|
72 |
+
# Domain info
|
73 |
+
if "domain" in results:
|
74 |
+
domain = results["domain"]
|
75 |
+
if domain and not isinstance(domain, str):
|
76 |
+
formatted.append("\n### π Domain Information\n")
|
77 |
+
for key, value in domain.items():
|
78 |
+
formatted.append(f"- **{key.title()}:** {value}")
|
79 |
+
|
80 |
+
# Historical data
|
81 |
+
if "historical" in results:
|
82 |
+
historical = results["historical"]
|
83 |
+
if historical:
|
84 |
+
formatted.append("\n### π
Historical Data\n")
|
85 |
+
for entry in historical[:5]: # Limit to 5 entries
|
86 |
+
formatted.append(f"""
|
87 |
+
- **Date:** {entry.get('timestamp', 'N/A')}
|
88 |
+
**URL:** [{entry.get('url', 'N/A')}]({entry.get('url', '#')})
|
89 |
+
**Type:** {entry.get('mime_type', 'N/A')}
|
90 |
+
""")
|
91 |
+
|
92 |
+
return "\n".join(formatted) if formatted else "No relevant information found."
|
93 |
else:
|
94 |
return str(results)
|
95 |
|
|
|
233 |
Try these example searches:
|
234 |
- Web Search: "Latest developments in artificial intelligence"
|
235 |
- Username: "johndoe"
|
236 |
+
- Image URL: "https://images.app.goo.gl/w5BtxZKvzg6BdkGE8"
|
237 |
- Social Media: "techuser" on Twitter
|
238 |
- Historical Data: "example.com"
|
239 |
""")
|