← All ivy-nodes
IVYXSTUDIO · IVY NODE
D
Default Prompt Creator
ivy.node.default-prompt-creator · v0.0.0
ivyx✓
Creates a default prompt formatting function that formats context and question in a simple text format. The function takes context and question as parameters and returns a formatted prompt string. The output prompt_creator function is used with prompt-generator node to generate prompts for LLM interactions. This is the simplest prompt format, suitable for most general-purpose AI tasks.
#prompt#creator
Inputs
| Field | Type | Description |
|---|---|---|
| features | object | Features |
| labels | object | Labels |
Outputs
| Field | Type | Description |
|---|---|---|
| prompt_creatorrequired | object | Callable function reference |
| features | object | Features |
| labels | object | Labels |
Source
python
# Input preparation
inp = __ivy_ctx__["nodes"][__ivy_node_id__]["input"]
# Compute
class DefaultPromptCreator:
"""Builds a default prompt-formatting callable."""
def build(self):
def default_prompt_creator(context: str, question: str, **kwargs) -> str:
return (
f"Context: {context}\n\n"
f"Question: {question}\n\n"
"Answer the question based on the context above. If the context is not relevant, use your own knowledge."
)
return default_prompt_creator
creator_node = DefaultPromptCreator()
prompt_creator = creator_node.build()
# Output collection (runner reads __ivy_ctx__)
out = __ivy_ctx__["nodes"][__ivy_node_id__]["output"]
out["prompt_creator"] = prompt_creatorTests
Requires: python:3.11
- basic-creator-creation
Create prompt creator function (should succeed).
prompt-creatordefaultbasic