Spaces:
Sleeping
Sleeping
Update app.py
Browse files- Fix API issues
app.py
CHANGED
@@ -35,12 +35,21 @@ def check_flagged_address(address: str) -> str:
|
|
35 |
String indicating if the address is flagged and its blockchain.
|
36 |
"""
|
37 |
chain = infer_chain(address)
|
|
|
|
|
|
|
38 |
for entry in flagged_addresses:
|
39 |
if isinstance(entry, dict) and "address" in entry:
|
40 |
if entry["address"].lower() == address.lower():
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
# Gradio chat function
|
46 |
def chat_with_agent(user_input, chat_history, hf_token):
|
@@ -128,7 +137,7 @@ with gr.Blocks(title="Bybit Hack Address Checker") as demo:
|
|
128 |
3. **Agent Processing**: The app uses a `CodeAgent` from the `smolagents` library, powered by the free `Mixtral-8x7B-Instruct-v0.1` model via the Hugging Face Inference API.
|
129 |
4. **Tool Usage**: The agent calls a custom tool (`check_flagged_address`) to compare your input against a list of flagged addresses from the Elliptic Bybit hack dataset (`https://dt074px2e9qbh.cloudfront.net/exploit-api.json`).
|
130 |
5. **Chain Identification**: If the address isn’t explicitly tagged with a blockchain in the dataset, the app infers it (Ethereum, Bitcoin, Tron, or Unknown) based on common address formats.
|
131 |
-
6. **Result**: You’ll see whether the address is flagged
|
132 |
|
133 |
### Why It’s Useful
|
134 |
- **Security**: Quickly check if an address you’re dealing with is linked to a known exploit.
|
|
|
35 |
String indicating if the address is flagged and its blockchain.
|
36 |
"""
|
37 |
chain = infer_chain(address)
|
38 |
+
flagged = False
|
39 |
+
|
40 |
+
# Check if the address is in the API data
|
41 |
for entry in flagged_addresses:
|
42 |
if isinstance(entry, dict) and "address" in entry:
|
43 |
if entry["address"].lower() == address.lower():
|
44 |
+
flagged = True
|
45 |
+
chain = entry.get("chain", chain) # Override with API-provided chain if available
|
46 |
+
break
|
47 |
+
|
48 |
+
# Format the response with emojis and clear details
|
49 |
+
if flagged:
|
50 |
+
return f"Address {address} is Flagged ✅\nChain: {chain}\nStatus: Present in Bybit hack database"
|
51 |
+
else:
|
52 |
+
return f"Address {address} is Not Flagged ❌\nChain: {chain}\nStatus: Not present in Bybit hack database"
|
53 |
|
54 |
# Gradio chat function
|
55 |
def chat_with_agent(user_input, chat_history, hf_token):
|
|
|
137 |
3. **Agent Processing**: The app uses a `CodeAgent` from the `smolagents` library, powered by the free `Mixtral-8x7B-Instruct-v0.1` model via the Hugging Face Inference API.
|
138 |
4. **Tool Usage**: The agent calls a custom tool (`check_flagged_address`) to compare your input against a list of flagged addresses from the Elliptic Bybit hack dataset (`https://dt074px2e9qbh.cloudfront.net/exploit-api.json`).
|
139 |
5. **Chain Identification**: If the address isn’t explicitly tagged with a blockchain in the dataset, the app infers it (Ethereum, Bitcoin, Tron, or Unknown) based on common address formats.
|
140 |
+
6. **Result**: You’ll see whether the address is flagged ✅ or not ❌, its chain type, and if it’s present in the database.
|
141 |
|
142 |
### Why It’s Useful
|
143 |
- **Security**: Quickly check if an address you’re dealing with is linked to a known exploit.
|