Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Conversation

@nattsw
Copy link
Contributor

@nattsw nattsw commented Jun 17, 2025

In #1424, we moved prompts into personas but did not extract examples out of the prompts. This PR corrects that.

Raw req payload after switch indicating compliance:

{"generationConfig"=>
  {"temperature"=>0.3,
   "responseSchema"=>
    {"type"=>"object",
     "properties"=>{"translation"=>{"type"=>"string"}},
     "required"=>["translation"]},
   "responseMimeType"=>"application/json"},
 "safetySettings"=>
  [{"category"=>"HARM_CATEGORY_HARASSMENT", "threshold"=>"BLOCK_NONE"},
   {"category"=>"HARM_CATEGORY_SEXUALLY_EXPLICIT",
    "threshold"=>"BLOCK_NONE"},
   {"category"=>"HARM_CATEGORY_HATE_SPEECH", "threshold"=>"BLOCK_NONE"},
   {"category"=>"HARM_CATEGORY_DANGEROUS_CONTENT",
    "threshold"=>"BLOCK_NONE"}],
 "contents"=>
  [{"role"=>"user",
    "parts"=>
     [{"text"=>
        "{\"content\":\"**Heathrow fechado**: paralisação de voos deve continuar nos próximos dias, diz gestora do aeroporto de *Londres*\",\"target_locale\":\"en\"}"}]},
   {"role"=>"model",
    "parts"=>
     [{"text"=>
        "{\"translation\":\"**Heathrow closed**: flight disruption expected to continue in coming days, says *London* airport management\"}"}]},
   {"role"=>"user",
    "parts"=>
     [{"text"=>
        "{\"content\":\"New Update for Minecraft Adds Underwater Temples\",\"target_locale\":\"es\"}"}]},
   {"role"=>"model",
    "parts"=>
     [{"text"=>
        "{\"translation\":\"Nueva actualización para Minecraft añade templos submarinos\"}"}]},
   {"role"=>"user",
    "parts"=>
     [{"text"=>
        "{\"content\":\"# Machine Learning 101\\n\\nMachine Learning (ML) is a subset of Artificial Intelligence (AI) that focuses on the development of algorithms and statistical models that enable computer systems to improve their performance on a specific task through experience.\\n\\n## Key Concepts\\n\\n1. **Supervised Learning**: The algorithm learns from labeled training data.\\n2. **Unsupervised Learning**: The algorithm finds patterns in unlabeled data.\\n3. **Reinforcement Learning**: The algorithm learns thro
ugh interaction with an environment.\\n\\n```python\\n# Simple example of a
 machine learning model\\nfrom sklearn.model_selection import train_test_sp
lit\\nfrom sklearn.linear_model import LogisticRegression\\n\\n# Assuming X
 and y are your features and target variables\\nX_train, X_test, y_train, y
_test = train_test_split(X, y, test_size=0.2, random_state=42)\\n\\nmodel =
 LogisticRegression()\\nmodel.fit(X_train, y_train)\\n\\n# Evaluate the mod
el\\naccuracy = model.score(X_test, y_test)\\nprint(f'Model accuracy: {accu
racy}')\\n```\\n\\nFor more information, visit [Machine Learning on Wikiped
ia](https://en.wikipedia.org/wiki/Machine_learning).\",\"target_locale\":\"
fr\"}"}]},
   {"role"=>"model",
    "parts"=>
     [{"text"=>
        "{\"translation\":\"# Machine Learning 101\\n\\nLe Machine Learning
 (ML) est un sous-ensemble de l'Intelligence Artificielle (IA) qui se conce
ntre sur le développement d'algorithmes et de modèles statistiques permetta
nt aux systèmes informatiques d'améliorer leurs performances sur une tâche
spécifique grâce à l'expérience.\\n\\n## Concepts clés\\n\\n1. **Apprentiss
age supervisé** : L'algorithme apprend à partir de données d'entraînement é
tiquetées.\\n2. **Apprentissage non supervisé** : L'algorithme trouve des m
otifs dans des données non étiquetées.\\n3. **Apprentissage par renforcemen
t** : L'algorithme apprend à travers l'interaction avec un environnement.\\
n\\n```python\\n# Exemple simple d'un modèle de machine learning\\nfrom skl
earn.model_selection import train_test_split\\nfrom sklearn.linear_model im
port LogisticRegression\\n\\n# En supposant que X et y sont vos variables d
e caractéristiques et cibles\\nX_train, X_test, y_train, y_test = train_tes
t_split(X, y, test_size=0.2, random_state=42)\\n\\nmodel = LogisticRegressi
on()\\nmodel.fit(X_train, y_train)\\n\\n# Évaluer le modèle\\naccuracy = mo
del.score(X_test, y_test)\\nprint(f'Model accuracy: {accuracy}')\\n```\\n\\
nPour plus d'informations, visitez [Machine Learning sur Wikipedia](https:/
/en.wikipedia.org/wiki/Machine_learning).\"}"}]},
   {"role"=>"user",
    "parts"=>
     [{"text"=>
        "{\"content\":\"このトピックでは、「本能寺の変」の裏に隠された真実
と、信長の最後の瞬間に迫るフィクションストーリーを皆さんと一緒に紐解いてい
きます。\",\"target_locale\":\"en\"}"}]}],
 "systemInstruction"=>
  {"role"=>"system",
   "parts"=>
    [{"text"=>
       "You are a highly skilled translator tasked with translating content
 from one language to another. Your goal is to provide accurate and context
ually appropriate translations while preserving the original structure and
formatting of the content. Follow these instructions carefully:\n\n1. Trans
late the content accurately while preserving any Markdown, HTML elements, o
r newlines.\n2. Maintain the original document structure including headings
, lists, tables, code blocks, etc.\n3. Preserve all links, images, and othe
r media references without translation.\n4. Handle code snippets appropriat
ely:\n  - Do not translate variable names, functions, or syntax within code
 blocks (```).\n  - Translate comments within code blocks.\n5. For technica
l terminology:\n  - Provide the accepted target language term if it exists.
\n  - If no equivalent exists, transliterate the term and include the origi
nal term in parentheses.\n6. For ambiguous terms or phrases, choose the mos
t contextually appropriate translation.\n7. Do not add any content besides
the translation.\n8. Ensure the translation only contains the original lang
uage and the target language.\n\nThe text to translate will be provided in
JSON format with the following structure:\n{\"content\": \"Text to translat
e\", \"target_locale\": \"Target language code\"}\n\nOutput your translatio
n in the following JSON format:\n{\"translation\": \"Your translated text h
ere\"}\n\nYou are being consumed via an API. Only return the translated tex
t in the specified JSON format. Do not include any additional information o
r explanations."}]}}

@nattsw nattsw merged commit df925f8 into main Jun 17, 2025
6 checks passed
@nattsw nattsw deleted the examples branch June 17, 2025 08:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants