Skip to content

A gpt chatbot that can search the web using Serp and Wolfram Alpha's api.

License

Notifications You must be signed in to change notification settings

willdphan/gpt-search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

GPT-Search

This repository provides a Python script for performing Google searches and extracting text from the search results using GPT-3. The script takes in a search query as input, along with the user's OpenAI API key and the GPT-3 model ID, and returns the corresponding search results as well as summaries generated by the GPT-3 model.

Installation

To install the necessary packages, use the following command:

pip install langchain openai google-search-results

Usage

Load the necessary libraries and set the environment variables for OpenAI API key and SERP API key. javascript

from langchain.agents import load_tools
from langchain.agents import initialize_agent
from langchain.llms import OpenAI
import os

os.environ['OPENAI_API_KEY'] = "YOUR_OPENAI_API_KEY_HERE"
os.environ['SERPAPI_API_KEY'] = "YOUR_SERPAPI_API_KEY_HERE"

Initialize the OpenAI language model and load the necessary tools.

llm = OpenAI(temperature=0)
tool_names = ["serpapi"]
tools = load_tools(tool_names)
import os

Initialize the GPT-3 search agent using the loaded tools and language model.

agent = initialize_agent(tools, llm, agent="zero-shot-react-description")

Use the search agent to perform a search and generate summaries for the search results.

Initialize the OpenAI language model and load the necessary tools.

query = "YOUR_SEARCH_QUERY_HERE"
search_results = agent.get_search_results(query, num_results=10)
for i, result in enumerate(search_results):
print(f"\n\nResult {i+1}:")
print(f"Title: {result.title}")
print(f"Link: {result.link}")
print(f"Summary: {result.summary}")
print(f"Summary generated by GPT-3: {agent.generate_summary(result.summary)}")

Note: You need to have an account with OpenAI and SERP API to obtain the API keys.

License

This script is open-source and licensed under the MIT License. For more details, check the LICENSE file.

About

A gpt chatbot that can search the web using Serp and Wolfram Alpha's api.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published