Skip to content
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

Feature/google maps geocoding #665

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## PR Description

[Provide a detailed description of your changes]

## Relevant issues

[Link to relevant issues]

## Type

🆕 New Feature | 🐛 Bug Fix | 🧹 Refactoring | 📖 Documentation | 🚄 Infrastructure | ✅ Test

## Changes(optional)

[List the changes you've made]

## Testing(optional)

[Describe how you've tested your changes]

## Note(optional)

[Any additional notes or context about the PR]
77 changes: 0 additions & 77 deletions PULL_REQUEST_TEMPLATE.md

This file was deleted.

120 changes: 120 additions & 0 deletions docs/docs/integrations/geocoding_simple.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Google Maps Geocoding\n",
"This notebook shows how to use Google Maps Geocoding API to convert addresses into coordinates"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%pip install --quiet langchain-google-community googlemaps"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"os.environ[\"GOOGLE_MAPS_API_KEY\"] = \"your_api_key_here\""
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from langchain_google_community.geocoding import GoogleGeocodingTool\n",
"\n",
"# API Reference: GoogleGeocodingTool\n",
"geocoding = GoogleGeocodingTool(api_key=os.environ[\"GOOGLE_MAPS_API_KEY\"])"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Address: 1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA\\nCoordinates: 37.4225018, -122.0847402'"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Basic geocoding\n",
"geocoding.run(\"1600 Amphitheatre Parkway, Mountain View, CA\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Address: Av. Gustave Eiffel, 75007 Paris, France\n",
"Coordinates: 48.85837009999999, 2.2944813\n",
"Address: Toledo, Spain\n",
"Coordinates: 39.8628296, -4.0273067\n"
]
}
],
"source": [
"# Advanced features\n",
"\n",
"# Language support (French)\n",
"result = geocoding._run(\n",
" address=\"Eiffel Tower\",\n",
" language=\"fr\"\n",
")\n",
"print(result)\n",
"\n",
"# Region biasing (Spain)\n",
"result = geocoding._run(\n",
" address=\"Toledo\",\n",
" region=\"es\"\n",
")\n",
"print(result)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.8"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
34 changes: 33 additions & 1 deletion libs/community/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
__pycache__
# Python cache
__pycache__/
*.py[cod]
*$py.class

# Distribution / packaging
dist/
build/
*.egg-info/

# Virtual environments
.env
.venv
env/
venv/

# IDE
.idea/
.vscode/

# Testing
.pytest_cache/
.coverage
htmlcov/

# Ruff
.ruff_cache/

# Mypy
.mypy_cache/

# Jupyter
.ipynb_checkpoints/
7 changes: 6 additions & 1 deletion libs/community/langchain_google_community/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
from langchain_google_community.drive import GoogleDriveLoader
from langchain_google_community.gcs_directory import GCSDirectoryLoader
from langchain_google_community.gcs_file import GCSFileLoader
from langchain_google_community.geocoding import (
GoogleGeocodingAPIWrapper,
GoogleGeocodingTool,
)
from langchain_google_community.gmail.loader import GMailLoader
from langchain_google_community.gmail.toolkit import GmailToolkit
from langchain_google_community.google_speech_to_text import SpeechToTextLoader
Expand Down Expand Up @@ -50,6 +54,8 @@
"GMailLoader",
"GmailToolkit",
"GoogleDriveLoader",
"GoogleGeocodingAPIWrapper",
"GoogleGeocodingTool",
"GooglePlacesAPIWrapper",
"GooglePlacesTool",
"GoogleSearchAPIWrapper",
Expand All @@ -66,7 +72,6 @@
"VertexFSVectorStore",
]


from importlib import metadata

try:
Expand Down
Loading
Loading