You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+65-2Lines changed: 65 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,70 @@ A suite of tools to perform geospatial operations using Large Language Models.
4
4
5
5
LLLLM stands for Lat-Lng-Large-Language-Model, you can call it as "el el el el emm" or "L4M".
6
6
7
-
8
7
## Setup
9
8
1. Create the llllm-env - `mamba env create -f environment.yaml`
10
-
2. Set your OpenAI API key as an environment variable - `export OPENAI_API_KEY=<your key here>`
9
+
2. Set your OpenAI API key as an environment variable - `export OPENAI_API_KEY=<your key here>`
10
+
11
+
## Getting Started
12
+
13
+
### Adding a new tool
14
+
15
+
Tools are ways the agent can use to interact with the outside world. You can find more information on how LLMs use tools to solve new tasks at scale in this paper: [Toolformer](https://arxiv.org/pdf/2302.04761.pdf)
16
+
17
+
Langchain comes bundled with a set of tools like Google Search, Wikipedia, Python REPL, Shell, Wolfram Alpha & several others - find the list of pre-built tools [here](https://python.langchain.com/en/latest/modules/agents/tools.html#)
18
+
19
+
Creating a new tool is simple in Langchain. You can create a custom tool by:
20
+
- using the `Tool` dataclass or
21
+
- inhering from the `BaseTool` class
22
+
23
+
Both these methods need to provide:
24
+
- name: unique & referred to by LLM while executing the chains
25
+
- description: detailed description of when & how the LLM should use this tool
26
+
- args_schema: arguments to the tool
27
+
28
+
Barebones of how to define a custom tool by inheriting from the `BaseTool` class
29
+
```python
30
+
from langchain.tools import BaseTool
31
+
32
+
classYourCustomTool(BaseTool):
33
+
name =<name>
34
+
description =<detailed-description>
35
+
args_schema =<PydanticModel>
36
+
37
+
def_run(self, query):
38
+
# functionality of the tool
39
+
pass
40
+
41
+
def_arun(self, query):
42
+
# async implementation of the tool (Optional)
43
+
raiseNotImplementedError
44
+
```
45
+
We have a few tools available in the LLLLM toolkit that you can use for reference - [MercantileTool](tools/mercantile_tool.py), [GeoPyTool](tools/geopy/), [OSMnxTool](tools/osmnx/)
46
+
47
+
Learn more about creating custom tools by reading this blog on [Building Custom Tools for LLM Agents from Pinecone](https://www.pinecone.io/learn/langchain-tools/) or [documention from Langchain](https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html).
48
+
49
+
50
+
### Creating an agent
51
+
52
+
Agents act like routers using LLMs to decide which tools to use for the task at hand. There are different types of agents available in langchain:
53
+
-[ReAct](https://python.langchain.com/en/latest/modules/agents/agents/examples/react.html) - Reason & Act agents are optimized for picking tools for best response - read more about them in this [paper](https://react-lm.github.io/)
54
+
-[Conversation Agent](https://python.langchain.com/en/latest/modules/agents/agents/examples/chat_conversation_agent.html) - they are ideal to use in a conversational setting
55
+
-[Structured Tool Chat Agent](https://python.langchain.com/en/latest/modules/agents/agents/examples/structured_chat.html) - use this agent if you have tools that expect multi-input parameters. Check the OSMnx or GeoPy tool for reference.
56
+
57
+
Usage
58
+
```python
59
+
from agents.l4m_agent import base_agent
60
+
61
+
agent = base_agent(
62
+
llm=<LLMobject>, # instance of an LLM like GPT-3.5-TURBO or GPT-4
63
+
tools=[<tool1>, <tool1>, ...], # list of tools the agent has access to perform its tasks
64
+
name=<name of agent>, # Agent.Type for eg: zero-shot-react-description or structure-chat-zero-shot-react-description (for multi-input tools)
65
+
)
66
+
```
67
+
68
+
### Creating notebooks to test
69
+
Import the tools & create an agent in jupyter notebook to interact with them. Please find example notebooks [here](/nbs/).
0 commit comments