sitatech commited on
Commit
b008970
·
1 Parent(s): 125261f

Adapt system prompt for virtual try on

Browse files
Files changed (2) hide show
  1. mcp_client.py +6 -7
  2. mcp_host/agent.py +30 -3
mcp_client.py CHANGED
@@ -165,13 +165,6 @@ class MCPClient:
165
  image=base64.b64decode(content.data),
166
  filename=f"{call_id}.{content.mimeType.split('/')[1]}", # e.g. "call_id.png"
167
  )
168
- contents.append(
169
- {
170
- "type": "text",
171
- "text": f"image_url: {image_url}\nimage:",
172
- }
173
- )
174
- # Put the image content after the url
175
  contents.append(
176
  {
177
  "type": "image_url",
@@ -180,6 +173,12 @@ class MCPClient:
180
  },
181
  }
182
  )
 
 
 
 
 
 
183
  else:
184
  raise ValueError(f"Unsupported content type: {content.type}")
185
 
 
165
  image=base64.b64decode(content.data),
166
  filename=f"{call_id}.{content.mimeType.split('/')[1]}", # e.g. "call_id.png"
167
  )
 
 
 
 
 
 
 
168
  contents.append(
169
  {
170
  "type": "image_url",
 
173
  },
174
  }
175
  )
176
+ contents.append(
177
+ {
178
+ "type": "text",
179
+ "text": f"image_url: {image_url}",
180
+ }
181
+ )
182
  else:
183
  raise ValueError(f"Unsupported content type: {content.type}")
184
 
mcp_host/agent.py CHANGED
@@ -49,6 +49,7 @@ ChatOutputType = Generator[
49
  None,
50
  ]
51
 
 
52
  class VibeShoppingAgent:
53
  SYSTEM_PROMPT: str = """You are a helpful online shopping AI assistant.
54
  <context>
@@ -148,11 +149,37 @@ class VibeShoppingAgent:
148
  <tool-response>
149
  Content displayed successfully.
150
  </tool-response>
151
- Assistant:
152
- If you like standing out, The Stylish Red Dress is a great choice, it looks very elegant and professional. Would you like to try it on?
153
  User: Yes, I would like to try it on
154
  Assistant: Great! Please upload a photo of yourself so I can help you try it on.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  </example-3>
 
 
 
 
 
 
156
  """
157
 
158
  def __init__(
@@ -524,7 +551,7 @@ class VibeShoppingAgent:
524
  return (
525
  {
526
  "type": "text",
527
- "text": f"{image_label}_url: {image_url}\n{image_label}:",
528
  },
529
  {
530
  "type": "image_url",
 
49
  None,
50
  ]
51
 
52
+ # TODO: Refactor to improve readability
53
  class VibeShoppingAgent:
54
  SYSTEM_PROMPT: str = """You are a helpful online shopping AI assistant.
55
  <context>
 
149
  <tool-response>
150
  Content displayed successfully.
151
  </tool-response>
152
+ Assistant: If you like standing out, The Stylish Red Dress is a great choice, it looks very elegant and professional. Would you like to try it on?
 
153
  User: Yes, I would like to try it on
154
  Assistant: Great! Please upload a photo of yourself so I can help you try it on.
155
+ User:
156
+ <uploaded-photo-wearing-pants-and-t-shirt>
157
+ input_image_url = "https://example.com/user-photo.png"
158
+ Assistant: Amazing! I received your photo, but for this photo, I can't automatically apply the dress, you need to draw a mask around the area where you want the dress to be applied.
159
+ User:
160
+ <uploaded-photo>
161
+ <uploaded-mask>
162
+ input_image_url = "https://example.com/user-photo.png"
163
+ input_mask_url = "https://example.com/user-photo-mask.png"
164
+ <tool-call>
165
+ {"name": "VirtualTry.try_item_with_masking", "arguments": {"prompt": "<prompt-as-described-in-tool-description>", "item_image_url": "https://example.com/stylish-red-dress.png", "target_image_url": "https://example.com/user-photo.png", "mask_image_url": "https://example.com/user-photo-mask.png"}}
166
+ </tool-call>
167
+ Tool:
168
+ <tool-response>
169
+ <result-image>
170
+ image_url: "https://example.com/virtual-try-on-result.png"
171
+ </tool-response>
172
+ Assistant: Hum, you look gorgeous in the Stylish Red Dress! Take a look at this:
173
+ <tool-call>
174
+ {"name": "Display.display_image", "arguments": {"image_url": "https://example.com/virtual-try-on-result.png"}}
175
+ </tool-call>
176
  </example-3>
177
+
178
+ <virtual-try-on-notes>
179
+ For the example-3, since the photo the user uploaded was of them wearing pants, and masking the paints area won't be enough to apply the dress (there would be an unmasked area between the legs), the assistant asked the user to draw a mask around the area where the dress should be applied, so it can apply it correctly.
180
+ But if the user wanted to buy a t-shirt and the photo was of them wearing a shirt for example, the assistant could have used the auto-masker to generate a mask of the shirt area, with the "shirt" masking prompt, and apply the t-shirt on top of it.
181
+ You must always refer to the tool description to understand how to use it correctly.
182
+ </virtual-try-on-notes>
183
  """
184
 
185
  def __init__(
 
551
  return (
552
  {
553
  "type": "text",
554
+ "text": f"{image_label}_url: {image_url}",
555
  },
556
  {
557
  "type": "image_url",