{"openapi":"3.1.0","info":{"title":"Babelbird for ThinkOwl","description":"<CENTER><img src=\"/static/babelbird-service.png\"></CENTER><BR>A service for detecting language and translation.<BR><B>If the little language model is deployed for CPU development, the only source language is English!</B>","contact":{"url":"http://www.thinkowl.com/"},"license":{"name":"ThinkOwl Usage License","url":"http://www.thinkowl.com/"},"version":"v1"},"paths":{"/metrics":{"get":{"summary":"Combined Metrics","description":"Expose combined metrics from the local instrumentator and the external server.","operationId":"combined_metrics_metrics_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/v1/translate/":{"post":{"summary":"Translate","description":"Translate a given text to a specified target language, sentence by sentence cache-aware.\n\nAlgorithm Details:\n1. **Source and Target Language Determination**:\n    - If the source language is not provided, it is detected from the input text.\n    - The target language is resolved from the provided language name or code.\n    - If either cannot be determined, an HTTP 422 error is raised.\n\n2. **Sentence Splitting**:\n    - The input text is split naively into sentences using a regular expression that detects sentence-ending punctuation ('.', '!', '?').\n    - Any trailing text without punctuation is also included as a sentence.\n\n3. **Cache Lookup**:\n    - For each sentence, the function checks if a cached translation exists for the (sentence, source language, target language) tuple.\n    - If all sentences are found in the cache, their translations are concatenated and returned immediately (cache hit).\n    - If any sentence is missing from the cache, the process continues (cache miss).\n\n4. **Authentication**:\n    - The endpoint requires a valid HTTP Bearer token. If not provided, an HTTP 401 error is raised.\n    - The tenant is extracted from the token for use in external translation requests.\n\n5. **Translation**:\n    - An API key is retrieved for the tenant and desk.\n        - The external translation service is called with the full input text.\n\n    - If translation fails, an HTTP 422 error is raised.\n\n6. **Post-Processing and Caching**:\n    - The translated text is split into sentences using the same logic as for the source text.\n    - If the number of translated sentences matches the number of source sentences, each (source, translated) sentence pair is added to the cache for future requests.\n    - If the counts do not match, caching is skipped and a warning is logged.\n\n7. **Response**:\n    - The translated text is returned as a plain text response.","operationId":"translate_v1_translate__post","security":[{"HTTPBearer":[]}],"parameters":[{"name":"desk","in":"query","required":true,"schema":{"type":"string","description":"The desk to use for the translation","title":"Desk"},"description":"The desk to use for the translation"},{"name":"source","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The source language code (optional). If not provided, language detection will be used.","enum":["Afrikaans","Albanian","Amharic","Arabic","Armenian","Asturian","Azerbaijani","Bashkir","Belarusian","Bengali","Bosnian","Bulgarian","Burmese","Catalan","Cebuano","Central Khmer","Chinese","Croatian","Czech","Danish","Dutch","English","Estonian","Finnish","French","Galician","Ganda","Georgian","German","Greek","Gujarati","Hausa","Hebrew","Hindi","Hungarian","Icelandic","Igbo","Iloko","Indonesian","Irish","Italian","Japanese","Javanese","Kannada","Kazakh","Korean","Lao","Latvian","Lingala","Lithuanian","Luxembourgish","Macedonian","Malagasy","Malay","Malayalam","Marathi","Mongolian","Nepali","Northern Sotho","Norwegian","Occitan","Persian","Polish","Portuguese","Romanian","Russian","Scottish Gaelic","Serbian","Sindhi","Sinhala","Slovak","Slovenian","Somali","Spanish","Sundanese","Swahili","Swati","Swedish","Tagalog","Tamil","Thai","Tswana","Turkish","Ukrainian","Urdu","Uzbek","Vietnamese","Welsh","Wolof","Xhosa","Yiddish","Yoruba","Zulu"],"title":"Source"},"description":"The source language code (optional). If not provided, language detection will be used."},{"name":"language","in":"query","required":false,"schema":{"type":"string","description":"The target language for translation.","enum":["Afrikaans","Albanian","Amharic","Arabic","Armenian","Asturian","Azerbaijani","Bashkir","Belarusian","Bengali","Bosnian","Bulgarian","Burmese","Catalan","Cebuano","Central Khmer","Chinese","Croatian","Czech","Danish","Dutch","English","Estonian","Finnish","French","Galician","Ganda","Georgian","German","Greek","Gujarati","Hausa","Hebrew","Hindi","Hungarian","Icelandic","Igbo","Iloko","Indonesian","Irish","Italian","Japanese","Javanese","Kannada","Kazakh","Korean","Lao","Latvian","Lingala","Lithuanian","Luxembourgish","Macedonian","Malagasy","Malay","Malayalam","Marathi","Mongolian","Nepali","Northern Sotho","Norwegian","Occitan","Persian","Polish","Portuguese","Romanian","Russian","Scottish Gaelic","Serbian","Sindhi","Sinhala","Slovak","Slovenian","Somali","Spanish","Sundanese","Swahili","Swati","Swedish","Tagalog","Tamil","Thai","Tswana","Turkish","Ukrainian","Urdu","Uzbek","Vietnamese","Welsh","Wolof","Xhosa","Yiddish","Yoruba","Zulu"],"default":"German","title":"Language"},"description":"The target language for translation."}],"requestBody":{"required":true,"content":{"text/plain":{"schema":{"type":"string","title":"Src Text"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/detect/":{"post":{"summary":"Detect","description":"Detect the language of a given text.\n\nThis endpoint receives plain text and returns a JSON structure with the detected language label, FLORES-200 code, and ISO code. If the input is empty or detection fails,\nthe result will indicate \"Unknown\" for all fields.\n\nParameters:\n    body (str): The input text to analyze (plain text, in the request body).\n\nReturns:\n    language_detection.DetectionResult: An object containing the detected language label, FLORES-200 code, and ISO code.","operationId":"detect_v1_detect__post","requestBody":{"content":{"text/plain":{"schema":{"type":"string","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DetectionResult"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"DetectionResult":{"properties":{"label":{"type":"string","title":"Label"},"flores":{"type":"string","title":"Flores"},"iso":{"type":"string","title":"Iso"}},"type":"object","required":["label","flores","iso"],"title":"DetectionResult","description":"A model representing the result of a language detection process.\n\nAttributes:\n    label (str): The label or name of the detected language like \"german\", \"english\" and alike.\n    flores (str): The flores value associated with the detection.\n    iso (str): The ISO code related to the detection."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"HTTPBearer":{"type":"http","scheme":"bearer"}}}}