|
| 1 | +# Real-Estate Agent (A2A) Sample |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +This sample demonstrates a sophisticated real-estate agent based on the Agent-to-Agent (A2A) protocol. The agent is capable of understanding natural language queries, performing filtered searches for rental properties, and returning structured results. |
| 6 | + |
| 7 | +## 🔗 Original Source and Contributions |
| 8 | + |
| 9 | +This sample is a snapshot of an active open-source project. For the latest updates, to report issues, or to contribute, please visit the original repositories: |
| 10 | + |
| 11 | +* **Real-Estate Agent:** `https://github.com/amineremache/robolancerai-real-estate-agent` |
| 12 | +* **Dafty MCP Server:** `https://github.com/amineremache/dafty-mcp` |
| 13 | + |
| 14 | +We encourage you to contribute directly to the source projects! |
| 15 | + |
| 16 | +## 🏛️ Architecture |
| 17 | + |
| 18 | +The system is composed of three main services orchestrated with `docker-compose`: |
| 19 | + |
| 20 | +1. **`real-estate-agent`**: The core Python A2A agent that handles user requests and orchestrates tool calls. |
| 21 | +2. **`dafty-mcp`**: A Node.js/TypeScript MCP (Model Context Protocol) tool server that provides the tools for interacting with the Daft.ie rental service. It includes a web scraper and an intelligent query parser. |
| 22 | +3. **`ollama`**: A local LLM service that runs the `tinydolphin` model to parse natural language queries into structured JSON. |
| 23 | + |
| 24 | +## ✨ Features |
| 25 | + |
| 26 | +- **Natural Language Understanding**: Uses a local LLM to parse user queries like "Find a 2-bed apartment in Dublin under €2000." |
| 27 | +- **Filtered Search**: Performs filtered searches based on location, price, and number of bedrooms. |
| 28 | +- **Self-Contained Environment**: The entire application runs in a portable and isolated Docker environment. |
| 29 | +- **A2A Compliant**: Built on the A2A protocol for standardized agent communication. |
| 30 | + |
| 31 | +## 🚀 Getting Started |
| 32 | + |
| 33 | +### Prerequisites |
| 34 | + |
| 35 | +- Docker and `docker-compose` must be installed. |
| 36 | +- You must have a `.env` file in the root of this sample directory. You can create one from the `.env.example` file and add your `API_KEY`. |
| 37 | + |
| 38 | +### Installation and Running |
| 39 | + |
| 40 | +1. **Navigate to the sample directory:** |
| 41 | + ```bash |
| 42 | + cd samples/python/agents/real_estate_agent |
| 43 | + ``` |
| 44 | + |
| 45 | +2. **Build and start the services:** |
| 46 | + ```bash |
| 47 | + docker-compose up --build |
| 48 | + ``` |
| 49 | + |
| 50 | +3. **The services will now be running:** |
| 51 | + * The `real-estate-agent` will be available on port `3001`. |
| 52 | + * The `dafty-mcp` and `ollama` services will be running in the background. |
| 53 | + |
| 54 | +## 🧪 Testing the Agent |
| 55 | + |
| 56 | +You can send a request to the agent using `curl`. The following example demonstrates how to search for a 2-bedroom apartment in Dublin for under €2000. |
| 57 | + |
| 58 | +```bash |
| 59 | +curl -X POST http://localhost:3001/ \ |
| 60 | +-H "Content-Type: application/json" \ |
| 61 | +-H "Authorization: Bearer <YOUR_API_KEY>" \ |
| 62 | +-d '{ |
| 63 | + "jsonrpc": "2.0", |
| 64 | + "id": "1", |
| 65 | + "method": "message/send", |
| 66 | + "params": { |
| 67 | + "message": { |
| 68 | + "messageId": "1", |
| 69 | + "role": "user", |
| 70 | + "parts": [ |
| 71 | + { |
| 72 | + "kind": "text", |
| 73 | + "text": "Find a 2-bed apartment in Dublin under €2000." |
| 74 | + } |
| 75 | + ] |
| 76 | + } |
| 77 | + } |
| 78 | +}' > results.json |
| 79 | +``` |
| 80 | + |
| 81 | +The results of the query will be saved to a `results.json` file in your project directory. |
0 commit comments