Skip to content

Instantly share code, notes, and snippets.

@CodeWithOz
Last active December 19, 2025 10:14
Show Gist options
  • Select an option

  • Save CodeWithOz/28c5165862ce2df83936ffa93c2bbfce to your computer and use it in GitHub Desktop.

Select an option

Save CodeWithOz/28c5165862ce2df83936ffa93c2bbfce to your computer and use it in GitHub Desktop.
Listen Better translation logic
import * as z from 'zod'
const TranslationSchema = z.object({
translatedText: z.string().describe('The translated text'),
verbs: z.array(
z.object({
conjugatedForm: z.string().describe('The verb form as it shows up in the text'),
infinitive: z.string().describe('The infinitive form of the verb'),
meaning: z.string().describe('The meaning of the verb'),
}).describe('A verb used in the text')
).nullable().describe('The verbs used in the text'),
vocabulary: z.array(
z.object({
word: z.string().describe('The word itself'),
meaning: z.string().describe('The meaning of the word'),
}).describe('A word used in the text')
).describe('Notable vocabulary used in the text'),
idiomaticExpressions: z.array(
z.object({
expression: z.string().describe('The idiomatic expression itself'),
literalMeaning: z.string().describe('The literal meaning of the idiomatic expression'),
contextualMeaning: z.string().describe('The meaning of the idiomatic expression in the context of the text'),
}).describe('An idiomatic expression used in the text')
).nullable().describe('Idiomatic expressions used in the text'),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment