Spaces:
No application file
No application file
Rename chat_mcp_server.py to product_search_mcp_server.py
Browse files- chat_mcp_server.py +0 -7
- product_search_mcp_server.py +27 -0
chat_mcp_server.py
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
|
3 |
-
def greet(name):
|
4 |
-
return "Hello " + name + "!!"
|
5 |
-
|
6 |
-
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
product_search_mcp_server.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from web_scraper import search_your_product
|
3 |
+
|
4 |
+
|
5 |
+
def product_search(query: str) -> str:
|
6 |
+
"""
|
7 |
+
Search for products based on the provided query.
|
8 |
+
|
9 |
+
Args:
|
10 |
+
query (str): The search query for products.
|
11 |
+
|
12 |
+
Returns:
|
13 |
+
str: A message with the search results.
|
14 |
+
"""
|
15 |
+
|
16 |
+
results = search_your_product(query)
|
17 |
+
if not results:
|
18 |
+
return f"No products found for your search: '{query}'. Please try a different query."
|
19 |
+
return f"Here are the products matching your search for '{query}': {results}."
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
demo = gr.Interface(fn=product_search,
|
25 |
+
inputs=[],
|
26 |
+
outputs="number")
|
27 |
+
demo.launch(mcp_server=True) # exposes an MCP schema automatically
|