janus.cli#

Attributes#

Functions#

get_collections_config()

version_callback(value)

common(ctx[, version])

A function for getting the app version

translate(input_dir, source_lang, output_dir, target_lang)

document(input_dir, language, output_dir[, llm_name, ...])

diagram(input_dir, language, output_dir[, llm_name, ...])

db_init([path, url])

db_status()

db_ls([collection_name, peek])

List the current database's collections

db_add(collection_name, model_name[, input_dir, ...])

Add a collection to the database

db_rm(collection_name, confirm)

Remove a collection from the database

llm_add(model_name[, model_type])

embedding_add(model_name[, model_type])

Module Contents#

janus.cli.httpx_logger#
janus.cli.log#
janus.cli.homedir#
janus.cli.janus_dir#
janus.cli.db_file#
janus.cli.db_loc#
janus.cli.collections_config_file#
janus.cli.get_collections_config()#
janus.cli.app#
janus.cli.db#
janus.cli.llm#
janus.cli.embedding#
janus.cli.version_callback(value)#
Parameters:

value (bool) –

Return type:

None

janus.cli.common(ctx, version=typer.Option(None, '--version', '-v', callback=version_callback, help='Print the version and exit.'))#

A function for getting the app version

This will call the version_callback function to print the version and exit.

Parameters:
  • ctx (typer.Context) – The typer context

  • version (bool) – A boolean flag for the version

Return type:

None

janus.cli.translate(input_dir, source_lang, output_dir, target_lang, llm_name='gpt-3.5-turbo-0125', max_prompts=10, overwrite=False, temp=0.7, prompt_template='simple', collection=None, splitter_type='file', 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'.")]) –

  • 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')]) –

  • 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())))]) –

  • 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.")]) –

janus.cli.document(input_dir, language, output_dir, llm_name='gpt-3.5-turbo-0125', max_prompts=10, overwrite=False, doc_mode='madlibs', comments_per_request=None, drop_comments=False, temperature=0.7, collection=None, splitter_type='file', 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.')]) –

  • language (typing_extensions.Annotated[str, typer.Option('--language', '-l', help='The language of the source code.', click_type=click.Choice(sorted(LANGUAGES)))]) –

  • output_dir (typing_extensions.Annotated[pathlib.Path, typer.Option('--output-dir', '-o', help='The directory to store the translated code in.')]) –

  • llm_name (typing_extensions.Annotated[str, typer.Option('--llm', '-L', help="The custom name of the model set with 'janus llm add'.")]) –

  • 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')]) –

  • doc_mode (typing_extensions.Annotated[str, typer.Option('--doc-mode', '-d', help='The documentation mode.', click_type=click.Choice(['madlibs', 'summary', 'multidoc', 'requirements']))]) –

  • comments_per_request (typing_extensions.Annotated[int, typer.Option('--comments-per-request', '-rc', help='The maximum number of comments to generate per request when using MadLibs documentation mode.')]) –

  • drop_comments (typing_extensions.Annotated[bool, typer.Option('--drop-comments/--keep-comments', help='Whether to drop or keep comments in the code sent to the LLM')]) –

  • temperature (typing_extensions.Annotated[float, typer.Option('--temperature', '-t', help='Sampling temperature.', min=0, max=2)]) –

  • 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())))]) –

  • 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.")]) –

janus.cli.diagram(input_dir, language, output_dir, llm_name='gpt-3.5-turbo-0125', max_prompts=10, overwrite=False, temperature=0.7, collection=None, diagram_type='Activity', add_documentation=False, splitter_type='file')#
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.')]) –

  • language (typing_extensions.Annotated[str, typer.Option('--language', '-l', help='The language of the source code.', click_type=click.Choice(sorted(LANGUAGES)))]) –

  • output_dir (typing_extensions.Annotated[pathlib.Path, typer.Option('--output-dir', '-o', help='The directory to store the translated code in.')]) –

  • llm_name (typing_extensions.Annotated[str, typer.Option('--llm', '-L', help="The custom name of the model set with 'janus llm add'.")]) –

  • 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')]) –

  • temperature (typing_extensions.Annotated[float, typer.Option('--temperature', '-t', help='Sampling temperature.', min=0, max=2)]) –

  • 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.')]) –

  • diagram_type (typing_extensions.Annotated[str, typer.Option('--diagram-type', '-dg', help='Diagram type to generate in PLANTUML')]) –

  • add_documentation (typing_extensions.Annotated[bool, typer.Option('--add-documentation/--no-documentation', '-ad', help='Whether to use documentation in generation')]) –

  • 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())))]) –

janus.cli.db_init(path=str(janus_dir / 'chroma.db'), url='')#
Parameters:
  • path (typing_extensions.Annotated[str, typer.Option('--path', '-p', help='The path to the database file.')]) –

  • url (typing_extensions.Annotated[str, typer.Option('--url', '-u', help='The URL of the database if the database is running externally.')]) –

Return type:

None

janus.cli.db_status()#
janus.cli.db_ls(collection_name=None, peek=None)#

List the current database’s collections

Parameters:
  • collection_name (typing_extensions.Annotated[Optional[str], typer.Argument(help='The name of the collection.')]) –

  • peek (typing_extensions.Annotated[Optional[int], typer.Option('--peek', '-p', help='Peek at N entries for a specific collection.')]) –

Return type:

None

janus.cli.db_add(collection_name, model_name, input_dir='./', input_lang='python', max_tokens=4096)#

Add a collection to the database

Parameters:
  • collection_name (typing_extensions.Annotated[str, typer.Argument(help='The name of the collection.')]) – The name of the collection to add

  • model_name (typing_extensions.Annotated[str, typer.Argument(help='The name of the embedding model.')]) – The name of the embedding model to use

  • input_dir (typing_extensions.Annotated[str, typer.Option('--input', '-i', help='The directory containing the source code to be added.')]) – The directory containing the source code to be added

  • input_lang (typing_extensions.Annotated[str, typer.Option('--language', '-l', help='The language of the source code.')]) – The language of the source code

  • max_tokens (typing_extensions.Annotated[int, typer.Option('--max-tokens', '-m', help='The maximum number of tokens for each chunk of input source code.')]) – The maximum number of tokens for each chunk of input source code

Return type:

None

janus.cli.db_rm(collection_name, confirm)#

Remove a collection from the database

Parameters:
  • collection_name (typing_extensions.Annotated[str, typer.Argument(help='The name of the collection.')]) – The name of the collection to remove

  • confirm (typing_extensions.Annotated[bool, typer.Option('--yes', '-y', help='Confirm the removal of the collection.')]) –

Return type:

None

janus.cli.llm_add(model_name, model_type='OpenAI')#
Parameters:
  • model_name (typing_extensions.Annotated[str, typer.Argument(help="The user's custom name of the model")]) –

  • model_type (typing_extensions.Annotated[str, typer.Option('--type', '-t', help='The type of the model', click_type=click.Choice(sorted(list(MODEL_TYPE_CONSTRUCTORS.keys()))))]) –

janus.cli.embedding_add(model_name, model_type='OpenAI')#
Parameters:
  • model_name (typing_extensions.Annotated[str, typer.Argument(help="The user's custom name for the model")]) –

  • model_type (typing_extensions.Annotated[str, typer.Option('--type', '-t', help='The type of the model', click_type=click.Choice(list((val.value for val in EmbeddingModelType))))]) –