TheWineStain / TWS_service.py
obaes's picture
Upload 13 files
64deae3 verified
import gradio as gr
import TWS_fonctions
import os
thecss="""
.gradio-container {
background-image: url('/gradio_api/file/wine.png');
background: url('/gradio_api/file/wine.png'); /* Fallback for older browsers/consistency */
background-size: cover;
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;
color: white!important;
background-color: green; /* Fallback color */
}
.gradio-container h1 {
font-size: 36px !important;color: white!important;
}
.gradio-container button {
font-size: 12px !important;color: white!important;font-weight: bold!important;
}
.gradio-container p {
font-size: 18px !important;color: white!important;
}
#title {font-size: 36px !important;color:white !important;}
#title-button {font-size: 36px !important;color:white !important;}
.title {font-size: 36px !important;color:white !important;}
#description {font-size: 36px !important;color:white !important;}
#description-button {font-size: 36px !important;color:white !important;}
.description {font-size: 36px !important;color:white !important;}
#texte {font-size: 36px !important;color:white !important;}
#texte-button {font-size: 36px !important;color:white !important;}
.texte {font-size: 36px !important;color:white !important;}
/* Styles pour le texte Markdown */
.gradio-container .gradio-description {
color: white!important; /* Applique le blanc à tout le contenu du Markdown */
}
.gradio-container .gradio-markdown h1,
.gradio-container .gradio-markdown h2,
.gradio-container .gradio-markdown h3,
.gradio-container .gradio-markdown h4,
.gradio-container .gradio-markdown p,
.gradio-container .gradio-markdown li,
.gradio-container .gradio-markdown strong {
color: white !important;
}
/* Si vos images Markdown sont trop grandes, vous pouvez les redimensionner */
.gradio-container .gradio-markdown img {
max-width: 100%; /* Empêche les images de déborder */
height: auto;
display: block; /* Pour centrer si besoin */
margin: 0 auto; /* Pour centrer l'image */
}
element.style {
color: white!important;
}
"""
#TWS_fonctions.playsequene()
#ajout bouteille(s) stockée dans la cave
add_to_cellar = gr.Interface(
fn=TWS_fonctions.add_to_cellar,
inputs=gr.Textbox("add 12 bottles of hautmarbuzet", label="details"),
outputs=[gr.Textbox(label="result")],
title="function add_to_cellar",
description="add a bottle to the cellar",
api_name="add_to_cellar",
flagging_mode="never",
css=thecss
)
#retrait bouteille(s) stockée dans la cave
remove_from_cellar = gr.Interface(
fn=TWS_fonctions.remove_from_cellar,
inputs=gr.Textbox("remove 12 bottles of hautmarbuzet", label="details"),
outputs=[gr.Textbox(label="result")],
title="function remove_from_cellar",
description="remove a bottle from the cellar",
api_name="remove_from_cellar",
flagging_mode="never",
css=thecss
)
#get nombre de bouteille(s) stockée dans la cave
cellar_inventory = gr.Interface(
fn=TWS_fonctions.cellar_inventory,
inputs=gr.Textbox("how many bottles do I have in the cellar", label="details"),
outputs=[gr.Textbox(label="result")],
title="function cellar_inventory",
description="list the number of bottles in the cellar",
api_name="cellar_inventory",
flagging_mode="never",
css=thecss
)
#trouve des informations (web) sur une bouteille sur la base du texte ou d’une image
info_bottle = gr.Interface(
fn=TWS_fonctions.info_bottle,
inputs=gr.Image(type="pil"),
outputs=[gr.Textbox(label="result")],
title="function info_bottle",
description="find the information on the bottle",
api_name="info_bottle",
flagging_mode="never",
css=thecss
)
#add a personal ratings on a bottle (text)
add_commment_bottle = gr.Interface(
fn=TWS_fonctions.add_commment_bottle,
inputs=[gr.Textbox("I loved this vintage of 2023 Hautmarbuzet", label="details")],
outputs=[gr.Textbox(label="result")],
title="function add_commment_bottle",
description="add a comment on a bottle",
api_name="add_commment_bottle",
flagging_mode="never",
css=thecss
)
#add a personal ratings on a bottle (text or images)
add_commment_bottle_image = gr.Interface(
fn=TWS_fonctions.add_commment_bottle_image,
inputs=[gr.Textbox("I loved this vintage of 2023 Hautmarbuzet", label="details"),gr.Image(type="pil",label="photo", value=None)],
outputs=[gr.Textbox(label="result")],
title="function add_commment_bottle_image",
description="add a comment on a bottle",
api_name="add_commment_bottle_image",
flagging_mode="never",
css=thecss
)
#reminds me my personnel ratings on a bottle (text)
get_commment_bottle = gr.Interface(
fn=TWS_fonctions.get_commment_bottle,
inputs=[gr.Textbox("What is my assessment of the Sierra Nevada?", label="details")],
outputs=[gr.Textbox(label="result")],
title="function get_commment_bottle",
description="gives feedback on the bottle",
api_name="get_commment_bottle",
flagging_mode="never",
css=thecss
)
#reminds me my personnel ratings on a bottle (text or image)
get_commment_bottle_image = gr.Interface(
fn=TWS_fonctions.get_commment_bottle_image,
inputs=[gr.Image(type="pil",label="photo", value=None)],
outputs=[gr.Textbox(label="result")],
title="function get_commment_bottle_image",
description="gives feedback on the bottle",
api_name="get_commment_bottle_image",
flagging_mode="never",
css=thecss
)
"""
#find data on a bottle
find_data_bottle = gr.Interface(
fn=TWS_fonctions.find_data_bottle,
inputs=[gr.Textbox("haut marbuzet 2019", label="details")],
outputs=[gr.Textbox(label="result")],
title="function find_data_bottle",
description="find data on bottle",
api_name="find_data_bottle",
flagging_mode="never",
css=thecss
)
"""
demo = gr.Blocks(css=thecss)
with demo:
gr.Markdown(
"""
# <h1 style='color:white;'>🔮World's first cellar and wine comments llm app
![](/gradio_api/file/winebot.jpg)
""")
gr.TabbedInterface(
[add_to_cellar, remove_from_cellar, cellar_inventory, info_bottle, add_commment_bottle,add_commment_bottle_image, get_commment_bottle,get_commment_bottle_image],
["Add to cellar", "Remove from cellar", "Cellar inventory", "Recognize a bottle", "comment a bottle","comment a bottle image", "get wine comments","get wine comments image"]
)
gr.TabItem("Usage in Clients", elem_id="texte", elem_classes="texte" )
gr.Markdown(
"<h1 style='color:white;'>To add this MCP to clients that support SSE (eg. Cursor, Windsurf, Cline), add the following to your MCP Config</h1>"
)
gr.Code(
"""{
"mcpServers": {
"TheWineStain": {
"url": "https://huggingface.co/spaces/Agents-MCP-Hackathon/TheWineStain/gradio_api/mcp/sse"
}
}
}"""
)
gr.Markdown(
"<h1 style='color:white;'>*Experimental stdio support* : For clients that only support stdio (eg. Claude Desktop), first install node.js. Then, you can use the following in your MCP Config</h1>"
)
gr.Code(
"""{
"mcpServers": {
"TheWineStain": {
"command": "npx",
"args": [
"mcp-remote",
"https://huggingface.co/spaces/Agents-MCP-Hackathon/TheWineStain/gradio_api/mcp/sse",
"--transport",
"sse-only"
]
}
}
}"""
)
gr.Markdown(
"""<h1 style='color:white;'>Want to use it in your Claude Desktop? Add this to your **claude_desktop_config.json**</h1>"""
)
gr.Code(
"""{
"mcpServers": {
"TheWineStain": {
"command": "npx",
"args": [
"mcp-remote",
"https://huggingface.co/spaces/Agents-MCP-Hackathon/TheWineStain/gradio_api/mcp/sse",
"--transport",
"sse-only"
]
}
}
}"""
)
gr.HTML(
"""
<video width="1000" controls Autoplay=autoplay>
<source src="http://127.0.0.1:7860/gradio_api/file/cellar_video.mov" type="video/mp4">
</video>
"""
)
gr.Markdown(
"""##
<h1 style='color:white;'> ### Built from the Ground Up for LLMs — This Is wine testing and comments Reinvented.
Use via API or MCP 🚀 · Powered by HF, SambaNova,Render + PostgreSQL · Built with Gradio 🟧</h1>
"""
)
gr.Markdown(
"""
# <h1 style='color:white;'>🔮World's first cellar and wine comments llm app</h1>
![](/gradio_api/file/winebot.jpg)
""")
if __name__ == "__main__":
demo.launch(mcp_server=True,server_name="0.0.0.0",allowed_paths=["/"])