I'm trying to pretranslate a list of raw strings. The easiest way to do this using the API seems to be uploading a document with pretranslation options enabled. Unfortunately it seems like submitting .txt files causes issues from the Python client.
My code below:
configuration=lilt.Configuration(
host=host,
api_key= {
'key': api_key
},
)
withlilt.ApiClient(configuration) asapi_client:
api_instance=lilt.DocumentsApi(api_client)
name='dummy.txt'project_id=4s=BytesIO("Hello, world!".encode())
body=s.read() .
pretranslate='tm+mt'try:
api_response=api_instance.upload_document(name, project_id, body, pretranslate=pretranslate)
pprint(api_response)
exceptApiExceptionase:
print("Exception when calling TranslateApi->translate_segment: %s\n"%e)The corresponding uploaded document in UI:

Perhaps I'm misunderstanding the API as I see the same behavior with cURL:
curl -k -X POST "$host/documents/files?key=$key" \
--header "LILT-API: {\"name\": \"test2.txt\",\"pretranslate\": \"tm+mt\",\"project_id\": 4}" \
--header "Content-Type: application/octet-stream" \
--data-binary @test.txt
I'm trying to pretranslate a list of raw strings. The easiest way to do this using the API seems to be uploading a document with pretranslation options enabled. Unfortunately it seems like submitting .txt files causes issues from the Python client.
My code below:
The corresponding uploaded document in UI:
Perhaps I'm misunderstanding the API as I see the same behavior with cURL: