REST API to split text into chunks of specified maximum tokens.
654
This Docker image provides a REST API for chunking a given text into pieces of a specified size. It is built using Go, with the prose library for natural language processing and gorilla/mux for routing.
docker pull rbehzadan/text-chunking-api:latest
docker run -d -p 8080:8080 rbehzadan/text-chunking-api
To run the server on a different port, set the PORT environment variable:
docker run -d -p 9090:9090 -e PORT=9090 rbehzadan/text-chunking-api
POST /chunkRequest Body:
{
"text": "Your text here.",
"max_tokens": 50
}
Response:
{
"chunks": ["Chunk 1", "Chunk 2", ...]
}
Error Responses:
400 Bad Request for invalid request payload or non-positive max_tokens.500 Internal Server Error for errors during text processing.curl -X POST http://localhost:8080/chunk -H "Content-Type: application/json" -d '{"text": "Your text here.", "max_tokens": 50}'
{
"chunks": [
"Your chunked text here."
]
}
PORT: Port on which the server will run (default is 8080).git checkout -b feature-branch).git commit -m 'Add new feature').git push origin feature-branch).This project is licensed under the MIT License. See the LICENSE file for details.
Content type
Image
Digest
sha256:a7ca1c484…
Size
12.3 MB
Last updated
about 2 years ago
docker pull rbehzadan/text-chunking-api