Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,37 +1,27 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from gradio_client import Client
|
| 3 |
|
| 4 |
-
|
| 5 |
-
llm_client = Client("hysts/zephyr-7b")
|
| 6 |
-
|
| 7 |
-
def create_compliment(text_description: str) -> str:
|
| 8 |
"""
|
| 9 |
-
|
| 10 |
|
| 11 |
Args:
|
| 12 |
-
|
|
|
|
| 13 |
"""
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
# We send the prompt to the language model to get our final result.
|
| 17 |
-
# CORRECTED api_name from "/add_text" to "/predict"
|
| 18 |
-
compliment = llm_client.predict(
|
| 19 |
-
prompt=prompt,
|
| 20 |
-
max_new_tokens=128,
|
| 21 |
-
api_name="/predict"
|
| 22 |
-
)
|
| 23 |
-
|
| 24 |
-
return compliment
|
| 25 |
|
| 26 |
-
# Create
|
| 27 |
iface = gr.Interface(
|
| 28 |
-
fn=
|
| 29 |
-
inputs=
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
| 33 |
)
|
| 34 |
|
| 35 |
-
# Launch the app as an MCP server
|
| 36 |
if __name__ == "__main__":
|
| 37 |
iface.launch(mcp_server=True)
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
+
def add_numbers(a: float, b: float) -> float:
|
|
|
|
|
|
|
|
|
|
| 4 |
"""
|
| 5 |
+
Adds two numbers together.
|
| 6 |
|
| 7 |
Args:
|
| 8 |
+
a: The first number.
|
| 9 |
+
b: The second number.
|
| 10 |
"""
|
| 11 |
+
return a + b
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
# Create a simple interface for our tool
|
| 14 |
iface = gr.Interface(
|
| 15 |
+
fn=add_numbers,
|
| 16 |
+
inputs=[
|
| 17 |
+
gr.Number(label="First Number"),
|
| 18 |
+
gr.Number(label="Second Number")
|
| 19 |
+
],
|
| 20 |
+
outputs=gr.Number(label="Sum"),
|
| 21 |
+
title="Addition MCP Server",
|
| 22 |
+
description="A simple MCP tool that adds two numbers. [1, 2]"
|
| 23 |
)
|
| 24 |
|
| 25 |
+
# Launch the app as an MCP server. This is the most important part.
|
| 26 |
if __name__ == "__main__":
|
| 27 |
iface.launch(mcp_server=True)
|