janus.cli#
Attributes#
Functions#
|
|
|
|
|
A function for getting the app version |
|
|
|
|
|
|
|
|
|
|
|
|
|
List the current database's collections |
|
Add a collection to the database |
|
Remove a collection from the database |
|
|
|
|
|
|
|
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_subclasses(cls)#
- janus.cli.REFINER_TYPES#
- janus.cli.REFINERS#
- janus.cli.get_collections_config()#
- janus.cli.app#
- janus.cli.db#
- janus.cli.llm#
- janus.cli.embedding#
- 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, 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'.")]) –
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.")]) –
- janus.cli.document(input_dir, language, output_dir, llm_name, max_prompts=10, overwrite=False, doc_mode='madlibs', comments_per_request=None, drop_comments=False, temperature=0.7, 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.')]) –
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())))]) –
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.")]) –
- janus.cli.aggregate(input_dir, language, output_dir, llm_name, max_prompts=10, overwrite=False, temperature=0.7, collection=None, splitter_type='file', intermediate_converters=['Documenter'])#
- 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.')]) –
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())))]) –
intermediate_converters (typing_extensions.Annotated[List[str], typer.Option('-C', '--converter', help='Name of an intermediate converter to use', click_type=click.Choice([c.__name__ for c in get_subclasses(Converter)]))]) –
- janus.cli.partition(input_dir, language, output_dir, llm_name='gpt-4o', max_prompts=10, overwrite=False, temperature=0.7, splitter_type='file', max_tokens=None, partition_token_limit=8192)#
- Parameters:
input_dir (typing_extensions.Annotated[pathlib.Path, typer.Option('--input', '-i', help='The directory containing the source code to be partitioned. ')]) –
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 partitioned 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)]) –
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.")]) –
partition_token_limit (typing_extensions.Annotated[int, typer.Option('--partition-tokens', '-pt', help='The limit on the number of tokens per partition.')]) –
- janus.cli.diagram(input_dir, language, output_dir, llm_name, max_prompts=10, overwrite=False, temperature=0.7, collection=None, diagram_type='Activity', add_documentation=False, splitter_type='file', refiner_types=['JanusRefiner'], retriever_type=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')]) –
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())))]) –
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']))]) –
- janus.cli.db_init(path=str(janus_dir / 'chroma.db'), url='')#
- janus.cli.db_status()#
- janus.cli.db_ls(collection_name=None, peek=None)#
List the current database’s collections
- 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
- janus.cli.llm_add(model_name, model_type='Azure')#
- janus.cli.llm_ls(all=False)#
- janus.cli.embedding_add(model_name, model_type='OpenAI')#
- Parameters: