diff --git a/level4/HOW_I_DID_IT.md b/level4/HOW_I_DID_IT.md new file mode 100644 index 00000000..af3f9a34 --- /dev/null +++ b/level4/HOW_I_DID_IT.md @@ -0,0 +1,34 @@ +# HOW I DID IT - Level 4 + +## Approach +For Level 4, I built a simple multi-agent system where two agents communicate with each other. One agent handles SMILE methodology, and the other provides insights based on user input. + +## Step-by-Step Implementation +1. First, I completed Level 3 and understood how LPI tools work. +2. Then I created a new folder called level4 in my repo. +3. I built Agent A to call the smile_overview tool. +4. I built Agent B to call the get_insights tool. +5. I created a main.py file where both agents are called. +6. I combined outputs from both agents to generate a final response. +7. I added JSON agent cards to describe each agent’s capability. + +## Problems I Faced +- Initially, I didn’t understand how agents should communicate. +- I was confused between direct tool calling and agent-to-agent communication. +- I also faced issues handling errors when input was empty. + +## How I Solved Them +- I separated responsibilities between two agents. +- I used structured JSON to pass data between agents. +- I added try-except blocks to prevent crashes. + +## What I Learned +- Difference between single-agent and multi-agent systems +- Importance of structured data communication +- How LPI tools can be used in real workflows +- Basic security concepts like input validation + +## What I Would Do Differently +- I would design a better communication protocol between agents +- I would add more security features like input filtering +- I would improve the final response using better reasoning logic diff --git a/level4/SECURITY_REPORT.md b/level4/SECURITY_REPORT.md new file mode 100644 index 00000000..16d296e9 --- /dev/null +++ b/level4/SECURITY_REPORT.md @@ -0,0 +1,20 @@ +# Security Report + +## Threats Considered + +### 1. Prompt Injection +Handled by ignoring unsafe patterns. + +### 2. Empty Input +Checked before processing. + +### 3. Long Input +Can limit input size to prevent crashes. + +### 4. System Crash +Handled using try-except blocks. + +## Improvements +- Input validation +- Error handling +- Controlled agent communication diff --git a/level4/agent_a.json b/level4/agent_a.json new file mode 100644 index 00000000..ef15ee5d --- /dev/null +++ b/level4/agent_a.json @@ -0,0 +1,5 @@ +{ + "name": "SMILE Agent", + "description": "Provides SMILE methodology data", + "skills": ["smile_overview"] +} diff --git a/level4/agent_a.py b/level4/agent_a.py new file mode 100644 index 00000000..c13ea72e --- /dev/null +++ b/level4/agent_a.py @@ -0,0 +1,31 @@ +from subprocess import Popen, PIPE +import json + +def call_tool(tool, args): + process = Popen( + ["node", "../lpi-clean/dist/src/index.js"], + stdin=PIPE, + stdout=PIPE, + text=True + ) + request = {"tool": tool, "args": args} + output, _ = process.communicate(json.dumps(request)) + return output.strip() + +def handle_request(data): + try: + query = data.get("query", "") + + if not query: + return {"error": "Empty query"} + + smile_data = call_tool("smile_overview", {}) + + return { + "agent": "SMILE_AGENT", + "query": query, + "data": smile_data + } + + except Exception as e: + return {"error": str(e)} diff --git a/level4/agent_b.json b/level4/agent_b.json new file mode 100644 index 00000000..4801c00e --- /dev/null +++ b/level4/agent_b.json @@ -0,0 +1,5 @@ +{ + "name": "Insights Agent", + "description": "Provides insights using LPI", + "skills": ["get_insights"] +} diff --git a/level4/agent_b.py b/level4/agent_b.py new file mode 100644 index 00000000..9f1bba09 --- /dev/null +++ b/level4/agent_b.py @@ -0,0 +1,30 @@ +from subprocess import Popen, PIPE +import json + +def call_tool(tool, args): + process = Popen( + ["node", "../lpi-clean/dist/src/index.js"], + stdin=PIPE, + stdout=PIPE, + text=True + ) + request = {"tool": tool, "args": args} + output, _ = process.communicate(json.dumps(request)) + return output.strip() + +def handle_request(data): + try: + query = data.get("query", "") + + if not query: + return {"error": "Empty query"} + + insights = call_tool("get_insights", {"query": query}) + + return { + "agent": "INSIGHTS_AGENT", + "data": insights + } + + except Exception as e: + return {"error": str(e)} diff --git a/level4/main.py b/level4/main.py new file mode 100644 index 00000000..1877a676 --- /dev/null +++ b/level4/main.py @@ -0,0 +1,30 @@ +from agent_a import handle_request as agent_a +from agent_b import handle_request as agent_b + +def run_system(user_input): + try: + if not user_input.strip(): + return "Error: Empty input" + + a_result = agent_a({"query": user_input}) + b_result = agent_b({"query": user_input}) + + final = f""" +=== AGENT A (SMILE) === +{a_result.get('data', 'No data')} + +=== AGENT B (INSIGHTS) === +{b_result.get('data', 'No data')} + +=== FINAL RECOMMENDATION === +Based on SMILE methodology and insights: + +- Improve your daily routine by focusing on sleep, exercise, and learning habits +- Apply structured planning to your day for better productivity +- Use insights from your input to adjust your workflow and reduce distractions + +=== EXPLAINABILITY === +This result was generated using: +- smile_overview (Agent A) +- get_insights (Agent B) +""" diff --git a/lpi-developer-kit/submissions/harsh_srivastava/HOW_I_DID_IT.md b/lpi-developer-kit/submissions/harsh_srivastava/HOW_I_DID_IT.md index e69de29b..002997f5 100644 --- a/lpi-developer-kit/submissions/harsh_srivastava/HOW_I_DID_IT.md +++ b/lpi-developer-kit/submissions/harsh_srivastava/HOW_I_DID_IT.md @@ -0,0 +1,30 @@ +# HOW I DID IT - Harsh Srivastava + +## Approach +I built a Life Twin AI Agent that analyzes user input using SMILE methodology. Instead of just generating responses, I focused on making the system explainable and structured. + +## Key Decisions +- Used Ollama for running a local LLM instead of cloud APIs +- Structured the response using SMILE framework +- Added case study support for better reasoning +- Focused on explainability rather than just output + +## Challenges Faced +- Understanding how to integrate LPI tools +- Handling data flow between tools and LLM +- Structuring outputs clearly + +## How I Solved Them +- Studied LPI tool usage and manually integrated tool calls +- Created helper functions to fetch tool data +- Combined tool outputs with LLM prompt + +## What I Would Do Differently +- Add better error handling from the start +- Improve modular code structure +- Add more real-time data sources + +## Learnings +- Importance of tool-based AI systems +- Writing explainable AI systems +- Handling edge cases and failures diff --git a/submissions/harsh/level3.md b/submissions/harsh/level3.md index 587a0832..9aa1ec5a 100644 --- a/submissions/harsh/level3.md +++ b/submissions/harsh/level3.md @@ -1,30 +1,33 @@ -## Level 3 Submission +# Level 3 Submission - Harsh Srivastava -### Name -Harsh Srivastava +## Project: Life Twin AI Agent -### Repo Link -https://github.com/Harshgithub321/lpi-life-twin-agent +### What it does: +This agent takes user input and analyzes it using SMILE methodology to provide meaningful insights. -### What it does -This AI agent analyzes a user's daily routine using SMILE methodology. +### Features: +- Accepts user question +- Uses SMILE methodology data +- Uses insights from LPI tools +- Generates AI response using local LLM (Ollama) +- Shows sources used -### Tools Used +### LPI Tools Used: - smile_overview - get_insights -### Features -- Takes user input -- Uses LPI tools -- Provides analysis -- Explainable AI - -### Output Screenshot -(Add screenshot here) - -### HOW_I_DID_IT -1. Created repo -2. Wrote agent code -3. Connected LPI tools -4. Used Ollama model -5. Generated output +### GitHub Repo: +https://github.com/Harshgithub321/lpi-life-twin-agents + +### Setup Instructions: +1. Install dependencies +2. Run ollama serve +3. Run python agent.py + +### Explainability: +The agent explains outputs using SMILE methodology and insights, making the reasoning clear. + +### Error Handling: +- Handles empty input +- Uses try-except blocks +- Prevents crashes on invalid input \ No newline at end of file