Update app.py
Browse files
app.py
CHANGED
|
@@ -1224,10 +1224,10 @@ Provide patched code and explain what changed.
|
|
| 1224 |
|
| 1225 |
async def centaur_chat_agent(user_msg, chat_history, target_id, state,
|
| 1226 |
current_ep, current_pl, current_code, http_method, api_key):
|
|
|
|
|
|
|
| 1227 |
if not api_key or not target_id:
|
| 1228 |
-
chat_history
|
| 1229 |
-
chat_history.append({"role": "user", "content": user_msg})
|
| 1230 |
-
chat_history.append({"role": "assistant", "content": "π΄ Missing API Key or Target Selection."})
|
| 1231 |
return chat_history, current_ep, current_pl, current_code, http_method, state
|
| 1232 |
|
| 1233 |
llm = genai.Client(api_key=api_key)
|
|
@@ -1285,9 +1285,7 @@ INSTRUCTIONS:
|
|
| 1285 |
data = CentaurChatResponse.model_validate_json(resp.text)
|
| 1286 |
|
| 1287 |
formatted_reply = f"**{data.chat_reply}**\n\nπ Technical Analysis:\n{data.technical_analysis}"
|
| 1288 |
-
chat_history
|
| 1289 |
-
chat_history.append({"role": "user", "content": user_msg})
|
| 1290 |
-
chat_history.append({"role": "assistant", "content": formatted_reply})
|
| 1291 |
|
| 1292 |
state["arsenal"][target_id].append({
|
| 1293 |
"Timestamp": datetime.now().strftime("%H:%M:%S"),
|
|
@@ -1302,9 +1300,7 @@ INSTRUCTIONS:
|
|
| 1302 |
data.suggested_code, data.http_method, state)
|
| 1303 |
except Exception as e:
|
| 1304 |
exploit_logger.log("ERROR", f"Chat agent failed: {e}")
|
| 1305 |
-
chat_history
|
| 1306 |
-
chat_history.append({"role": "user", "content": user_msg})
|
| 1307 |
-
chat_history.append({"role": "assistant", "content": f"β οΈ Agent Error: {str(e)}"})
|
| 1308 |
return chat_history, current_ep, current_pl, current_code, http_method, state
|
| 1309 |
|
| 1310 |
# ==============================================================================
|
|
@@ -1627,11 +1623,13 @@ async def patch_code_with_ai(current_code, user_request, tid, state, api_key):
|
|
| 1627 |
# GRADIO UI β all gr.Markdown() scale= calls removed (not supported)
|
| 1628 |
# ==============================================================================
|
| 1629 |
|
| 1630 |
-
|
| 1631 |
.primary-btn { background: linear-gradient(45deg,#ff0080,#ff8c00) !important; }
|
| 1632 |
.exploit-table { font-family: 'Courier New', monospace; font-size: 0.9em; }
|
| 1633 |
.code-editor { font-family: 'Courier New', monospace; font-size: 0.95em; }
|
| 1634 |
-
"""
|
|
|
|
|
|
|
| 1635 |
|
| 1636 |
engine_state = gr.State({"profiles": {}, "arsenal": defaultdict(list)})
|
| 1637 |
|
|
@@ -1734,7 +1732,7 @@ with gr.Blocks(theme=gr.themes.Monochrome(), css="""
|
|
| 1734 |
gr.Markdown("### π€ AI Agent β CENTAUR")
|
| 1735 |
chatbot = gr.Chatbot(
|
| 1736 |
height=400, label="Conversational Interface",
|
| 1737 |
-
show_label=False,
|
| 1738 |
avatar_images=(None, "https://em-content.zobj.net/source/twitter/376/robot_1f916.png")
|
| 1739 |
)
|
| 1740 |
chat_in = gr.Textbox(
|
|
@@ -1840,4 +1838,5 @@ Deploy AI agents to: analyse vulnerabilities β generate strategies β craft p
|
|
| 1840 |
)
|
| 1841 |
|
| 1842 |
|
| 1843 |
-
demo.launch(share=False, server_name="0.0.0.0", server_port=7860
|
|
|
|
|
|
| 1224 |
|
| 1225 |
async def centaur_chat_agent(user_msg, chat_history, target_id, state,
|
| 1226 |
current_ep, current_pl, current_code, http_method, api_key):
|
| 1227 |
+
# Gradio 6: Chatbot history is [[user, bot], ...] tuples
|
| 1228 |
+
chat_history = chat_history or []
|
| 1229 |
if not api_key or not target_id:
|
| 1230 |
+
chat_history.append([user_msg, "π΄ Missing API Key or Target Selection."])
|
|
|
|
|
|
|
| 1231 |
return chat_history, current_ep, current_pl, current_code, http_method, state
|
| 1232 |
|
| 1233 |
llm = genai.Client(api_key=api_key)
|
|
|
|
| 1285 |
data = CentaurChatResponse.model_validate_json(resp.text)
|
| 1286 |
|
| 1287 |
formatted_reply = f"**{data.chat_reply}**\n\nπ Technical Analysis:\n{data.technical_analysis}"
|
| 1288 |
+
chat_history.append([user_msg, formatted_reply])
|
|
|
|
|
|
|
| 1289 |
|
| 1290 |
state["arsenal"][target_id].append({
|
| 1291 |
"Timestamp": datetime.now().strftime("%H:%M:%S"),
|
|
|
|
| 1300 |
data.suggested_code, data.http_method, state)
|
| 1301 |
except Exception as e:
|
| 1302 |
exploit_logger.log("ERROR", f"Chat agent failed: {e}")
|
| 1303 |
+
chat_history.append([user_msg, f"β οΈ Agent Error: {str(e)}"])
|
|
|
|
|
|
|
| 1304 |
return chat_history, current_ep, current_pl, current_code, http_method, state
|
| 1305 |
|
| 1306 |
# ==============================================================================
|
|
|
|
| 1623 |
# GRADIO UI β all gr.Markdown() scale= calls removed (not supported)
|
| 1624 |
# ==============================================================================
|
| 1625 |
|
| 1626 |
+
_CSS = """
|
| 1627 |
.primary-btn { background: linear-gradient(45deg,#ff0080,#ff8c00) !important; }
|
| 1628 |
.exploit-table { font-family: 'Courier New', monospace; font-size: 0.9em; }
|
| 1629 |
.code-editor { font-family: 'Courier New', monospace; font-size: 0.95em; }
|
| 1630 |
+
"""
|
| 1631 |
+
|
| 1632 |
+
with gr.Blocks() as demo:
|
| 1633 |
|
| 1634 |
engine_state = gr.State({"profiles": {}, "arsenal": defaultdict(list)})
|
| 1635 |
|
|
|
|
| 1732 |
gr.Markdown("### π€ AI Agent β CENTAUR")
|
| 1733 |
chatbot = gr.Chatbot(
|
| 1734 |
height=400, label="Conversational Interface",
|
| 1735 |
+
show_label=False,
|
| 1736 |
avatar_images=(None, "https://em-content.zobj.net/source/twitter/376/robot_1f916.png")
|
| 1737 |
)
|
| 1738 |
chat_in = gr.Textbox(
|
|
|
|
| 1838 |
)
|
| 1839 |
|
| 1840 |
|
| 1841 |
+
demo.launch(share=False, server_name="0.0.0.0", server_port=7860,
|
| 1842 |
+
theme=gr.themes.Monochrome(), css=_CSS)
|