We're excited to announce the launch of our first free and open-source ChatGPT plugin that serves a useful purpose!
This plugin is designed for counting characters and words in a given text.
ChatGPT's base model isn't always great at accurately counting characters and words, so we created this plugin to address that need.
- Check the word count of your essays or articles.
- Verify the character count of your tweets to ensure they fit within the limit.
- Use this plugin as a template to create your own ChatGPT plugins.
-
Navigate to the root directory of the Word Counter API.
-
Create a virtual environment:
python -m venv venv
or
python3 -m venv venv
-
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
- On Windows:
-
Install the required packages:
pip install -r requirements.txt
-
Run the FastAPI application:
uvicorn server:app --reload
The application will be accessible at "http://localhost:8000/".
The Word Counter API is a FastAPI application that serves as a ChatGPT plugin. It provides an endpoint /count
that counts characters and words in a given text when accessed.
The main code for the application is in the server.py
file. Here's a snippet of the code that defines the /count
endpoint:
@app.post("/count")
def count_characters_and_words(data: TextData):
text = data.text
character_count = len(text)
word_count = len(text.split())
return {
"character_count": character_count,
"word_count": word_count
}
When a user accesses the /count
endpoint and provides text data, the application returns a JSON response containing the character count and word count.
To set up the Word Counter API as a ChatGPT plugin, follow these steps:
-
Go to the "Develop your own plugin" section of the ChatGPT API documentation.
-
Input the localhost URL of the Word Counter API (e.g., "http://localhost:8000/") to set it up as a plugin.
-
Once the plugin is set up, you can interact with it through ChatGPT. For example, you can send the message "count characters and words in 'Hello, world!'" to ChatGPT, and it will return the character count and word count provided by the Word Counter API.
ssh -R 80:localhost:8000 localhost.run