Sontran0108
Add API endpoints for external inference calls
31a1d92

A newer version of the Gradio SDK is available: 6.12.0

Upgrade
metadata
title: CoEdIT Handler
emoji: ✏️
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 4.0.0
app_file: app.py
pinned: false
license: cc-by-nc-4.0
short_description: Custom handler for Grammarly CoEdIT model

CoEdIT Handler

This is a custom handler for the Grammarly CoEdIT model, providing grammar correction and text enhancement capabilities.

Features

  • Grammar correction
  • Text coherence improvement
  • Text simplification
  • Paraphrasing
  • Formal/informal style conversion
  • Neutral tone conversion

API Usage

The Space provides multiple REST API endpoints:

Main Inference Endpoint

curl -X POST "https://sxtran-grammar-corrector-app.hf.space/predict" \
     -H "Content-Type: application/json" \
     -d '{
       "inputs": ["Fix the grammar: When I grow up, I start to understand what he said is quite right."],
       "parameters": {
         "num_return_sequences": 1,
         "temperature": 1.0
       }
     }'

Health Check

curl -X GET "https://sxtran-grammar-corrector-app.hf.space/health"

API Information

curl -X GET "https://sxtran-grammar-corrector-app.hf.space/info"

Python Example

import requests

# API endpoint
url = "https://sxtran-grammar-corrector-app.hf.space/predict"

# Request data
data = {
    "inputs": ["Fix the grammar: When I grow up, I start to understand what he said is quite right."],
    "parameters": {
        "num_return_sequences": 1,
        "temperature": 1.0
    }
}

# Make request
response = requests.post(url, json=data)
result = response.json()

print(result)

Response Format

{
  "success": true,
  "results": [
    {
      "original_sentence": "Fix the grammar: When I grow up, I start to understand what he said is quite right.",
      "enhanced_sentence": "When I grow up, I start to understand that what he said is quite right.",
      "changes": [
        {
          "original_phrase": "what he said is quite right",
          "new_phrase": "that what he said is quite right",
          "explanation": "replace change"
        }
      ]
    }
  ]
}

Model

This handler uses the grammarly/coedit-large model.