svg-editor / prompts.py
remiserra's picture
UI v2
7be1a06
# Remi Serra 202407
svg_prompts = {
"Create SVG": {
"template": """You are an expert of the SVG image format. You will be provided with the description of an image.
Design the SVG to create the image and return the new SVG image XML. Do not provide comments, only the resulting SVG XML.
Instructions:
{instructions}
Result SVG XML:
""",
"display": True,
"uploadmode" : False,
"example": "Three dots",
"primer": '<?xml version="1.0" ?><svg xmlns="http://www.w3.org/2000/svg"',
},
"Modify SVG": {
"template": """You are an expert of the SVG image format.
You will be provided with an SVG image XML representation and modification instructions.
Apply the instructions to the SVG XML and return the new SVG image XML. Do not provide comments, only the resulting SVG XML.
SVG XML:
{svg}
Instructions:
{instructions}
Result SVG XML:
""",
"display": True,
"uploadmode" : True,
"example": "Change all colors to red",
"primer": "",
},
"Describe SVG": {
"template": """You are an expert of the SVG image format.
You will be provided with an SVG image XML representation, please describe the image provided.
Try to describe the overall image, not only the details.
SVG XML:
{svg}
Description of the image:
""",
"display": False,
"uploadmode" : True,
"example": "N/A",
"primer": "",
},
"Create IBM style SVG": {
"template": """You are an expert of the SVG image format and of IBM design style.
You will be provided with a few samples of IBM style SVG image,
Then you will be provided with the description of an image.
Design a new SVG to create the image and return the new SVG image XML.
Do not provide comments, only the resulting SVG XML.
SVG XML Sample in IBM design style:
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="16" height="16" fill="white" fill-opacity="0.01" style="mix-blend-mode:multiply"/>
<path d="M8 14C6.9122 14 5.84883 13.6774 4.94436 13.0731C4.03989 12.4687 3.33494 11.6098 2.91866 10.6048C2.50238 9.59977 2.39346 8.4939 2.60568 7.42701C2.8179 6.36011 3.34172 5.38011 4.11091 4.61092C4.8801 3.84173 5.86011 3.3179 6.927 3.10568C7.9939 2.89347 9.09977 3.00238 10.1048 3.41867C11.1098 3.83495 11.9687 4.5399 12.5731 5.44437C13.1774 6.34884 13.5 7.41221 13.5 8.5C13.5 9.95869 12.9205 11.3576 11.8891 12.3891C10.8576 13.4205 9.45869 14 8 14ZM8 4C7.10998 4 6.23995 4.26392 5.49993 4.75839C4.75991 5.25286 4.18314 5.95566 3.84254 6.77793C3.50195 7.6002 3.41283 8.505 3.58647 9.37791C3.7601 10.2508 4.18868 11.0526 4.81802 11.682C5.44736 12.3113 6.24918 12.7399 7.12209 12.9135C7.99501 13.0872 8.89981 12.9981 9.72208 12.6575C10.5443 12.3169 11.2471 11.7401 11.7416 11.0001C12.2361 10.26 12.5 9.39002 12.5 8.5C12.5 7.30653 12.0259 6.16194 11.182 5.31802C10.3381 4.47411 9.19347 4 8 4Z" fill="#161616"/>
<path d="M3.79082 2.00158L2.00018 3.79597L2.70803 4.50234L4.49867 2.70795L3.79082 2.00158Z" fill="#161616"/>
<path d="M12.2076 1.99719L11.4997 2.70356L13.2904 4.49795L13.9982 3.79158L12.2076 1.99719Z" fill="#161616"/>
<path d="M10.5 8H5.5V9H10.5V8Z" fill="#161616"/>
</svg>
SVG XML Sample in IBM design style:
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="16" height="16" fill="white" fill-opacity="0.01" style="mix-blend-mode:multiply"/>
<path d="M15 7.5H13V6C12.9997 5.73488 12.8942 5.48072 12.7067 5.29326C12.5193 5.10579 12.2651 5.00033 12 5H10C9.73489 5.00033 9.48072 5.10579 9.29326 5.29326C9.10579 5.48072 9.00033 5.73488 9 6V7.5H7V4C6.99967 3.73489 6.89421 3.48072 6.70674 3.29326C6.51928 3.10579 6.26511 3.00033 6 3H4C3.73488 3.00033 3.48072 3.10579 3.29326 3.29326C3.10579 3.48072 3.00033 3.73489 3 4V7.5H1V8.5H3V12C3.00033 12.2651 3.10579 12.5193 3.29326 12.7067C3.48072 12.8942 3.73488 12.9997 4 13H6C6.26511 12.9997 6.51928 12.8942 6.70674 12.7067C6.89421 12.5193 6.99967 12.2651 7 12V8.5H9V10C9.00033 10.2651 9.10579 10.5193 9.29326 10.7067C9.48072 10.8942 9.73489 10.9997 10 11H12C12.2651 10.9997 12.5193 10.8942 12.7067 10.7067C12.8942 10.5193 12.9997 10.2651 13 10V8.5H15V7.5ZM4 12V4H6L6.0006 12H4ZM10 10V6H12L12.0006 10H10Z" fill="#161616"/>
</svg>
SVG XML Sample in IBM design style:
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="16" height="16" fill="white" fill-opacity="0.01" style="mix-blend-mode:multiply"/>
<path d="M13.5 11.071V4.92905C13.8411 4.84157 14.153 4.66539 14.404 4.4184C14.655 4.17141 14.8362 3.86239 14.9292 3.52273C15.0222 3.18306 15.0236 2.82485 14.9334 2.48444C14.8432 2.14404 14.6645 1.83357 14.4155 1.58456C14.1665 1.33554 13.856 1.15685 13.5156 1.06662C13.1752 0.976392 12.817 0.977839 12.4773 1.07082C12.1376 1.16379 11.8286 1.34499 11.5816 1.59601C11.3346 1.84702 11.1585 2.15893 11.071 2.50005H4.92899C4.84151 2.15893 4.66533 1.84702 4.41834 1.59601C4.17135 1.34499 3.86233 1.16379 3.52267 1.07082C3.183 0.977839 2.82479 0.976392 2.48438 1.06662C2.14398 1.15685 1.83351 1.33554 1.5845 1.58456C1.33548 1.83357 1.15679 2.14404 1.06656 2.48444C0.976331 2.82485 0.977778 3.18306 1.07075 3.52273C1.16373 3.86239 1.34493 4.17141 1.59594 4.4184C1.84696 4.66539 2.15887 4.84157 2.49999 4.92905V11.071C2.15887 11.1585 1.84696 11.3347 1.59594 11.5817C1.34493 11.8287 1.16373 12.1377 1.07075 12.4774C0.977778 12.817 0.976331 13.1752 1.06656 13.5157C1.15679 13.8561 1.33548 14.1665 1.5845 14.4155C1.83351 14.6646 2.14398 14.8432 2.48438 14.9335C2.82479 15.0237 3.183 15.0223 3.52267 14.9293C3.86233 14.8363 4.17135 14.6551 4.41834 14.4041C4.66533 14.1531 4.84151 13.8412 4.92899 13.5H11.071C11.1585 13.8412 11.3346 14.1531 11.5816 14.4041C11.8286 14.6551 12.1376 14.8363 12.4773 14.9293C12.817 15.0223 13.1752 15.0237 13.5156 14.9335C13.856 14.8432 14.1665 14.6646 14.4155 14.4155C14.6645 14.1665 14.8432 13.8561 14.9334 13.5157C15.0236 13.1752 15.0222 12.817 14.9292 12.4774C14.8362 12.1377 14.655 11.8287 14.404 11.5817C14.153 11.3347 13.8411 11.1585 13.5 11.071ZM13 2.00005C13.1978 2.00005 13.3911 2.0587 13.5556 2.16858C13.72 2.27846 13.8482 2.43464 13.9239 2.61736C13.9996 2.80009 14.0194 3.00116 13.9808 3.19514C13.9422 3.38912 13.8469 3.5673 13.7071 3.70715C13.5672 3.84701 13.3891 3.94225 13.1951 3.98083C13.0011 4.01942 12.8 3.99962 12.6173 3.92393C12.4346 3.84824 12.2784 3.72007 12.1685 3.55562C12.0586 3.39117 12 3.19783 12 3.00005C12.0003 2.73492 12.1057 2.48075 12.2932 2.29328C12.4807 2.10581 12.7349 2.00035 13 2.00005ZM1.99999 3.00005C1.99999 2.80227 2.05864 2.60893 2.16852 2.44448C2.2784 2.28003 2.43458 2.15186 2.6173 2.07617C2.80003 2.00048 3.0011 1.98068 3.19508 2.01926C3.38906 2.05785 3.56724 2.15309 3.70709 2.29294C3.84695 2.43279 3.94219 2.61098 3.98077 2.80496C4.01936 2.99894 3.99955 3.20001 3.92387 3.38273C3.84818 3.56546 3.72001 3.72164 3.55556 3.83152C3.39111 3.9414 3.19777 4.00005 2.99999 4.00005C2.73485 3.99978 2.48065 3.89434 2.29317 3.70686C2.10569 3.51938 2.00025 3.26518 1.99999 3.00005ZM2.99999 14C2.80221 14 2.60887 13.9414 2.44442 13.8315C2.27997 13.7216 2.15179 13.5655 2.07611 13.3827C2.00042 13.2 1.98062 12.9989 2.0192 12.805C2.05779 12.611 2.15303 12.4328 2.29288 12.2929C2.43273 12.1531 2.61092 12.0578 2.8049 12.0193C2.99888 11.9807 3.19994 12.0005 3.38267 12.0762C3.5654 12.1519 3.72158 12.28 3.83146 12.4445C3.94134 12.6089 3.99999 12.8023 3.99999 13C3.99968 13.2652 3.89423 13.5193 3.70676 13.7068C3.51929 13.8943 3.26511 13.9997 2.99999 14ZM11.071 12.5H4.92899C4.83944 12.1563 4.6598 11.8426 4.40861 11.5914C4.15741 11.3402 3.84376 11.1606 3.49999 11.071V4.92905C3.84373 4.83945 4.15737 4.6598 4.40855 4.40861C4.65974 4.15743 4.83939 3.84379 4.92899 3.50005H11.071C11.1605 3.84382 11.3402 4.15748 11.5914 4.40867C11.8426 4.65986 12.1562 4.8395 12.5 4.92905V11.071C12.1562 11.1606 11.8425 11.3402 11.5913 11.5914C11.3401 11.8426 11.1605 12.1563 11.071 12.5ZM13 14C12.8022 14 12.6089 13.9414 12.4444 13.8315C12.28 13.7216 12.1518 13.5655 12.0761 13.3827C12.0004 13.2 11.9806 12.9989 12.0192 12.805C12.0578 12.611 12.153 12.4328 12.2929 12.2929C12.4327 12.1531 12.6109 12.0578 12.8049 12.0193C12.9989 11.9807 13.1999 12.0005 13.3827 12.0762C13.5654 12.1519 13.7216 12.28 13.8315 12.4445C13.9413 12.6089 14 12.8023 14 13C13.9996 13.2652 13.8942 13.5193 13.7067 13.7068C13.5192 13.8942 13.2651 13.9997 13 14Z" fill="#161616"/>
</svg>
SVG XML Sample in IBM design style:
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="16" height="16" fill="white" fill-opacity="0.01" style="mix-blend-mode:multiply"/>
<path d="M8 1C6.61553 1 5.26216 1.41054 4.11101 2.17971C2.95987 2.94888 2.06266 4.04213 1.53285 5.32122C1.00303 6.6003 0.86441 8.00777 1.13451 9.36563C1.4046 10.7235 2.07129 11.9708 3.05026 12.9497C4.02922 13.9287 5.2765 14.5954 6.63437 14.8655C7.99224 15.1356 9.3997 14.997 10.6788 14.4672C11.9579 13.9373 13.0511 13.0401 13.8203 11.889C14.5895 10.7378 15 9.38447 15 8C14.9979 6.14413 14.2597 4.36486 12.9474 3.05256C11.6351 1.74026 9.85588 1.00209 8 1V1ZM13.9746 7.5H11.0205C11.1458 6.20609 11.6189 4.97021 12.3897 3.92335C13.3047 4.9037 13.863 6.1636 13.9746 7.5V7.5ZM8.5 7.5V2.0254C9.64338 2.12054 10.735 2.54373 11.6437 3.24415C10.7081 4.47913 10.1448 5.95567 10.02 7.5H8.5ZM7.5 7.5H5.98C5.85523 5.95567 5.2919 4.47913 4.3563 3.24415C5.26503 2.54373 6.35663 2.12054 7.5 2.0254V7.5ZM7.5 8.5V13.9746C6.35663 13.8795 5.26503 13.4563 4.3563 12.7558C5.2919 11.5209 5.85523 10.0443 5.98 8.5H7.5ZM8.5 8.5H10.02C10.1448 10.0443 10.7082 11.5209 11.6438 12.7558C10.7351 13.4563 9.64341 13.8795 8.5 13.9746V8.5ZM3.61035 3.92335C4.38106 4.97021 4.85416 6.20609 4.9795 7.5H2.0254C2.13698 6.1636 2.69529 4.9037 3.61035 3.92335V3.92335ZM2.0254 8.5H4.9795C4.85416 9.79391 4.38106 11.0298 3.61035 12.0766C2.69529 11.0963 2.13698 9.8364 2.0254 8.5V8.5ZM12.3897 12.0766C11.6189 11.0298 11.1458 9.79391 11.0205 8.5H13.9746C13.863 9.8364 13.3047 11.0963 12.3897 12.0766V12.0766Z" fill="#161616"/>
</svg>
SVG XML in IBM design style:
""",
"display": False,
"uploadmode" : False,
"example": "Three dots",
"primer": '<?xml version="1.0" ?><svg xmlns="http://www.w3.org/2000/svg"',
},
}
def list_prompts():
prompt_list = [k for k, v in svg_prompts.items() if v["display"] is True]
return prompt_list
def get_prompt_template(promptid):
return svg_prompts[promptid]["template"]
def get_prompt_example(promptid):
return svg_prompts[promptid]["example"]
def get_prompt_primer(promptid):
return svg_prompts[promptid]["primer"]
def get_prompt_uploadmode(promptid):
return svg_prompts[promptid]["uploadmode"]