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

Documentation #163

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
86 changes: 84 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ langchain-openai = "0.0.2"
tokenizers = "^0.15.2"
boto3 = ">=1.33.2,<1.34.35"
aioboto3 = "^12.3.0"
duckduckgo-search = "^6.2.5"
pyowm = "^3.3.0"

[tool.poetry.group.dev.dependencies]
black = "^23.11.0"
Expand Down
25 changes: 23 additions & 2 deletions salesgpt/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import boto3
import requests
from langchain.agents import Tool
from langchain.agents import load_tools
from langchain.chains import RetrievalQA
from langchain.text_splitter import CharacterTextSplitter
from langchain_community.chat_models import BedrockChat
from langchain_community.vectorstores import Chroma
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
from langchain_community.tools import DuckDuckGoSearchRun
from langchain_community.utilities import OpenWeatherMapAPIWrapper
from litellm import completion
import smtplib
from email.mime.multipart import MIMEMultipart
Expand Down Expand Up @@ -244,19 +247,37 @@ def generate_calendly_invitation_link(query):
return f"url: {data['resource']['booking_url']}"
else:
return "Failed to create Calendly link: "

def search_web(query):
search = DuckDuckGoSearchRun()
return search.invoke(query)

def weather_search(query):
OPENWEATHERMAP_API_KEY = os.getenv(
"OPENWEATHERMAP_API_KEY")
weather = OpenWeatherMapAPIWrapper()
print("IT worked")
return weather.run(query)

def get_tools(product_catalog):
# query to get_tools can be used to be embedded and relevant tools found
# see here: https://langchain-langchain.vercel.app/docs/use_cases/agents/custom_agent_with_plugin_retrieval#tool-retriever

# we only use four tools for now, but this is highly extensible!
knowledge_base = setup_knowledge_base(product_catalog)
tools = [

tools = load_tools(["openweathermap-api"])
tools.extend([
Tool(
name="ProductSearch",
func=knowledge_base.run,
description="useful for when you need to answer questions about product information or services offered, availability and their costs.",
),
Tool(
name="WebSearch",
func=search_web,
description="useful for when you need to search the web for information.",
),
Tool(
name="GeneratePaymentLink",
func=generate_stripe_payment_link,
Expand All @@ -273,6 +294,6 @@ def get_tools(product_catalog):
description='''Useful for when you need to create invite for a personal meeting in Sleep Heaven shop.
Sends a calendly invitation based on the query input.''',
)
]
])

return tools
43 changes: 43 additions & 0 deletions website/docs/Tools/Internet_search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
sidebar_position: 2

---
# Internet Search

SalesGPT now has the capability to perform internet searches using DuckDuckGo through a pre-made LangChain tool. This feature allows the AI sales agent to access up-to-date information from the web during conversations, enhancing its ability to provide relevant and timely responses.

## How to Enable Internet Search

To enable the DuckDuckGo search functionality in your SalesGPT setup:

1. Ensure you have the latest version of LangChain installed.

2. Add the DuckDuckGo search tool to your tools list in the `get_tools` function within the `tools.py` file:

```python
from langchain.tools import DuckDuckGoSearchRun

def get_tools(product_catalog):
# ... other tool configurations ...

tools.extend([
# ... other tools ...
Tool(
name="WebSearch",
func=DuckDuckGoSearchRun().run,
description="Useful for when you need to search the web for current information.",
),
])

return tools
```

3. Make sure the `USE_TOOLS_IN_API` environment variable is set to `True` in your `.env` file:

```
USE_TOOLS_IN_API=True
```

By adding this tool, your SalesGPT agent will be able to perform web searches when it needs to find information that isn't available in its training data or product catalog. This can be particularly useful for answering questions about current events, market trends, or competitor information.

Remember to use this tool responsibly and in compliance with DuckDuckGo's terms of service.
75 changes: 75 additions & 0 deletions website/docs/Tools/Pre-built_tools copy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
sidebar_position: 2

---
# Pre-built Tools

SalesGPT is not limited to just custom-built tools. It can also leverage a wide range of pre-built tools available from LangChain. These tools provide additional capabilities and integrations that can enhance your AI sales agent's functionality.

## Using LangChain's Pre-built Tools

LangChain offers a variety of pre-made tools that you can easily integrate into SalesGPT. These tools cover a wide range of functionalities, from web searches to mathematical calculations.

To use these tools:

1. Set up the desired tools according to the LangChain documentation.
2. Add the configured tools to the "tools" list in your SalesGPT setup.

You can find the full list of available tools and their setup instructions in the [LangChain Tools documentation](https://python.langchain.com/v0.2/docs/integrations/tools/).

Some popular pre-built tools include:

- Search tools (e.g., SerpAPI, Google Search)
- Calculator tools
- Weather tools
- News API tools
- And many more!

By incorporating these pre-built tools, you can significantly expand the capabilities of your AI sales agent, allowing it to access real-time information, perform calculations, or integrate with various APIs as needed during sales conversations.

Remember to review the documentation for each tool you want to use, as some may require additional setup steps or API keys.


## Example: Weather Search Tool

One pre-built tool that has been implemented in SalesGPT is the weather search tool. This serves as a good example of how to set up and use a pre-built tool from LangChain. Here's how it's implemented:

1. First, ensure you have the necessary API key. For the weather tool, you need an OpenWeatherMap API key. You can get a free key that allows 1000 requests per day from [OpenWeatherMap](https://openweathermap.org/api).

2. Add the API key to your `.env` file:

```
OPENWEATHERMAP_API_KEY=your_api_key_here
```

3. In the `tools.py` file, import the necessary components and set up the tool:

```python
from langchain.tools import OpenWeatherMapAPIWrapper
import os

def weather_search(query):
OPENWEATHERMAP_API_KEY = os.getenv("OPENWEATHERMAP_API_KEY")
weather = OpenWeatherMapAPIWrapper()
return weather.run(query)
```

4. Add the weather tool to your `get_tools` function:

```python
def get_tools(product_catalog):
tools = load_tools(["openweathermap-api"])
tools.extend([
# ... other tools ...
Tool(
name="WeatherSearch",
func=weather_search,
description="Useful for getting current weather information for a specific location.",
),
])
return tools
```

This example demonstrates how to set up a pre-built tool from LangChain. Each tool may have its own setup requirements, such as API keys or additional configurations. Always refer to the LangChain documentation for specific setup instructions for each tool you want to use.


Loading