janus.prompts.prompt#

Attributes#

Classes#

PromptEngine

A class defining prompting schemes for the LLM.

ChatGptPromptEngine

A class defining prompting schemes for the LLM.

ClaudePromptEngine

A class defining prompting schemes for the LLM.

TitanPromptEngine

A class defining prompting schemes for the LLM.

Llama2PromptEngine

A class defining prompting schemes for the LLM.

Llama3PromptEngine

A class defining prompting schemes for the LLM.

CoherePromptEngine

A class defining prompting schemes for the LLM.

MistralPromptEngine

A class defining prompting schemes for the LLM.

Module Contents#

janus.prompts.prompt.log#
janus.prompts.prompt.TEXT_OUTPUT = []#
janus.prompts.prompt.SAME_OUTPUT = ['document_inline']#
janus.prompts.prompt.JSON_OUTPUT = ['evaluate', 'document', 'document_madlibs', 'requirements']#
janus.prompts.prompt.JANUS_PROMPT_TEMPLATES_DIR#
janus.prompts.prompt.SYSTEM_PROMPT_TEMPLATE_FILENAME = 'system.txt'#
janus.prompts.prompt.HUMAN_PROMPT_TEMPLATE_FILENAME = 'human.txt'#
janus.prompts.prompt.PROMPT_VARIABLES_FILENAME = 'variables.json'#
janus.prompts.prompt.retry_with_output_prompt_text = Multiline-String#
Show Value
"""Instructions:
--------------
{instructions}
--------------
Completion:
--------------
{completion}
--------------

Above, the Completion did not satisfy the constraints given in the Instructions.
Error:
--------------
{error}
--------------

Please try again. Please only respond with an answer that satisfies the
constraints laid out in the Instructions:"""
janus.prompts.prompt.retry_with_error_and_output_prompt_text = Multiline-String#
Show Value
"""Prompt:
--------------
{prompt}
--------------
Completion:
--------------
{completion}
--------------

Above, the Completion did not satisfy the constraints given in the Prompt.
Error:
--------------
{error}
--------------

Please try again. Please only respond with an answer that satisfies the
constraints laid out in the Prompt:"""
janus.prompts.prompt.retry_with_output_prompt#
janus.prompts.prompt.retry_with_error_and_output_prompt#
class janus.prompts.prompt.PromptEngine(source_language, prompt_template, target_language=None, target_version=None)#

Bases: abc.ABC

A class defining prompting schemes for the LLM.

Initialize a PromptEngine instance.

Parameters:
  • source_language (str) – The language to translate from

  • target_language (str | None) – The language to translate to

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

  • prompt_template (str) – The name of the Janus prompt template directory to use. Can be one of “simple”, “document”, “document_inline”, “pseudocode”, or “requirements”, or a path to a custom directory containing system.txt and human.txt files.

abstract load_prompt_template(template_path)#
Parameters:

template_path (pathlib.Path) –

Return type:

langchain.prompts.ChatPromptTemplate

static get_prompt_template_path(template_name)#

Raises an exception if the specified prompt template path is not a directory containing system.txt and human.txt files.

Parameters:

template_name (str) – The name of the Janus prompt template directory to use. Can be one of “simple”, “document”, “document_inline”, or “requirements”, or a path to a custom directory containing system.txt and human.txt files.

Return type:

pathlib.Path

class janus.prompts.prompt.ChatGptPromptEngine(source_language, prompt_template, target_language=None, target_version=None)#

Bases: PromptEngine

A class defining prompting schemes for the LLM.

Initialize a PromptEngine instance.

Parameters:
  • source_language (str) – The language to translate from

  • target_language (str | None) – The language to translate to

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

  • prompt_template (str) – The name of the Janus prompt template directory to use. Can be one of “simple”, “document”, “document_inline”, “pseudocode”, or “requirements”, or a path to a custom directory containing system.txt and human.txt files.

load_prompt_template(template_path)#
Parameters:

template_path (pathlib.Path) –

Return type:

langchain.prompts.ChatPromptTemplate

class janus.prompts.prompt.ClaudePromptEngine(source_language, prompt_template, target_language=None, target_version=None)#

Bases: PromptEngine

A class defining prompting schemes for the LLM.

Initialize a PromptEngine instance.

Parameters:
  • source_language (str) – The language to translate from

  • target_language (str | None) – The language to translate to

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

  • prompt_template (str) – The name of the Janus prompt template directory to use. Can be one of “simple”, “document”, “document_inline”, “pseudocode”, or “requirements”, or a path to a custom directory containing system.txt and human.txt files.

load_prompt_template(template_path)#
Parameters:

template_path (pathlib.Path) –

Return type:

langchain.prompts.ChatPromptTemplate

class janus.prompts.prompt.TitanPromptEngine(source_language, prompt_template, target_language=None, target_version=None)#

Bases: PromptEngine

A class defining prompting schemes for the LLM.

Initialize a PromptEngine instance.

Parameters:
  • source_language (str) – The language to translate from

  • target_language (str | None) – The language to translate to

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

  • prompt_template (str) – The name of the Janus prompt template directory to use. Can be one of “simple”, “document”, “document_inline”, “pseudocode”, or “requirements”, or a path to a custom directory containing system.txt and human.txt files.

load_prompt_template(template_path)#
Parameters:

template_path (pathlib.Path) –

Return type:

langchain.prompts.ChatPromptTemplate

class janus.prompts.prompt.Llama2PromptEngine(source_language, prompt_template, target_language=None, target_version=None)#

Bases: PromptEngine

A class defining prompting schemes for the LLM.

Initialize a PromptEngine instance.

Parameters:
  • source_language (str) – The language to translate from

  • target_language (str | None) – The language to translate to

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

  • prompt_template (str) – The name of the Janus prompt template directory to use. Can be one of “simple”, “document”, “document_inline”, “pseudocode”, or “requirements”, or a path to a custom directory containing system.txt and human.txt files.

load_prompt_template(template_path)#
Parameters:

template_path (pathlib.Path) –

Return type:

langchain.prompts.ChatPromptTemplate

class janus.prompts.prompt.Llama3PromptEngine(source_language, prompt_template, target_language=None, target_version=None)#

Bases: PromptEngine

A class defining prompting schemes for the LLM.

Initialize a PromptEngine instance.

Parameters:
  • source_language (str) – The language to translate from

  • target_language (str | None) – The language to translate to

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

  • prompt_template (str) – The name of the Janus prompt template directory to use. Can be one of “simple”, “document”, “document_inline”, “pseudocode”, or “requirements”, or a path to a custom directory containing system.txt and human.txt files.

load_prompt_template(template_path)#
Parameters:

template_path (pathlib.Path) –

Return type:

langchain.prompts.ChatPromptTemplate

class janus.prompts.prompt.CoherePromptEngine(source_language, prompt_template, target_language=None, target_version=None)#

Bases: PromptEngine

A class defining prompting schemes for the LLM.

Initialize a PromptEngine instance.

Parameters:
  • source_language (str) – The language to translate from

  • target_language (str | None) – The language to translate to

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

  • prompt_template (str) – The name of the Janus prompt template directory to use. Can be one of “simple”, “document”, “document_inline”, “pseudocode”, or “requirements”, or a path to a custom directory containing system.txt and human.txt files.

load_prompt_template(template_path)#
Parameters:

template_path (pathlib.Path) –

Return type:

langchain.prompts.ChatPromptTemplate

class janus.prompts.prompt.MistralPromptEngine(source_language, prompt_template, target_language=None, target_version=None)#

Bases: PromptEngine

A class defining prompting schemes for the LLM.

Initialize a PromptEngine instance.

Parameters:
  • source_language (str) – The language to translate from

  • target_language (str | None) – The language to translate to

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

  • prompt_template (str) – The name of the Janus prompt template directory to use. Can be one of “simple”, “document”, “document_inline”, “pseudocode”, or “requirements”, or a path to a custom directory containing system.txt and human.txt files.

load_prompt_template(template_path)#
Parameters:

template_path (pathlib.Path) –

Return type:

langchain.prompts.ChatPromptTemplate