Git Product home page Git Product logo

toll's Introduction

toll

This microservice takes a string of content and returns the token count using the tiktoken library. It is built using Flask.

Table of Contents

Prerequisites

  • Python 3.x
  • Flask
  • tiktoken
  • Poetry

Installation

  1. Clone the repository:

    git clone https://github.com/haha-systems/toll.git
    cd toll
  2. Install the required packages:

    pip install flask tiktoken poetry
  3. Create a requirements.txt file:

    pip freeze > requirements.txt

Usage

  1. Run the Flask app:

    python main.py
  2. Send a POST request to the /token_count endpoint with the content you want to tokenize. For example, using curl:

    curl -X POST -H "Content-Type: application/json" -d '{"content": "Your content here"}' http://127.0.0.1:4000/token_count

    You should get a JSON response with the token count:

    {
      "token_count": 4
    }

API Endpoints

POST /token_count

  • Description: Returns the token count for the provided content.
  • Request:
    • Headers: Content-Type: application/json
    • Body: JSON object with a content field containing the string to be tokenized.
  • Response:
    • Success: JSON object with a token_count field.
    • Error: JSON object with an error field and an appropriate error message.

Example Request

{
  "content": "Your content here"
}

Example Response

{
  "token_count": 4
}

License

This project is licensed under the MIT License.

toll's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.