translate#
Attributes#
Functions#
|
Module Contents#
- translate.log#
- translate.translate(input_dir, source_lang, output_dir, target_lang, llm_name, failure_dir=None, max_prompts=10, overwrite=False, skip_context=False, temp=0.7, prompt_template='simple', collection=None, splitter_type='file', refiner_types=['JanusRefiner'], retriever_type=None, max_tokens=None)#
- Parameters:
input_dir (typing_extensions.Annotated[pathlib.Path, typer.Option('--input', '-i', help='The directory containing the source code to be translated. The files should all be in one flat directory.')]) –
source_lang (typing_extensions.Annotated[str, typer.Option('--source-language', '-s', help='The language of the source code.', click_type=click.Choice(sorted(LANGUAGES)))]) –
output_dir (typing_extensions.Annotated[pathlib.Path, typer.Option('--output', '-o', help='The directory to store the translated code in.')]) –
target_lang (typing_extensions.Annotated[str, typer.Option('--target-language', '-t', help="The desired output language to translate the source code to. The format can follow a 'language-version' syntax. Use 'text' to get plaintextresults as returned by the LLM. Examples: `python-3.10`, `mumps`, `java-10`,text.")]) –
llm_name (typing_extensions.Annotated[str, typer.Option('--llm', '-L', help="The custom name of the model set with 'janus llm add'.")]) –
failure_dir (typing_extensions.Annotated[Optional[pathlib.Path], typer.Option('--failure-directory', '-f', help='The directory to store failure files during translation')]) –
max_prompts (typing_extensions.Annotated[int, typer.Option('--max-prompts', '-m', help='The maximum number of times to prompt a model on one functional block before exiting the application. This is to prevent wasting too much money.')]) –
overwrite (typing_extensions.Annotated[bool, typer.Option('--overwrite/--preserve', help='Whether to overwrite existing files in the output directory')]) –
skip_context (typing_extensions.Annotated[bool, typer.Option('--skip-context', help='Prompts will include any context information associated with source code blocks, unless this option is specified')]) –
temp (typing_extensions.Annotated[float, typer.Option('--temperature', '-T', help='Sampling temperature.', min=0, max=2)]) –
prompt_template (typing_extensions.Annotated[str, typer.Option('--prompt-template', '-p', help='Name of the Janus prompt template directory or path to a directory containing those template files.')]) –
collection (typing_extensions.Annotated[str, typer.Option('--collection', '-c', help='If set, will put the translated result into a Chroma DB collection with the name provided.')]) –
splitter_type (typing_extensions.Annotated[str, typer.Option('-S', '--splitter', help='Name of custom splitter to use', click_type=click.Choice(list(CUSTOM_SPLITTERS.keys())))]) –
refiner_types (typing_extensions.Annotated[list[str], typer.Option('-r', '--refiner', help='List of refiner types to use. Add -r for each refiner to use in refinement chain', click_type=click.Choice(list(REFINERS.keys())))]) –
retriever_type (typing_extensions.Annotated[str, typer.Option('-R', '--retriever', help='Name of custom retriever to use', click_type=click.Choice(['active_usings', 'language_docs']))]) –
max_tokens (typing_extensions.Annotated[int, typer.Option('--max-tokens', '-M', help="The maximum number of tokens the model will take in. If unspecificed, model's default max will be used.")]) –