Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,17 +5,21 @@ import torch
|
|
5 |
# Agent 1: Intent Classifier
|
6 |
intent_classifier = pipeline("text-classification", model="MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli")
|
7 |
|
|
|
8 |
def detect_intent(text):
|
9 |
labels = {
|
10 |
"weather": "The user wants to know the weather.",
|
11 |
"faq": "The user is asking for help.",
|
12 |
"smalltalk": "The user is making casual conversation."
|
13 |
}
|
14 |
-
|
|
|
15 |
for label, hypothesis in labels.items():
|
16 |
-
result = intent_classifier(
|
17 |
-
|
18 |
-
|
|
|
|
|
19 |
|
20 |
# Agent 2: Domain Logic
|
21 |
def handle_logic(intent):
|
|
|
5 |
# Agent 1: Intent Classifier
|
6 |
intent_classifier = pipeline("text-classification", model="MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli")
|
7 |
|
8 |
+
|
9 |
def detect_intent(text):
|
10 |
labels = {
|
11 |
"weather": "The user wants to know the weather.",
|
12 |
"faq": "The user is asking for help.",
|
13 |
"smalltalk": "The user is making casual conversation."
|
14 |
}
|
15 |
+
best_intent = "smalltalk"
|
16 |
+
best_score = 0
|
17 |
for label, hypothesis in labels.items():
|
18 |
+
result = intent_classifier(text=text, text_pair=hypothesis)[0]
|
19 |
+
if result['label'] == 'ENTAILMENT' and result['score'] > best_score:
|
20 |
+
best_score = result['score']
|
21 |
+
best_intent = label
|
22 |
+
return best_intent
|
23 |
|
24 |
# Agent 2: Domain Logic
|
25 |
def handle_logic(intent):
|