Skip to content

Commit dc79118

Browse files
authored
Merge pull request #9 from developmentseed/geopy-tool
Add tools from geopy to geocode & compute distance between 2 points
2 parents 77df917 + 754ac14 commit dc79118

File tree

7 files changed

+439
-10
lines changed

7 files changed

+439
-10
lines changed

agents/l4m_agent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from langchain.agents import initialize_agent
22

33

4-
def base_agent(llm, tools):
4+
def base_agent(llm, tools, name="zero-shot-react-description"):
55
"""Base agent to perform xyz slippy map tiles operations.
66
77
llm: LLM object
@@ -10,8 +10,8 @@ def base_agent(llm, tools):
1010
agent = initialize_agent(
1111
llm=llm,
1212
tools=tools,
13-
agent="zero-shot-react-description",
14-
max_iterations=5,
13+
agent=name,
14+
max_iterations=3,
1515
early_stopping_method="generate",
1616
verbose=True,
1717
)

environment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ dependencies:
99
- langchain
1010
- duckduckgo-search
1111
- mercantile
12+
- geopy
1213
- ipywidgets
1314
- jupyterlab

nbs/23-05-18_mercantile-tool.ipynb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
},
5656
{
5757
"cell_type": "code",
58-
"execution_count": 11,
58+
"execution_count": 5,
5959
"id": "660da8b8-f422-4f31-a3aa-15296709033f",
6060
"metadata": {},
6161
"outputs": [],
@@ -75,7 +75,7 @@
7575
},
7676
{
7777
"cell_type": "code",
78-
"execution_count": 12,
78+
"execution_count": 6,
7979
"id": "b4c4291d-35c9-48b7-8b45-7da5ff155db7",
8080
"metadata": {},
8181
"outputs": [],
@@ -85,7 +85,7 @@
8585
},
8686
{
8787
"cell_type": "code",
88-
"execution_count": 13,
88+
"execution_count": 8,
8989
"id": "6baab55c-892f-4938-8f18-c2b8c8712cf2",
9090
"metadata": {},
9191
"outputs": [
@@ -96,11 +96,15 @@
9696
"\n",
9797
"\n",
9898
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
99-
"\u001b[32;1m\u001b[1;3mI need to use the mercantile tool to get the xyz tile for London.\n",
99+
"\u001b[32;1m\u001b[1;3mI need to use mercantile to get the xyz tile for London, but I need to find the longitude and latitude coordinates for London first.\n",
100+
"Action: DuckDuckGo\n",
101+
"Action Input: \"London longitude and latitude\"\u001b[0m\n",
102+
"Observation: \u001b[36;1m\u001b[1;3mLondon, city, capital of the United Kingdom. It is among the oldest of the world's great cities—its history spanning nearly two millennia—and one of the most cosmopolitan. By far Britain's largest metropolis, it is also the country's economic, transportation, and cultural centre. London is situated in southeastern England, lying astride the River Thames some 50 miles (80 km) upstream ... The length of a degree of arc of latitude is approximately 111 km (69 miles), varying, because of the nonuniformity of Earth's curvature, from 110.567 km (68.706 miles) at the Equator to 111.699 km (69.41 miles) at the poles. Geographic latitude is also given in degrees, minutes, and seconds. facts about lines of longitude London (51°30′N) is farther north than Calgary (51°03′N) with Amsterdam, Berlin and Dublin being located even further north. Montreal is south of Paris. Phoenix is placed close to the Ancient city of Carthage, which was a Phoenician city-state. People from Phoenix today are known as Phoenicians. (Credit: reddit users twomancanoe and svaachkuet) Covering an area of 130,279 sq. km, England is the largest country in the United Kingdom. Located in the southeastern part of the country, along the banks of the Thames River is London - the capital and the largest city of England. London serves as one of the most important global cities in the world. Where is England? Greenwich Mean Time or GMT is mean (average) solar time at the Greenwich Meridian or Prime Meridian, 0 degrees longitude. The Prime Meridian is the reference point for every time zone in the world. The time displayed by the Shepherd Gate Clock at the Royal Observatory in Greenwich, London, is always GMT. When the sun is at its highest point ...\u001b[0m\n",
103+
"Thought:\u001b[32;1m\u001b[1;3mNow that I have the longitude and latitude information for London, I can use mercantile to get the xyz tile.\n",
100104
"Action: mercantile\n",
101-
"Action Input: -0.1278, 51.5074, 10\u001b[0m\n",
105+
"Action Input: \"-0.1278, 51.5074, 10\"\u001b[0m\n",
102106
"Observation: \u001b[33;1m\u001b[1;3mTile(x=511, y=340, z=10.0)\u001b[0m\n",
103-
"Thought:\u001b[32;1m\u001b[1;3mI now know the xyz tile for London is Tile(x=511, y=340, z=10.0).\n",
107+
"Thought:\u001b[32;1m\u001b[1;3mThe xyz tile for London is Tile(x=511, y=340, z=10.0)\n",
104108
"Final Answer: Tile(x=511, y=340, z=10.0)\u001b[0m\n",
105109
"\n",
106110
"\u001b[1m> Finished chain.\u001b[0m\n"
@@ -113,7 +117,7 @@
113117
" 'output': 'Tile(x=511, y=340, z=10.0)'}"
114118
]
115119
},
116-
"execution_count": 13,
120+
"execution_count": 8,
117121
"metadata": {},
118122
"output_type": "execute_result"
119123
}

0 commit comments

Comments
 (0)