Open
Description
In Doccano's custom REST API export feature, template variables are not being processed and replaced with actual values.
How to Reproduce:
- Create a new project in Doccano
- Configure a custom REST API export with the following configuration:
{
"url": "http://127.0.0.1:5000/",
"body": {"text": "{{ text }}", "label": "{{ labels[0].name }}"},
"method": "POST",
"params": {},
"headers": {}
}
- Expose an API endpoint on the url stated. I have used a simple flask api:
from flask import Flask, request
app = Flask(__name__)
@app.route("/", methods=["POST"])
def predict():
print(request.get_json())
return {"label": "NEG"}
- Import a document, for simplicity, I have set the document's text field to 'test text 1234'
- Set the auto-label filter on, in the front end of doccano, and click next on the document to call the api. The document becomes auto-labelled with "NEG" as expected.
- Observe, in your IDE, that the incoming JSON to the API contains literal template strings instead of processed values:
{'text': 'test text 1234', 'label': '{{ labels[0].name }}'}
127.0.0.1 - - [18/Nov/2024 17:38:07] "POST / HTTP/1.1" 200 -
The same result happens when I modify the request attrs as a guess at the 'label' property to either of the following as well: "label": "{{ label }}", "label": "{{ labels[0] }}", or even "status": "{{ status }}".
This is confusing since {{ text }} is being replaced with the actual document text, but not for any of the other properties you would expect to be supported within the request body.
Project Type: Text Classification
Task Type: Category
API: Local Flask server
- Operating System: Ubuntu 24.04.1 LTS
- Python Version Used: 3.9.20
- When you install doccano: 13/11/2024
- How did you install doccano (Heroku button etc): pip install doccano
Metadata
Assignees
Labels
No labels
Activity