Sanchit2207 commited on
Commit
d9a2161
·
verified ·
1 Parent(s): 8be198e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
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
- scores = {}
 
15
  for label, hypothesis in labels.items():
16
- result = intent_classifier({"premise": text, "hypothesis": hypothesis})[0]
17
- scores[label] = result['score'] if result['label'] == 'ENTAILMENT' else 0
18
- return max(scores, key=scores.get)
 
 
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):