azad.prompts.dialects.xml.dialect Module¶
azad.prompts.dialects.xml.dialect ¶
Attributes¶
Classes¶
XMLDialect ¶
XMLDialect(config: XMLDialectConfig)
Bases: Dialect
XML-based dialect for AI agent communication.
Source code in azad/prompts/dialects/xml/dialect.py
Attributes¶
Functions¶
format_dialect_rules ¶
format_dialect_rules(prompt_data: PromptData, rules_file_name: Optional[str]) -> str
Return the XML dialect rules.
Source code in azad/prompts/dialects/xml/dialect.py
format_example ¶
Format an example tool call in XML.
format_tool_call ¶
format_tool_call(tool_call: ToolCallPart) -> str
Format a tool call into XML.
Source code in azad/prompts/dialects/xml/dialect.py
format_tool_result ¶
format_tool_result(tool_result: ToolResultPart) -> str
Format a tool result into XML.
Source code in azad/prompts/dialects/xml/dialect.py
format_history_item ¶
format_history_item(item: Message) -> Optional[dict]
Convert a Message to a LiteLLM message with XML tools and image support.
Source code in azad/prompts/dialects/xml/dialect.py
create_parser ¶
create_parser(prompt_data: PromptData) -> DialectParser
Create an XML dialect parser configured with the specified tools.
Source code in azad/prompts/dialects/xml/dialect.py
format_tool_schema ¶
format_tool_schema(tool: ToolMetadata) -> dict
Format a tool's metadata into a JSON schema format.
Parameters:
-
tool(ToolMetadata) –The tool metadata to format
Returns:
-
dict–A dictionary representing the formatted tool schema
Source code in azad/prompts/base_dialect.py
format_tools_schema ¶
format_tools_schema(tools: List[ToolMetadata]) -> List[dict]
Format multiple tools' metadata into JSON schema format.
Parameters:
-
tools(List[ToolMetadata]) –A list of tool metadata objects to format
Returns:
-
List[dict]–A list of dictionaries representing the formatted tool schemas
Source code in azad/prompts/base_dialect.py
inject_prompt_cache ¶
inject_prompt_cache(messages: list[dict], prompt_data: PromptData)
Modifies the formatted messages list IN-PLACE to add cache control flags based on the model type and specific caching rules.
Source code in azad/prompts/base_dialect.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
format_messages ¶
format_messages(prompt_data: PromptData, rules_path: Optional[str]) -> list[dict]
Source code in azad/prompts/base_dialect.py
format_system_prompt ¶
format_system_prompt(prompt_data: PromptData, rules_path: Optional[str]) -> dict
Format the system prompt for the dialect. This method handles the replacement of placeholders in the system prompt with the actual values from the prompt data. If there is no placeholder it will format the system prompt in following way: TOOL_USE_INSTRUCTION AVAILABLE_TOOLS USER AGENT PROMPT SYSTEM GENERAL INSTRUCTIONS USER CUSTOM INSTRUCTIONS
Source code in azad/prompts/base_dialect.py
format_system_rules ¶
Source code in azad/prompts/base_dialect.py
format_history ¶
format_history(prompt_data: PromptData) -> List[dict]
Format the entire message history from the mindmap.
Source code in azad/prompts/base_dialect.py
format_user_prompt ¶
format_user_prompt(prompt_data: PromptData) -> str
Source code in azad/prompts/base_dialect.py
format_user_agent_prompt ¶
format_user_agent_prompt(prompt_data: PromptData) -> str
Source code in azad/prompts/base_dialect.py
format_tool_docs ¶
format_tool_docs(prompt_data: PromptData) -> str
Format documentation for available tools.
This base implementation handles the structure, while specific dialects format the individual examples.
Parameters:
-
tools–List of Tool classes or ToolSignature objects to document
Returns:
-
str–Formatted tool documentation string
Source code in azad/prompts/base_dialect.py
Functions¶
format_any_json_to_xml ¶
Convert a JSON object to an XML string with CDATA sections for all values.