janus.converter.chain#

Attributes#

log

Classes#

ConverterChain

Class for representing multiple converters chained together

Module Contents#

janus.converter.chain.log#
class janus.converter.chain.ConverterChain(*args, **kwargs)#

Bases: janus.converter.converter.Converter

Class for representing multiple converters chained together

Initialize a Converter instance.

Parameters:
  • source_language – The source programming language.

  • parser_type – The type of parser to use for parsing the LLM output. Valid values are “code”, “text”, “eval”, and None (default). If None, the Converter assumes you won’t be parsing an output (i.e., adding to an embedding DB).

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

  • max_tokens – The maximum number of tokens to use in the LLM. If None, the converter will use half the model’s token limit.

  • prompt_templates – The name of the prompt templates to use.

  • db_path – The path to the database to use for vectorization.

  • db_config – The configuration for the database.

  • protected_node_types – A set of node types that aren’t to be merged.

  • prune_node_types – A set of node types which should be pruned.

  • splitter_type – The type of splitter to use. Valid values are “file”, “tag”, “chunk”, “ast-strict”, and “ast-flex”.

  • refiner_type – The type of refiner to use. Valid values: - “parser” - “reflection” - None

  • retriever_type – The type of retriever to use. Valid values: - “active_usings” - “language_docs” - None

  • combine_output – Whether to combine the output into a single file or not.

  • use_janus_inputs – Whether to use janus inputs or not.

  • target_language – The target programming language.

  • target_version – The target programming language version.

translate_file(file, failure_path=None)#

Translate a file using the chain of converters

Parameters:
  • file (pathlib.Path) – The file to translate

  • failure_path (pathlib.Path | None) – The path to write the failure file to

Returns:

The translated code block

Return type:

janus.language.block.TranslatedCodeBlock

translate_text(text, name, failure_path=None)#

Translate a text using the chain of converters

Parameters:
  • text (str) – The text to translate

  • name (str) – The name of the file

  • failure_path (pathlib.Path | None) – The path to write the failure file to

Returns:

The translated code block

Return type:

janus.language.block.TranslatedCodeBlock

translate_block(input_block, name, failure_path=None)#

Translate a block of code using the chain of converters

Parameters:
Returns:

The translated code block

Return type:

janus.language.block.TranslatedCodeBlock