Skip to content

(cli) Translator notes/hints are not included when not using lingo.dev provider #1728

@thomasaull

Description

@thomasaull

What's happening?

When using a provider other than lingo.dev, even when using one of the supported buckets translator notes/hints are not sent along with the translation request to the model.

Exact Reproduction Steps

Check the source where the request is created:

const payload = {
  sourceLocale: input.sourceLocale,
  targetLocale: input.targetLocale,
  data: input.processableData,
};

const response = await generateText({
  model,
  ...params.settings,
  messages: [
    { role: "system", content: systemPrompt },
    { role: "user", content: "OK" },
    ...shots.flatMap(
      ([userShot, assistantShot]) =>
        [
          { role: "user", content: JSON.stringify(userShot) },
          { role: "assistant", content: JSON.stringify(assistantShot) },
        ] as Message[],
    ),
    { role: "user", content: JSON.stringify(payload) },
  ],
});

Expected

Hints should be included in the request, so the model can take the additional context into consideration when translating the value

The code could look something like this:

const hasHints = input.hints && Object.keys(input.hints).length > 0;

const payload = {
  sourceLocale: input.sourceLocale,
  targetLocale: input.targetLocale,
  data: input.processableData,
  ...(hasHints && { hints: input.hints }),
};

Actual

Hints are not included in the request, the model does not have any additional context

Screenshots/Videos

Please check source, it’s rather obvious there

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions