Update app.py
Browse files
app.py
CHANGED
@@ -51,26 +51,25 @@ model = genai.GenerativeModel(
|
|
51 |
system_instruction="Act as a language model trained on a specific style of writing that incorporates both Roman and Devanagari script",
|
52 |
)
|
53 |
|
54 |
-
transliteration_example_file = upload_to_gemini(
|
55 |
-
"ai_exp_json.txt", mime_type="text/plain"
|
56 |
-
)
|
57 |
-
|
58 |
-
chat_session = model.start_chat(
|
59 |
-
history=[
|
60 |
-
{
|
61 |
-
"role": "user",
|
62 |
-
"parts": [
|
63 |
-
"Given a sentence in Roman written English and a set of pre-defined patterns, transliterate only specific words to Devanagari script while maintaining a desired ratio between Roman and Devanagari words. Your task is to transliterate only a subset of words while maintaining the overall meaning and sentence structure.\n",
|
64 |
-
'Based on a provided English sentence and a desired transliteration ratio, use your knowledge of this unique style to select words for transliteration that enhance the overall message and aesthetic. I will provide you with training examples to understand the preferred approach.\nGo through the examples in the file in following JSON format: [{"English": xxx, "Transliteration"}]." and Develop a system that can intelligently choose which English words to transliterate into Devanagari in a sentence, aiming for a specific ratio between the two scripts. With the help of examples in Json format file, design a system that can learn the optimal ratio and transliteration pattern.',
|
65 |
-
transliteration_example_file,
|
66 |
-
],
|
67 |
-
},
|
68 |
-
]
|
69 |
-
)
|
70 |
-
|
71 |
|
72 |
def generate_transliteration_gemini_15_pro(text):
|
73 |
texts = [text]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
response = chat_session.send_message(
|
75 |
'Given an English sentences: \n```' + "\n".join(texts) + '\n```\nTransliterate English sentences into a mix of Roman and Devanagari script, following a predefined pattern or learning from provided examples above without explain anything.\nReturn output in JSON in following format for the list of sentences: {"text": xxx, "transliterate": xxx}'
|
76 |
)
|
|
|
51 |
system_instruction="Act as a language model trained on a specific style of writing that incorporates both Roman and Devanagari script",
|
52 |
)
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
def generate_transliteration_gemini_15_pro(text):
|
56 |
texts = [text]
|
57 |
+
transliteration_example_file = upload_to_gemini(
|
58 |
+
"ai_exp_json.txt", mime_type="text/plain"
|
59 |
+
)
|
60 |
+
|
61 |
+
chat_session = model.start_chat(
|
62 |
+
history=[
|
63 |
+
{
|
64 |
+
"role": "user",
|
65 |
+
"parts": [
|
66 |
+
"Given a sentence in Roman written English and a set of pre-defined patterns, transliterate only specific words to Devanagari script while maintaining a desired ratio between Roman and Devanagari words. Your task is to transliterate only a subset of words while maintaining the overall meaning and sentence structure.\n",
|
67 |
+
'Based on a provided English sentence and a desired transliteration ratio, use your knowledge of this unique style to select words for transliteration that enhance the overall message and aesthetic. I will provide you with training examples to understand the preferred approach.\nGo through the examples in the file in following JSON format: [{"English": xxx, "Transliteration"}]." and Develop a system that can intelligently choose which English words to transliterate into Devanagari in a sentence, aiming for a specific ratio between the two scripts. With the help of examples in Json format file, design a system that can learn the optimal ratio and transliteration pattern.',
|
68 |
+
transliteration_example_file,
|
69 |
+
],
|
70 |
+
},
|
71 |
+
]
|
72 |
+
)
|
73 |
response = chat_session.send_message(
|
74 |
'Given an English sentences: \n```' + "\n".join(texts) + '\n```\nTransliterate English sentences into a mix of Roman and Devanagari script, following a predefined pattern or learning from provided examples above without explain anything.\nReturn output in JSON in following format for the list of sentences: {"text": xxx, "transliterate": xxx}'
|
75 |
)
|