This file contains hidden or 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
| { | |
| "transfer": { | |
| "properties": { | |
| "transfer_type_of_transportation": { | |
| "type": "string", | |
| "description": "if it is car or aircraft or ship" | |
| }, | |
| "transfer_person_name": { "type": "string" }, | |
| "transfer_departure_from_location": { "type": "string" }, | |
| "transfer_arrival_to_location": { "type": "string" }, |
This file contains hidden or 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
| import { Api, Function, StackContext, use } from "sst/constructs"; | |
| import { Translations } from "./Translations"; | |
| export function API({ stack }: StackContext) { | |
| const { translationFn, translationFns } = use(Translations); | |
| const staticTranslationLambdas: Record<string, { function: Function }> = Object.fromEntries( | |
| translationFns.map(({ key, fn }) => [`POST /api/translate/${key}`, { function: fn }]) | |
| ); |
This file contains hidden or 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
| import { StackContext, Function, Stack } from "sst/constructs"; | |
| const LANGUAGE_PAIRS = [ | |
| ["es", "en"], | |
| ["pl", "en"], | |
| ] as const; | |
| interface UnidirectionalTranslation { | |
| from: string; | |
| to: string; | |
| } |
This file contains hidden or 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
| from easynmt import EasyNMT | |
| import json | |
| import os | |
| def main(event, context): | |
| source_lang = os.environ.get("FROM_LANGUAGE_CODE") | |
| target_lang = os.environ.get("TO_LANGUAGE_CODE") | |
| try: | |
| body_dict = json.loads(event.get("body", "{}")) |
This file contains hidden or 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
| FROM alpine:latest AS model | |
| ARG LANGUAGE_CODE_PAIR | |
| ENV LANGUAGE_CODE_PAIR=$LANGUAGE_CODE_PAIR | |
| RUN test -n "$LANGUAGE_CODE_PAIR" || (echo "ERROR: LANGUAGE_CODE_PAIR is empty!" && exit 1) | |
| RUN apk update && apk add --no-cache curl git git-lfs | |
| RUN git lfs install | |
| RUN git clone https://huggingface.co/Helsinki-NLP/opus-mt-${LANGUAGE_CODE_PAIR} /tmp/models |
This file contains hidden or 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
| import { SSTConfig } from "sst"; | |
| import { Translations } from "./stacks/Translations"; | |
| import { API } from "./stacks/Api"; | |
| export default { | |
| config(_input) { | |
| return { | |
| name: "easynmt-opus-translation", | |
| region: "eu-west-1", | |
| }; |
This file contains hidden or 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
| import { Api, StackContext, use } from "sst/constructs"; | |
| import { Translations } from "./Translations"; | |
| export function API({ stack }: StackContext) { | |
| const { translationFn } = use(Translations); | |
| new Api(stack, "translation-api", { | |
| routes: { | |
| "POST /api/translate/{languageCode}": { | |
| cdk: { |
This file contains hidden or 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
| import { StackContext, Function } from "sst/constructs"; | |
| export function Translations({ stack }: StackContext) { | |
| const translationFn = new Function(stack, "TranslationLambda", { | |
| runtime: "container", | |
| handler: "packages/functions/src/translation", | |
| memorySize: 6000, | |
| diskSize: 1024, | |
| timeout: "10 minutes", | |
| }); |
This file contains hidden or 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
| import { StackContext, Function, Stack } from "sst/constructs"; | |
| const LANGUAGE_PAIRS = [ | |
| ["es", "en"], | |
| ["pl", "en"], | |
| ] as const; | |
| interface UnidirectionalTranslation { | |
| from: string; | |
| to: string; | |
| } |
This file contains hidden or 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
| from easynmt import EasyNMT | |
| import json | |
| def main(event, context): | |
| path_params = event.get("pathParameters", {}) | |
| try: | |
| body_dict = json.loads(event.get("body", "{}")) | |
| except json.JSONDecodeError as e: | |
| print(f"Error parsing body JSON: {e}") |
NewerOlder