Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -37,7 +37,7 @@ def check_flagged_address(address: str) -> str:
|
|
37 |
# Define the tool for the agent
|
38 |
flagged_address_tool = Tool(
|
39 |
name="check_flagged_address",
|
40 |
-
description="Checks if a cryptocurrency address is flagged in the Bybit hack database.",
|
41 |
fn=check_flagged_address
|
42 |
)
|
43 |
|
@@ -48,13 +48,14 @@ def chat_with_agent(user_input, chat_history, hf_token):
|
|
48 |
|
49 |
# Check if token is provided
|
50 |
if not hf_token or hf_token.strip() == "":
|
51 |
-
|
|
|
|
|
52 |
|
53 |
# Initialize the CodeAgent with the user-provided HF token
|
54 |
agent = CodeAgent(
|
55 |
model=HfApiModel(model_id="mistralai/Mixtral-8x7B-Instruct-v0.1", token=hf_token),
|
56 |
-
tools=[flagged_address_tool]
|
57 |
-
system_prompt="You are an agent that checks if cryptocurrency addresses are flagged as part of the Bybit hack. Given an address, use the check_flagged_address tool to verify its status and report the result, including the blockchain it's on."
|
58 |
)
|
59 |
|
60 |
# Run the agent with the user's input
|
@@ -63,8 +64,9 @@ def chat_with_agent(user_input, chat_history, hf_token):
|
|
63 |
except Exception as e:
|
64 |
response = f"Error: {str(e)}. Check your HF token or try again."
|
65 |
|
66 |
-
# Append as
|
67 |
-
chat_history.append(
|
|
|
68 |
|
69 |
# Return updated history and clear the input box
|
70 |
return chat_history, ""
|
@@ -87,8 +89,8 @@ with gr.Blocks(title="Bybit Hack Address Checker") as demo:
|
|
87 |
lines=1
|
88 |
)
|
89 |
|
90 |
-
# Chatbot component
|
91 |
-
chatbot = gr.Chatbot(label="Conversation")
|
92 |
|
93 |
# Address input
|
94 |
msg = gr.Textbox(
|
|
|
37 |
# Define the tool for the agent
|
38 |
flagged_address_tool = Tool(
|
39 |
name="check_flagged_address",
|
40 |
+
description="Checks if a cryptocurrency address is flagged in the Bybit hack database and identifies its blockchain.",
|
41 |
fn=check_flagged_address
|
42 |
)
|
43 |
|
|
|
48 |
|
49 |
# Check if token is provided
|
50 |
if not hf_token or hf_token.strip() == "":
|
51 |
+
chat_history.append({"role": "user", "content": user_input})
|
52 |
+
chat_history.append({"role": "assistant", "content": "Please enter a valid Hugging Face API token."})
|
53 |
+
return chat_history, ""
|
54 |
|
55 |
# Initialize the CodeAgent with the user-provided HF token
|
56 |
agent = CodeAgent(
|
57 |
model=HfApiModel(model_id="mistralai/Mixtral-8x7B-Instruct-v0.1", token=hf_token),
|
58 |
+
tools=[flagged_address_tool]
|
|
|
59 |
)
|
60 |
|
61 |
# Run the agent with the user's input
|
|
|
64 |
except Exception as e:
|
65 |
response = f"Error: {str(e)}. Check your HF token or try again."
|
66 |
|
67 |
+
# Append as OpenAI-style messages
|
68 |
+
chat_history.append({"role": "user", "content": user_input})
|
69 |
+
chat_history.append({"role": "assistant", "content": response})
|
70 |
|
71 |
# Return updated history and clear the input box
|
72 |
return chat_history, ""
|
|
|
89 |
lines=1
|
90 |
)
|
91 |
|
92 |
+
# Chatbot component with messages format
|
93 |
+
chatbot = gr.Chatbot(label="Conversation", type="messages")
|
94 |
|
95 |
# Address input
|
96 |
msg = gr.Textbox(
|