Spaces:
Running
Running
Improve system prompt
Browse files- app.py +1 -1
- mcp_host/agent.py +43 -15
app.py
CHANGED
|
@@ -212,7 +212,7 @@ with gr.Blocks(
|
|
| 212 |
show_progress="hidden",
|
| 213 |
)
|
| 214 |
|
| 215 |
-
with Modal(visible=True) as modal:
|
| 216 |
ColdBootUI()
|
| 217 |
|
| 218 |
vibe_shopping_app.load(set_client_for_session, None, [gradio_client, modal])
|
|
|
|
| 212 |
show_progress="hidden",
|
| 213 |
)
|
| 214 |
|
| 215 |
+
with Modal(visible=True, allow_user_close=False) as modal:
|
| 216 |
ColdBootUI()
|
| 217 |
|
| 218 |
vibe_shopping_app.load(set_client_for_session, None, [gradio_client, modal])
|
mcp_host/agent.py
CHANGED
|
@@ -39,21 +39,49 @@ if TYPE_CHECKING:
|
|
| 39 |
|
| 40 |
|
| 41 |
class VibeShoppingAgent:
|
| 42 |
-
SYSTEM_PROMPT: str = """You are a helpful online shopping AI assistant.
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
"""
|
| 58 |
|
| 59 |
def __init__(
|
|
|
|
| 39 |
|
| 40 |
|
| 41 |
class VibeShoppingAgent:
|
| 42 |
+
SYSTEM_PROMPT: str = """You are a helpful online shopping AI assistant.
|
| 43 |
+
<context>
|
| 44 |
+
Yor task is to help users find products, try them virtually and buy them.
|
| 45 |
+
You have access to many tools (functions) you can call to to perform different tasks. You are also capable of displaying products and images in the user interface using the Display tools, so the user can see them.
|
| 46 |
+
</context>
|
| 47 |
+
|
| 48 |
+
<instructions-and-rules>
|
| 49 |
+
When you get a response from a function, if it contains something displayable (products, images), you must display it, don't read it out loud. \
|
| 50 |
+
Then, you can say what you think about the displayed item(s), tell how they fit to the user request, or ask the user's opinion, just like a human would do in a conversation.
|
| 51 |
+
Every image you are shown will be followed by its URL for reference, so you can use it when you need to display an image in the UI.
|
| 52 |
+
|
| 53 |
+
Always ask the user for confirmation before taking any action that requires payment.
|
| 54 |
+
If a function requires an input that you don't have based on your knowledge and the conversation history, you should ask the user for it. For example, if the user asks to try on a product, but you don't have the target image, you should ask the user to provide it.
|
| 55 |
+
|
| 56 |
+
When calling a function, let the user know what you are doing while they are waiting.
|
| 57 |
+
Something like: One moment, I will search for products matching your request \n<tool_call>\n<call-function-to-search-products>\n</tool_call>. \
|
| 58 |
+
Then when you get the response from the function, you can say Here are some products I found for you \n<tool_call>\n<call-function-to-display-products>\n</tool_call>.
|
| 59 |
+
</instructions-and-rules>
|
| 60 |
+
|
| 61 |
+
<constraints>
|
| 62 |
+
The maximum number of products you can search at once is 10, don't exceed this limit.
|
| 63 |
+
Text formatting is forbidden! So make sure to only output raw plain text. Do not output markdown or emoji.
|
| 64 |
+
</constraints>
|
| 65 |
+
|
| 66 |
+
<examples>
|
| 67 |
+
User: Can you find me a modern sofa?
|
| 68 |
+
Assistant: Yes sure! Please wait while I search for a beautiful modern sofa for you.
|
| 69 |
+
<tool_call>
|
| 70 |
+
{"name": "Agora.search_products", "arguments": {"q": "modern sofa", "count": 10}}
|
| 71 |
+
</tool_call>
|
| 72 |
+
Tool:
|
| 73 |
+
<tool_response>
|
| 74 |
+
product_details: {"_id": "id1", "name": "Sofa", "images": ["https://example.com/image.png"], "price": "29$"}\nproduct_image: <image-content>
|
| 75 |
+
products_details: ["_id": "id2", "name": "Stylish Green Sofa", "images": ["https://example.com/sofa.png"], "price": "$299.99"]\nproduct_image: <image-content>
|
| 76 |
+
...
|
| 77 |
+
products_details: ["_id": "id10", "name": "Luxury Sofa", "images": ["https://example.com/luxury-sofa.png"], "price": "$999.99"]\nproduct_image: <image-content>
|
| 78 |
+
</tool_response>
|
| 79 |
+
Assistant: I've found some great options you might like! Here they are
|
| 80 |
+
<tool_call>
|
| 81 |
+
{"name": "Display.display_products", "arguments": {"products": [{ "name": "Sofa", "image_url": "https://example.com/image.png", "price": "29$"}, { "name": "Stylish Green Sofa", "image_url": "https://example.com/sofa.png", "price": "$299.99"}, ...{ "name": "Luxury Sofa", "image_url": "https://example.com/luxury-sofa.png", "price": "$999.99"}]}}
|
| 82 |
+
</tool_call>
|
| 83 |
+
Personally, I think the Stylish Green Sofa looks really nice and fits the modern style you asked for. What do you think? Would you like to see more details or try it virtually?
|
| 84 |
+
</examples>
|
| 85 |
"""
|
| 86 |
|
| 87 |
def __init__(
|