| import os |
| import gradio as gr |
| from crewai import Agent, Task, Crew |
| from langchain_openai import ChatOpenAI |
| from dotenv import load_dotenv |
|
|
| load_dotenv() |
| openai_api_key = os.getenv("OPENAI_API_KEY") |
|
|
| |
| llm = ChatOpenAI(model="gpt-4o-mini", temperature=0.5, openai_api_key=openai_api_key) |
|
|
| |
| intel_agent = Agent( |
| role="Intelligence Analyst", |
| goal="Generate detailed intelligence based on given input.", |
| backstory="Trained in data synthesis, aerial recon, signal intercepts, and pattern analysis.", |
| llm=llm, |
| verbose=True |
| ) |
|
|
| logistics_agent = Agent( |
| role="Field Logistics Coordinator", |
| goal="Optimize supply chains, manage resource allocation, and coordinate unit mobility in low-infrastructure zones.", |
| backstory="Expert in supply caching, route planning, and adaptive logistics under hostile conditions.", |
| llm=llm, |
| verbose=True |
| ) |
|
|
| psyops_agent = Agent( |
| role="Psychological Operations Planner", |
| goal="Design and execute operations to degrade enemy morale, manipulate public perception, and sow internal division.", |
| backstory="Specialist in narrative control, propaganda deployment, and cultural exploitation tactics.", |
| llm=llm, |
| verbose=True |
| ) |
|
|
| |
| def process_query(user_input): |
| task1 = Task( |
| description=f"Analyze the following scenario for intelligence: {user_input}", |
| agent=intel_agent, |
| expected_output="A structured intelligence assessment." |
| ) |
|
|
| task2 = Task( |
| description=f"Plan logistics for the scenario: {user_input}", |
| agent=logistics_agent, |
| expected_output="A detailed logistics and resource movement plan." |
| ) |
|
|
| task3 = Task( |
| description=f"Devise psyops strategy for the scenario: {user_input}", |
| agent=psyops_agent, |
| expected_output="A step-by-step psyops strategy." |
| ) |
|
|
| crew = Crew(agents=[intel_agent, logistics_agent, psyops_agent], tasks=[task1, task2, task3], verbose=False) |
| results = crew.kickoff() |
|
|
| intel_res = f"### 🛰 Intelligence Analyst\n{results.tasks_output[0].raw}" |
| logistics_res = f"### 🚚 Field Logistics Coordinator\n{results.tasks_output[1].raw}" |
| psyops_res = f"### 🧠 Psychological Operations Planner\n{results.tasks_output[2].raw}" |
|
|
| return intel_res, logistics_res, psyops_res |
|
|
| |
| with gr.Blocks(css=""" |
| body { |
| background: linear-gradient(135deg, #0f2027, #203a43, #2c5364); |
| color: white; |
| } |
| .agent-box { |
| padding: 15px; |
| border-radius: 10px; |
| margin: 10px; |
| background: rgba(255, 255, 255, 0.08); |
| box-shadow: 0px 0px 10px rgba(0,0,0,0.3); |
| min-height: 200px; |
| } |
| h1 { |
| text-align: center; |
| color: #ffcc00; |
| } |
| """) as demo: |
| gr.Markdown("# Guerrilla Warfare Agent") |
| with gr.Row(): |
| user_input = gr.Textbox(label="Enter Intel", placeholder="Type your intel here...", lines=3) |
| submit_btn = gr.Button("Run Analysis", variant="primary") |
|
|
| with gr.Row(): |
| intel_output = gr.Markdown(elem_classes="agent-box") |
| logistics_output = gr.Markdown(elem_classes="agent-box") |
| psyops_output = gr.Markdown(elem_classes="agent-box") |
|
|
| submit_btn.click(process_query, inputs=[user_input], outputs=[intel_output, logistics_output, psyops_output]) |
|
|
| demo.launch() |
|
|