WordCounterGPT banner
ykdojo ykdojo

WordCounterGPT

Development community

Description

A ChatGPT plugin for precise character and word counting

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

Word Counter API

We're excited to announce the launch of our first free and open-source ChatGPT plugin that serves a useful purpose!

What Does It Do?

This plugin is designed for counting characters and words in a given text.

Why Create This Plugin?

ChatGPT's base model isn't always great at accurately counting characters and words, so we created this plugin to address that need.

Use Cases

  • 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.

Setup and Run

  1. Navigate to the root directory of the Word Counter API.

  2. Create a virtual environment:

    python -m venv venv

    or

    python3 -m venv venv
  3. Activate the virtual environment:

    • On Windows:
      venv\Scripts\activate
    • On macOS/Linux:
      source venv/bin/activate
  4. Install the required packages:

    pip install -r requirements.txt
  5. Run the FastAPI application:

    uvicorn server:app --reload

The application will be accessible at "http://localhost:8000/".

How It Works

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.

Setting Up the Plugin with ChatGPT

To set up the Word