janus.converter.translate#

Attributes#

log

Classes#

Translator

A class that translates code from one programming language to another.

Module Contents#

janus.converter.translate.log#
class janus.converter.translate.Translator(target_language='python', target_version='3.10', **kwargs)#

Bases: janus.converter.converter.Converter

A class that translates code from one programming language to another.

Initialize a Translator instance.

Parameters:
  • model – The LLM to use for translation. If an OpenAI model, the OPENAI_API_KEY environment variable must be set and the OPENAI_ORG_ID environment variable should be set if needed.

  • model_arguments – Additional arguments to pass to the LLM constructor.

  • source_language – The source programming language.

  • target_language (str) – The target programming language.

  • target_version (str | None) – The target version of the target programming language.

  • max_prompts – The maximum number of prompts to try before giving up.

  • max_tokens – The maximum number of tokens the model will take in. If unspecificed, model’s default max will be used.

  • prompt_template – name of prompt template directory (see janus/prompts/templates) or path to a directory.

set_target_language(target_language, target_version)#

Validate and set the target language.

The affected objects will not be updated until translate() is called.

Parameters:
  • target_language (str) – The target programming language.

  • target_version (str | None) – The target version of the target programming language.

Return type:

None