← All ivy-nodes
IVYXSTUDIO · IVY NODE
X

XML Prompt Creator

ivy.node.xml-prompt-creator · v0.0.0

ivyx

Creates an XML-formatted prompt function that wraps context and question in XML tags (<context> and <question>). This format is useful for models that understand structured XML markup, providing clear separation between context and question. The output creator function is used with prompt-generator node to generate XML-formatted prompts for LLM interactions.

#xml#prompt#creator

Inputs

FieldTypeDescription
featuresobjectFeatures
labelsobjectLabels

Outputs

FieldTypeDescription
creatorrequiredobjectCallable function reference
featuresobjectFeatures
labelsobjectLabels

Source

python

# Input preparation
inp = __ivy_ctx__["nodes"][__ivy_node_id__]["input"]

# Compute
class XMLPromptCreator:
    """Builds an XML-style prompt-formatting callable."""

    def build(self):
        def xml_prompt_creator(context: str, question: str, **kwargs) -> str:
            return f"""
    Use the following pieces of information enclosed in <context> tags to provide an answer to the question enclosed in <question> tags.
    <context>
    {context}
    </context>
    <question>
    {question}
    </question>
    """
        return xml_prompt_creator

creator_node = XMLPromptCreator()
creator = creator_node.build()

# Output collection (runner reads __ivy_ctx__)
out = __ivy_ctx__["nodes"][__ivy_node_id__]["output"]
out["creator"] = creator

Tests

Requires: python:3.11

  • basic-xml-creator

    Create XML prompt creator function (should succeed).

    xmlprompt-creatorbasic