generated from google/new-project
-
Notifications
You must be signed in to change notification settings - Fork 489
feat(samples): add real-estate-agent sample #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
amineremache
wants to merge
4
commits into
a2aproject:main
Choose a base branch
from
amineremache:feat-real-estate-agent
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b16c564
feat(samples): add real-estate-agent sample
amineremache 0916396
Merge branch 'main' into feat-real-estate-agent
amineremache 5e14607
Merge branch 'main' into feat-real-estate-agent
amineremache f5cd5c4
Merge branch 'main' into feat-real-estate-agent
amineremache File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| .git | ||
| .gitignore | ||
| tests | ||
| .env | ||
| .vscode | ||
| __pycache__ | ||
| *.pyc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # The port the server will run on | ||
| PORT=3001 | ||
|
|
||
| # A secret key to authenticate requests | ||
| API_KEY=your-secret-api-key | ||
|
|
||
| # The URL of the MCP server | ||
| MCP_SERVER_URL=http://localhost:4000/sse | ||
|
|
||
|
|
||
| # Your ngrok authtoken | ||
| NGROK_AUTHTOKEN=your_ngrok_authtoken_here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| # Byte-compiled / optimized / DLL files | ||
| __pycache__/ | ||
| *.py[cod] | ||
| *$py.class | ||
|
|
||
| # C extensions | ||
| *.so | ||
|
|
||
| # Distribution / packaging | ||
| .Python | ||
| build/ | ||
| develop-eggs/ | ||
| dist/ | ||
| downloads/ | ||
| eggs/ | ||
| .eggs/ | ||
| lib/ | ||
| lib64/ | ||
| parts/ | ||
| sdist/ | ||
| var/ | ||
| wheels/ | ||
| *.egg-info/ | ||
| .installed.cfg | ||
| *.egg | ||
| MANIFEST | ||
|
|
||
| # PyInstaller | ||
| # Usually these files are written by a python script from a template | ||
| # before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
| *.manifest | ||
| *.spec | ||
|
|
||
| # Installer logs | ||
| pip-log.txt | ||
| pip-delete-this-directory.txt | ||
|
|
||
| # Unit test / coverage reports | ||
| htmlcov/ | ||
| .tox/ | ||
| .nox/ | ||
| .coverage | ||
| .coverage.* | ||
| .cache | ||
| nosetests.xml | ||
| coverage.xml | ||
| *.cover | ||
| .hypothesis/ | ||
| .pytest_cache/ | ||
|
|
||
| # Translations | ||
| *.mo | ||
| *.pot | ||
|
|
||
| # Django stuff: | ||
| *.log | ||
| local_settings.py | ||
| db.sqlite3 | ||
|
|
||
| # Flask stuff: | ||
| instance/ | ||
| .webassets-cache | ||
|
|
||
| # Scrapy stuff: | ||
| .scrapy | ||
|
|
||
| # Sphinx documentation | ||
| docs/_build/ | ||
|
|
||
| # PyBuilder | ||
| target/ | ||
|
|
||
| # Jupyter Notebook | ||
| .ipynb_checkpoints | ||
|
|
||
| # IPython | ||
| profile_default/ | ||
| ipython_config.py | ||
|
|
||
| # pyenv | ||
| .python-version | ||
|
|
||
| # celery beat schedule file | ||
| celerybeat-schedule | ||
|
|
||
| # SageMath parsed files | ||
| *.sage.py | ||
|
|
||
| # Environments | ||
| .env | ||
| .venv | ||
| env/ | ||
| venv/ | ||
| ENV/ | ||
| env.bak/ | ||
| venv.bak/ | ||
|
|
||
| # Spyder project settings | ||
| .spyderproject | ||
| .spyderworkspace | ||
|
|
||
| # Rope project settings | ||
| .ropeproject | ||
|
|
||
| # mkdocs documentation | ||
| /site | ||
|
|
||
| # mypy | ||
| .mypy_cache/ | ||
| .dmypy.json | ||
| dmypy.json | ||
|
|
||
| # Pyre type checker | ||
| .pyre/ | ||
|
|
||
| .env | ||
| .session |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [0.1.2] - 2025-07-06 | ||
|
|
||
| ### Added | ||
| - Deployment scripts for Google Cloud Platform. | ||
| - `ngrok` integration for creating a public URL for the agent. | ||
| - `gcp_setup.sh` to set up the environment on a GCP VM. | ||
| - `gcp_initial_vm_setup.sh` and `gcp_startup_service.sh` for service configuration. | ||
|
|
||
| ### Changed | ||
| - Updated `docker-compose.yml` to use a dedicated network and handle environment variables for deployment. | ||
| - The application now listens on `::` to accept connections from any IP address. | ||
| - `agent_card.py` now uses an environment variable for the agent's public URL. | ||
| - Updated `README.md` with deployment instructions for GCP. | ||
|
|
||
| ## [0.1.1] - 2025-07-05 | ||
|
|
||
| ### Added | ||
| - Integrated `ollama` with the `tinydolphin` model to parse natural language queries into structured JSON. | ||
| - A new `parse_query` tool in the `dafty-mcp` to handle query parsing. | ||
|
|
||
| ### Changed | ||
| - The `agent_executor` now calls the `parse_query` tool before searching for properties. | ||
| - The `dafty-mcp` client now has a generic `call_tool` method. | ||
| - Updated `docker-compose.yml` to include the `ollama` and `ollama-setup` services. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Use an official Python runtime as a parent image | ||
| FROM python:3.13-slim | ||
|
|
||
| # Set the working directory in the container | ||
| WORKDIR /usr/src/app | ||
|
|
||
| # Copy the requirements file to the working directory | ||
| COPY requirements.txt ./ | ||
|
|
||
| # Install any needed packages specified in requirements.txt | ||
| RUN pip install --no-cache-dir -r requirements.txt gunicorn | ||
|
|
||
| # Bundle app source | ||
| COPY . . | ||
|
|
||
| # Create a non-root user and switch to it | ||
| RUN useradd --create-home appuser | ||
| USER appuser | ||
|
|
||
| # Set environment variables | ||
| ENV PYTHONUNBUFFERED=1 | ||
|
|
||
| # Your app binds to port 3001, so expose that | ||
| EXPOSE 3001 | ||
|
|
||
| # Define the command to run your app | ||
| CMD ["gunicorn", "-w", "2", "-k", "uvicorn.workers.UvicornWorker", "main:app", "--bind", "[::]:3001", "--access-logfile", "-", "--error-logfile", "-", "--log-level", "info"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| ISC License | ||
|
|
||
| Copyright (c) 2025, Amine REMACHE <[email protected]> | ||
|
|
||
| Permission to use, copy, modify, and/or distribute this software for any | ||
| purpose with or without fee is hereby granted, provided that the above | ||
| copyright notice and this permission notice appear in all copies. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| WITH REGARD to THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| # Real-Estate Agent (A2A) Sample | ||
|
|
||
|  | ||
|
|
||
| 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. | ||
|
|
||
| ## 🔗 Original Source and Contributions | ||
|
|
||
| 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: | ||
|
|
||
| * **Real-Estate Agent:** `https://github.com/amineremache/robolancerai-real-estate-agent` | ||
| * **Dafty MCP Server:** `https://github.com/amineremache/dafty-mcp` | ||
|
|
||
| We encourage you to contribute directly to the source projects! | ||
|
|
||
| ## 🏛️ Architecture | ||
|
|
||
| The system is composed of three main services orchestrated with `docker-compose`: | ||
|
|
||
| 1. **`real-estate-agent`**: The core Python A2A agent that handles user requests and orchestrates tool calls. | ||
| 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. | ||
| 3. **`ollama`**: A local LLM service that runs the `tinydolphin` model to parse natural language queries into structured JSON. | ||
|
|
||
| ## ✨ Features | ||
|
|
||
| - **Natural Language Understanding**: Uses a local LLM to parse user queries like "Find a 2-bed apartment in Dublin under €2000." | ||
| - **Filtered Search**: Performs filtered searches based on location, price, and number of bedrooms. | ||
| - **Self-Contained Environment**: The entire application runs in a portable and isolated Docker environment. | ||
| - **A2A Compliant**: Built on the A2A protocol for standardized agent communication. | ||
|
|
||
| ## 🚀 Getting Started | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Docker and `docker-compose` must be installed. | ||
| - 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`. | ||
|
|
||
| ### Installation and Running | ||
|
|
||
| 1. **Navigate to the sample directory:** | ||
| ```bash | ||
| cd samples/python/agents/real_estate_agent | ||
| ``` | ||
|
|
||
| 2. **Build and start the services:** | ||
| ```bash | ||
| docker-compose up --build | ||
| ``` | ||
|
|
||
| 3. **The services will now be running:** | ||
| * The `real-estate-agent` will be available on port `3001`. | ||
| * The `dafty-mcp` and `ollama` services will be running in the background. | ||
|
|
||
| ## 🧪 Testing the Agent | ||
|
|
||
| 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. | ||
|
|
||
| ```bash | ||
| curl -X POST http://localhost:3001/ \ | ||
| -H "Content-Type: application/json" \ | ||
| -H "Authorization: Bearer <YOUR_API_KEY>" \ | ||
| -d '{ | ||
| "jsonrpc": "2.0", | ||
| "id": "1", | ||
| "method": "message/send", | ||
| "params": { | ||
| "message": { | ||
| "messageId": "1", | ||
| "role": "user", | ||
| "parts": [ | ||
| { | ||
| "kind": "text", | ||
| "text": "Find a 2-bed apartment in Dublin under €2000." | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }' > results.json | ||
| ``` | ||
|
|
||
| The results of the query will be saved to a `results.json` file in your project directory. |
Binary file added
BIN
+805 KB
samples/python/agents/real_estate_agent/assets/a2a-real-estate-agent-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions
11
samples/python/agents/real_estate_agent/dafty-mcp/.dockerignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| node_modules | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| .session | ||
| .git | ||
| .vscode | ||
| .idea | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| lerna-debug.log* | ||
| .pnpm-debug.log* | ||
| tests | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.