šŸŽÆ[How-To] Build a ChatGPT Plugin: AI Web Surfer - A Powerful Plugin That Summarizes Web Content and Enhances Conversational AI Experiences (Open Source Code)

Building a ChatGPT Plugin: AI Web Surfer

Introduction

ChatGPT plugins are a powerful way to extend the capabilities of the ChatGPT language model by integrating external APIs and services. In this blog post, weā€™ll explore how to build a ChatGPT plugin called ā€œAI Surferā€ that allows ChatGPT to surf the internet, summarize articles, and limit token counts using concurrent API connections. Weā€™ll also discuss how to deploy the plugin to Replit for free or to other cloud services.

:star: Built Using My Plugin Creator Bot.

What are ChatGPT Plugins?

ChatGPT plugins are integrations that allow ChatGPT to interact with external APIs, databases, or services. By using plugins, ChatGPT can perform tasks such as fetching data, summarizing articles, translating text, and much more. Plugins are defined using a manifest file (ai-plugin.json) and an OpenAPI specification (specification.yaml) that describe the pluginā€™s metadata, authentication, and API endpoints.

AI Surfer Plugin: Overview

The AI Surfer plugin empowers ChatGPT to ā€œsurfā€ the internet by summarizing the content of web pages provided by users. By inputting a URL, the plugin leverages OpenAIā€™s GPT-3.5 Turbo language model to generate concise and informative summaries of the web pageā€™s content. The pluginā€™s key features and benefits include:

  • Web Content Summarization: The AI Surfer plugin can distill the essential information from articles, blog posts, and other web content, providing users with quick and easy-to-understand summaries.

  • Concurrent API Connections: To efficiently handle long articles and reduce token counts, the plugin uses concurrent API connections to process and summarize different sections of the content simultaneously.

  • Language Model Integration: The plugin integrates with OpenAIā€™s GPT-3.5 Turbo language model, harnessing its natural language processing capabilities to produce high-quality summaries.

  • Adjustability and Flexibility: The plugin is fully adjustable, allowing developers to customize its behavior and output to suit specific use cases.

  • Deployment Options: The AI Surfer plugin can be deployed to various cloud services, including Replit, AWS, Heroku, and more, providing flexibility in hosting and scalability.

By enabling ChatGPT to summarize web content, the AI Surfer plugin enhances the language modelā€™s capabilities, allowing users to quickly access and understand information from across the web.

Full How-to and Code here (:star: star and follow if you like it.)

Join my Reddit

5 Likes

Thinking about adding support for AutoGPT to this plug-inā€¦

2 Likes

Hey, I appreciate all the work youā€™ve done on this and for sharing it. I donā€™t know if this is the right place to ask, or if somewhere else would be better. Iā€™m trying to get the plugin to run in Replit and Iā€™m getting the error:

Traceback (most recent call last): File "main.py", line 9, in <module> import openai # OpenAI's GPT-3 language model library ModuleNotFoundError: No module named 'openai'
I also tried pip installing it and got errors. I upgraded pip and now when I try to pip install I get:

An error occurred during configuration: option use-feature: invalid choice: 'content-addressable-pool' (choose from 'fast-deps', 'truststore', 'no-binary-enable-wheel-cache')

poetry add openai also does not work.

`
TypeError

expected string or bytes-like object

at venv/lib/python3.10/site-packages/poetry/core/utils/helpers.py:27 in canonicalize_name
23ā”‚ canonicalize_regex = re.compile(r"[-]+ā€œ)
24ā”‚
25ā”‚
26ā”‚ def canonicalize_name(name): # type: (str) ā†’ str
ā†’ 27ā”‚ return canonicalize_regex.sub(ā€œ-ā€, name).lower()
28ā”‚
29ā”‚
30ā”‚ def module_name(name): # type: (str) ā†’ str
31ā”‚ return canonicalize_name(name).replace(ā€œ.ā€, "
ā€).replace(ā€œ-ā€, ā€œ_ā€)
`

Look like you didnā€™t install the modules. I should probably update the requirements.txt, pip install module

Try adding the following to the requirements.txt in your replit. You may need to click show hidden files

openai
requests
beautifulsoup4
fastapi
jinja2
spacy
httpx
uvicorn

Ok, Iā€™ll try that, but openai is already in requirements.txt and I can see it in the Replit packages. Hereā€™s whatā€™s in requirements.txt now.

Flask==2.1.1
flask_cors==3.1.1
requests==2.27.1
beautifulsoup4==4.10.0
openai==0.27.0

[Edit]
I tried it, still the same message.

Iā€™ll publish the replit, youā€™ll be able to just fork it. Iā€™ll post here when itā€™s live.

1 Like

Thank you. First time using Replit. Maybe I should look at a tutorial. Should I be able to run it locally? Iā€™m getting an error with that too. I tried:

poetry run python main.py

and got

Traceback (most recent call last): File "/Users/larry/Dev/OpenAI/Surfer/main.py", line 36, in <module> nlp = spacy.load("en_core_web_sm") File "/Users/larry/opt/anaconda3/envs/surfer/lib/python3.10/site-packages/spacy/__init__.py", line 54, in load return util.load_model( File "/Users/larry/opt/anaconda3/envs/surfer/lib/python3.10/site-packages/spacy/util.py", line 449, in load_model raise IOError(Errors.E050.format(name=name)) OSError: [E050] Can't find model 'en_core_web_sm'. It doesn't seem to be a Python package or a valid path to a data directory.

Yeah, you can run it locallly. Youā€™re Still missing the modules, it wonā€™t run if theyā€™re not installed, try upgrading your pip

1 Like

Ok, I see a pyproject.toml and a poetry.lock file, so I assumed that doing a poetry install would take care of installing all the packages locally. Anyway, thatā€™s what I did. The error doesnā€™t tell me thereā€™s a package missing. It says it canā€™t find the model file. I assume by missing modules you mean packages? What am I not understanding here?

[Edit]
I can see that the model file itā€™s complaining about is here:

./venv/lib/python3.10/site-packages/en_core_web_sm

But when I put that path in, it still complains that it canā€™t find it.

python -m spacy download en_core_web_sm

I used this module so you could plug-in other LLMs easily.

1 Like

Ok, I see, Iā€™m missing models. Iā€™ll try that, thanks.

Ok, I installed as a plugin. I had to change a couple addresses in ai-plugin.json, but it works! Finally. Sorry for all the hassle getting it going. Thanks for helping me though it! Works great!

Yes, thatā€™s really awesome. Iā€™ll be using it. But this taught me a lot about building a bit more complex plugin than the one for Todos, and how to incorporate other LLMs in the process. Itā€™s a great tutorial/example to help people get started.

For anyone else struggling to get it working, as I was, it was mostly my fault because as I said above, Iā€™d never used replit, hereā€™s some things to look out for:

  1. First, as we discovered above, the model en_core_web_sm was missing, which you can get with: python -m spacy download en_core_web_sm.

  2. In the `ai-plugin.jsonā€™ manifest file thereā€™s two places where the domain is used, one to tell it where the openapi.yaml file is, and one to tell it where logo url is. Without the openai.yaml file location the plugin wonā€™t install. I replaced them manually, but I believe the DOMAIN environment variable will do that for you if you supply a value. Iā€™ll have to try that.

  3. There also may have been a couple requirements missing, hereā€™s what should have been in the requirements.txt file:

openai
requests
beautifulsoup4
fastapi
jinja2
spacy
httpx
uvicorn
  1. I was also stuck on the fact that the output doesnā€™t show on the summary page, but if you install the plugin and test it, you get a summary from ChatGPT.

As far as replit goes, I dragged a folder from my local machine and dumped it on the replit file folder which cause me all kinds of headaches. Also I tried to use poetry in replit instead of using pip install -r requirements.txt

That made it work and I learned a few things. Ruvā€™s repo deserves some stars.

thank you bing chat for pointing me here - a great loop in action - and thanks @ruv for sharing. interestingly, it took several prompts to point here

1 Like

Thanks bing!

(Additional 25 characters)

1 Like

Hi @ruv a quick message to say a big thank you for your work. you are a genius! love this openai-api-plugin :pray:

I think the OpenAi api plug-in might be my best one yet. Itā€™s crazy useful when used with other plugins.

1 Like

I called it " the mother of all plugins" : Vincent Sider on LinkedIn: GitHub - ruvnet/chatgpt-openai-api-plugin: A powerful ChatGPT plugin thatā€¦

1 Like