diff --git a/tabby/server/backend/language_presets.py b/tabby/server/backend/language_presets.py index 04fa844..1e25fa0 100644 --- a/tabby/server/backend/language_presets.py +++ b/tabby/server/backend/language_presets.py @@ -1,3 +1,4 @@ +from collections import defaultdict from typing import List from pydantic import BaseModel, Field @@ -10,28 +11,43 @@ class LanguagePreset(BaseModel): stop_words: List[str] -LanguagePresets = { - Language.UNKNOWN: LanguagePreset( - max_length=128, - stop_words=["\n\n"], - ), - Language.PYTHON: LanguagePreset( - max_length=128, - stop_words=["\n\n", "\ndef", "\n#", "\nimport", "\nfrom", "\nclass"], - ), - Language.JAVASCRIPT: LanguagePreset( - max_length=128, stop_words=["\n\n", "\nfunction", "\n//", "\nimport", "\nclass"] - ), - Language.TYPESCRIPT: LanguagePreset( - max_length=128, - stop_words=[ - "\n\n", - "\nfunction", - "\n//", - "\nimport", - "\nclass", - "\ninterface", - "\ntype", - ], - ), -} +DEFAULT = LanguagePreset( + max_length=128, + stop_words=["\n\n"], +) + + +LanguagePresets = defaultdict( + lambda: DEFAULT, + [ + ( + Language.PYTHON, + LanguagePreset( + max_length=128, + stop_words=["\n\n", "\ndef", "\n#", "\nimport", "\nfrom", "\nclass"], + ), + ), + ( + Language.JAVASCRIPT, + LanguagePreset( + max_length=128, + stop_words=["\n\n", "\nfunction", "\n//", "\nimport", "\nclass"], + ), + ), + ( + Language.TYPESCRIPT, + LanguagePreset( + max_length=128, + stop_words=[ + "\n\n", + "\nfunction", + "\n//", + "\nimport", + "\nclass", + "\ninterface", + "\ntype", + ], + ), + ), + ], +) diff --git a/tabby/server/models.py b/tabby/server/models.py index 8c68332..e70428c 100644 --- a/tabby/server/models.py +++ b/tabby/server/models.py @@ -12,9 +12,18 @@ class Choice(BaseModel): # https://code.visualstudio.com/docs/languages/identifiers class Language(str, Enum): UNKNOWN = "unknown" - PYTHON = "python" + CLOJURE = "clojure" + CSHARP = "csharp" + CSS = "css" + DOCKERFILE = "dockerfile" + FSHARP = "fsharp" + GO = "go" JAVASCRIPT = "javascript" + JSON = "json" + PHP = "php" + PYTHON = "python" TYPESCRIPT = "typescript" + YAML = "yaml" class CompletionRequest(BaseModel):