forked from theopenconversationkit/tock
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/1606-Deepl-integration-new' into 'sncf-master'
theopenconversationkit#1606 Add Deepl translator module - second set of corrections See merge request factory-ia/bots/tock!3
- Loading branch information
Showing
4 changed files
with
58 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,45 @@ | ||
Module for translation with Deepl | ||
# TOCK Deepl Translation | ||
|
||
Here are the configurable variables: | ||
|
||
- tock_translator_deepl_target_languages : set of supported languages - ex : en,es | ||
- tock_translator_deepl_api_url : Deepl api url (default pro api url : https://api.deepl.com/v2/translate). | ||
- `tock_translator_deepl_target_languages`: set of supported languages - ex : en,es | ||
- `tock_translator_deepl_api_url`: Deepl api url (default pro api url : https://api.deepl.com/v2/translate). | ||
If you have problems with pro api, you can use free api : https://api-free.deepl.com/v2/translate | ||
- tock_translator_deepl_api_key : Deepl api key to use (see your account) | ||
- tock_translator_deepl_glossaryId: glossary identifier to use in translation | ||
- `tock_translator_deepl_api_key` : Deepl api key to use (see your account) | ||
- `tock_translator_deepl_glossary_id`: glossary identifier to use in translation | ||
|
||
Deepl documentation: https://developers.deepl.com/docs | ||
> Deepl documentation: https://developers.deepl.com/docs | ||
To integrate the module into a custom Tock Admin, pass the module as a parameter to the ai.tock.nlp.admin.startAdminServer() function. | ||
To integrate the module into a custom Tock Admin, pass the module as a parameter to the `ai.tock.nlp.admin.startAdminServer()` function. | ||
|
||
Example: | ||
|
||
```kt | ||
package ai.tock.bot.admin | ||
|
||
import ai.tock.nlp.admin.startAdminServer | ||
import ai.tock.translator.deepl.deeplTranslatorModule | ||
|
||
fun main() { | ||
startAdminServer(deeplTranslatorModule) | ||
} | ||
startAdminServer(deeplTranslatorModule()) | ||
} | ||
``` | ||
|
||
## Http Client Configuration | ||
|
||
You can configure the Deepl client, including proxy settings, by passing a parameter to `deeplTranslatorModule`: | ||
|
||
```kt | ||
startAdminServer(deeplTranslatorModule(OkHttpDeeplClient { | ||
proxyAuthenticator { _: Route?, response: Response -> | ||
// https://square.github.io/okhttp/3.x/okhttp/index.html?okhttp3/Authenticator.html | ||
if (response.challenges().any { it.scheme.equals("OkHttp-Preemptive", ignoreCase = true) }) { | ||
response.request.newBuilder() | ||
.header("Proxy-Authorization", credential) | ||
.build() | ||
} else { | ||
null | ||
} | ||
} | ||
})) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters