agentkit.compose_prompt
Classes
|
Base class for composing prompts. |
|
Class for composing prompts with database values. |
- class agentkit.compose_prompt.BaseComposePrompt(system_prompt: str = 'You are a helpful assistant.')
Base class for composing prompts. This class is used to compose prompts for the LLM.
Each compose prompt instance takes dependencies (QA results from dependent nodes) and a prompt as input and returns a prompt in OpenAI format.
- class agentkit.compose_prompt.ComposePromptDB(system_prompt: str = 'You are a helpful assistant.')
Class for composing prompts with database values. This class is used to compose prompts for the LLM.
Each compose prompt instance takes dependencies (QA results from dependent nodes) and a prompt as input and returns a prompt in OpenAI format.
- node
Corresponding Node object.
- Type:
Node
- add_dependencies(messages, dependencies, db)
Add dependencies to the messages with db values.
- Parameters:
messages (list) – List of messages.
dependencies (list) – List of dependencies.
db (dict) – Database values.
- Returns:
List of messages with dependencies in OpenAI format.
- Return type:
messages (list)
- compose(dependencies, prompt)
Compose prompt for the LLM with database augmentation.
Prompt text may contain placeholders for db values. This function will replace the placeholders with the actual values from db.
- Parameters:
dependencies (list) – List of dependencies.
prompt (str) – User prompt.
- Returns:
List of messages in OpenAI format. shrink_idx (int): Index to shrink the prompt in case of truncation.
- Return type:
msg (list)
- render_db(text, db)
Render db placeholders in the prompt text.
Prompt text may contain placeholders for db values. This function will replace the placeholders with the actual values from db.
Example:
Confirm if the subgoal ‘$db.subgoals.subgoal$’ is still accurate for the challenge.
Confirm if the subgoal ‘$db.subgoals.subgoal$’ is incomplete and up-to-date according to the completion criteria ‘$db.subgoals.guide$’.
- Parameters:
text (str) – Prompt text.
db (dict) – Database values.
- Returns:
Prompt text with db placeholders replaced with actual values. db_retrieval_results (list): List of db retrieval results.
- Return type:
text (str)
- set_node(node)
Set the node for the ComposePromptDB class.
- Parameters:
node (Node) – Corresponding Node object.