|
| 1 | +class Localization::GlossaryEntryProposal::VerifyWithLLM |
| 2 | + include Mandate |
| 3 | + |
| 4 | + initialize_with :proposal |
| 5 | + |
| 6 | + def call |
| 7 | + LLM::ExecGeminiFlash.(prompt, endpoint) |
| 8 | + end |
| 9 | + |
| 10 | + def endpoint |
| 11 | + "localization_verify_glossary_entry_proposal?proposal_uuid=#{proposal.uuid}" |
| 12 | + end |
| 13 | + |
| 14 | + def prompt |
| 15 | + <<~PROMPT |
| 16 | + You are a localization expert.#{' '} |
| 17 | + Your task is to verify the quality of a glossary entry proposal. |
| 18 | + This glossary entry will be sent to future LLM translators when doing translation work. |
| 19 | +
|
| 20 | + The proposal has three parts: |
| 21 | + - A term in English |
| 22 | + - A proposed translation of that term into the target language |
| 23 | + - Proposed instructions on how the term should be used by the LLM translator in the future |
| 24 | +
|
| 25 | + Respond with JSON containing two fields: |
| 26 | + - `result`: "approved", "rejected" or "spam" based on the quality of the glossary entry. |
| 27 | + - `reason`: A brief explanation of your decision. |
| 28 | +
|
| 29 | + You should use "approved" if the glossary entry is generally accurate and appropriate for the given context. |
| 30 | + You should use "rejected" if the glossary entry has issues such as inaccuracies, poor phrasing, or is not suitable for the context. |
| 31 | + You should use "spam" if the glossary entry is a serious step away from the intended purpose. For example, if it is trying to inject spam onto the website, or contains profanity etc. Use this with care as it will automatically block the user that proposed the change. |
| 32 | +
|
| 33 | + The target locale is `#{proposal.locale}` |
| 34 | +
|
| 35 | + The original glossary term was: |
| 36 | + ~~~~~~ |
| 37 | + #{proposal.term} |
| 38 | + ~~~~~~ |
| 39 | +
|
| 40 | + This is information about how it's used: |
| 41 | + ~~~~~~ |
| 42 | + #{proposal.llm_instructions} |
| 43 | + ~~~~~~ |
| 44 | +
|
| 45 | + The proposed glossary entry is: |
| 46 | + ~~~~~~ |
| 47 | + #{proposal.translation} |
| 48 | + ~~~~~~ |
| 49 | +
|
| 50 | + Respond with JSON. |
| 51 | + PROMPT |
| 52 | + end |
| 53 | +end |
0 commit comments