Spaces:
Running
Running
Upload tool
Browse files- requirements.txt +0 -1
- tool.py +2 -6
requirements.txt
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
smolagents
|
| 2 |
-
torch
|
| 3 |
transformers
|
| 4 |
PyPDF2
|
| 5 |
requests
|
|
|
|
| 1 |
smolagents
|
|
|
|
| 2 |
transformers
|
| 3 |
PyPDF2
|
| 4 |
requests
|
tool.py
CHANGED
|
@@ -12,7 +12,7 @@ class DocumentAnalyzer(Tool):
|
|
| 12 |
name = "analyze_document"
|
| 13 |
description = "Analyzes a PDF document and extracts key information like summary and sentiment"
|
| 14 |
inputs = {'document_url': {'type': 'string', 'description': 'URL to a PDF document'}}
|
| 15 |
-
output_type = "
|
| 16 |
|
| 17 |
def __init__(self):
|
| 18 |
super().__init__()
|
|
@@ -50,8 +50,4 @@ class DocumentAnalyzer(Tool):
|
|
| 50 |
sentiment_analyzer = pipeline("sentiment-analysis")
|
| 51 |
sentiment = sentiment_analyzer(text[:512])[0]
|
| 52 |
|
| 53 |
-
return {
|
| 54 |
-
"summary": summary,
|
| 55 |
-
"sentiment": sentiment['label'],
|
| 56 |
-
"confidence": sentiment['score']
|
| 57 |
-
}
|
|
|
|
| 12 |
name = "analyze_document"
|
| 13 |
description = "Analyzes a PDF document and extracts key information like summary and sentiment"
|
| 14 |
inputs = {'document_url': {'type': 'string', 'description': 'URL to a PDF document'}}
|
| 15 |
+
output_type = "string"
|
| 16 |
|
| 17 |
def __init__(self):
|
| 18 |
super().__init__()
|
|
|
|
| 50 |
sentiment_analyzer = pipeline("sentiment-analysis")
|
| 51 |
sentiment = sentiment_analyzer(text[:512])[0]
|
| 52 |
|
| 53 |
+
return f"Summary: {summary}\nSentiment: {sentiment['label']}\nConfidence: {sentiment['score']:.2f}"
|
|
|
|
|
|
|
|
|
|
|
|