jangmin commited on
Commit
1d09788
·
verified ·
1 Parent(s): d7957bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -25
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import json
2
  import gradio as gr
3
- from gradio_mcp import enable_mcp
4
  from textblob import TextBlob
5
 
6
  def sentiment_analysis(text: str) -> str:
@@ -17,8 +16,8 @@ def sentiment_analysis(text: str) -> str:
17
  sentiment = blob.sentiment
18
 
19
  result = {
20
- "polarity": round(sentiment.polarity, 2), # -1 (negative) to 1 (positive)
21
- "subjectivity": round(sentiment.subjectivity, 2), # 0 (objective) to 1 (subjective)
22
  "assessment": "positive" if sentiment.polarity > 0 else "negative" if sentiment.polarity < 0 else "neutral"
23
  }
24
 
@@ -33,29 +32,11 @@ demo = gr.Interface(
33
  description="Analyze the sentiment of text using TextBlob"
34
  )
35
 
36
- # Enable MCP server with proper configuration
37
- mcp_server = enable_mcp(
38
- demo,
39
- tool_config={
40
- "sentiment_analysis": {
41
- "description": "Analyze the sentiment of the given text. Returns polarity (-1 to 1), subjectivity (0 to 1), and overall assessment (positive/negative/neutral).",
42
- "parameters": {
43
- "type": "object",
44
- "properties": {
45
- "text": {
46
- "type": "string",
47
- "description": "The text to analyze for sentiment"
48
- }
49
- },
50
- "required": ["text"]
51
- }
52
- }
53
- }
54
- )
55
-
56
- # Launch the interface
57
  if __name__ == "__main__":
58
  demo.launch(
59
  server_name="0.0.0.0",
60
- server_port=7860
 
 
61
  )
 
1
  import json
2
  import gradio as gr
 
3
  from textblob import TextBlob
4
 
5
  def sentiment_analysis(text: str) -> str:
 
16
  sentiment = blob.sentiment
17
 
18
  result = {
19
+ "polarity": round(sentiment.polarity, 2),
20
+ "subjectivity": round(sentiment.subjectivity, 2),
21
  "assessment": "positive" if sentiment.polarity > 0 else "negative" if sentiment.polarity < 0 else "neutral"
22
  }
23
 
 
32
  description="Analyze the sentiment of text using TextBlob"
33
  )
34
 
35
+ # Launch with MCP server
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  if __name__ == "__main__":
37
  demo.launch(
38
  server_name="0.0.0.0",
39
+ server_port=7860,
40
+ mcp_server=True,
41
+ debug=True # 디버그 모드 활성화
42
  )