Spaces:
Sleeping
Sleeping
Saurabh Zinjad commited on
Commit ·
1db7322
1
Parent(s): 8217568
Add addition functionality and integrate into Gradio interface
Browse files
app.py
CHANGED
|
@@ -28,6 +28,20 @@ def sentiment_analysis(text: str) -> dict:
|
|
| 28 |
}
|
| 29 |
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
# Create the Gradio interface
|
| 32 |
demo = gr.Interface(
|
| 33 |
fn=sentiment_analysis,
|
|
@@ -37,6 +51,19 @@ demo = gr.Interface(
|
|
| 37 |
description="Analyze the sentiment of text using TextBlob",
|
| 38 |
)
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
# Launch the interface and MCP server
|
| 41 |
if __name__ == "__main__":
|
| 42 |
-
|
|
|
|
| 28 |
}
|
| 29 |
|
| 30 |
|
| 31 |
+
def add_two_number(a: int, b: int) -> int:
|
| 32 |
+
"""
|
| 33 |
+
Add two numbers.
|
| 34 |
+
|
| 35 |
+
Args:
|
| 36 |
+
a (int): First number
|
| 37 |
+
b (int): Second number
|
| 38 |
+
|
| 39 |
+
Returns:
|
| 40 |
+
int: The sum of the two numbers
|
| 41 |
+
"""
|
| 42 |
+
return a + b
|
| 43 |
+
|
| 44 |
+
|
| 45 |
# Create the Gradio interface
|
| 46 |
demo = gr.Interface(
|
| 47 |
fn=sentiment_analysis,
|
|
|
|
| 51 |
description="Analyze the sentiment of text using TextBlob",
|
| 52 |
)
|
| 53 |
|
| 54 |
+
demo2 = gr.Interface(
|
| 55 |
+
fn=add_two_number,
|
| 56 |
+
inputs=[gr.Number(), gr.Number()],
|
| 57 |
+
outputs=gr.Number(),
|
| 58 |
+
title="Add Two Numbers",
|
| 59 |
+
description="Add two numbers together",
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
app = gr.TabbedInterface(
|
| 64 |
+
interface_list=[demo, demo2], tab_names=["Function 1", "Function 2"]
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
# Launch the interface and MCP server
|
| 68 |
if __name__ == "__main__":
|
| 69 |
+
app.launch(mcp_server=True)
|