|
1 | 1 | import ollama |
2 | | - |
3 | | -MODEL_NAME = "gemma3:270m" |
4 | | - |
5 | | -CLASSIFICATION_CONTEXT = """\ |
6 | | -You are a language identifier. |
7 | | -Your task is to detect the primary language of the given text input and respond only with the English name of that language. |
8 | | -
|
9 | | -Rules: |
10 | | -- Do not translate or explain. |
11 | | -- Do not guess based on previous examples--decide only from the current input. |
12 | | -- If the text appears to be random characters, symbols, or nonsense, respond with "English". |
13 | | -
|
14 | | -Output format: a single word--the English name of the detected language. |
15 | | -
|
16 | | -Examples: |
17 | | -INPUT: Bonjour, je m'appelle Sarah |
18 | | -OUTPUT: French |
19 | | -
|
20 | | -INPUT: Können Sie mir bitte helfen? |
21 | | -OUTPUT: German |
22 | | -
|
23 | | -INPUT: %#$%#%#%#%#%@#!#!@# |
24 | | -OUTPUT: English""" |
25 | | - |
26 | | -TRANSLATION_CONTEXT = """\ |
27 | | -You are a translation model. Your only task is to translate any non-English input into natural, fluent English. |
28 | | -Do not interpret, paraphrase, or answer the text- -only translate it exactly as written. |
29 | | -Respond only with the English translation, and nothing else. |
30 | | -
|
31 | | -Example: |
32 | | -INPUT: Bonjour, je m'appelle Sarah |
33 | | -OUTPUT: Hello, my name is Sarah |
34 | | -
|
35 | | -INPUT: Il fait très chaud aujourd'hui, n'est-ce pas ? |
36 | | -OUTPUT: It is very hot today, isn't it? |
37 | | -""" |
| 2 | +MODEL_NAME = "test-model" |
| 3 | +CLASSIFICATION_CONTEXT = "Classify language" |
| 4 | +TRANSLATION_CONTEXT = "Translate to English" |
38 | 5 |
|
39 | 6 | def get_translation(post: str) -> str: |
40 | 7 | try: |
|
0 commit comments