Greg Thompson commited on
Commit
f7dd3a5
1 Parent(s): 809d03c

Update test cases for intent-classification endpoint

Browse files
Files changed (3) hide show
  1. app.py +8 -0
  2. mathtext_fastapi/nlu.py +0 -3
  3. scripts/make_request.py +2 -1
app.py CHANGED
@@ -18,6 +18,7 @@ from pydantic import BaseModel
18
  from mathtext_fastapi.logging import prepare_message_data_for_logging
19
  from mathtext_fastapi.conversation_manager import manage_conversation_response
20
  from mathtext_fastapi.nlu import evaluate_message_with_nlu
 
21
 
22
  app = FastAPI()
23
 
@@ -88,6 +89,13 @@ async def programmatic_message_manager(request: Request):
88
  return JSONResponse(context)
89
 
90
 
 
 
 
 
 
 
 
91
  @app.post("/nlu")
92
  async def evaluate_user_message_with_nlu_api(request: Request):
93
  """ Calls nlu evaluation and returns the nlu_response
 
18
  from mathtext_fastapi.logging import prepare_message_data_for_logging
19
  from mathtext_fastapi.conversation_manager import manage_conversation_response
20
  from mathtext_fastapi.nlu import evaluate_message_with_nlu
21
+ from mathtext_fastapi.nlu import run_intent_classification
22
 
23
  app = FastAPI()
24
 
 
89
  return JSONResponse(context)
90
 
91
 
92
+ @app.post("/intent-classification")
93
+ def intent_classification_ep(content: Text = None):
94
+ ml_response = run_intent_classification(content.content)
95
+ content = {"message": ml_response}
96
+ return JSONResponse(content=content)
97
+
98
+
99
  @app.post("/nlu")
100
  async def evaluate_user_message_with_nlu_api(request: Request):
101
  """ Calls nlu evaluation and returns the nlu_response
mathtext_fastapi/nlu.py CHANGED
@@ -145,9 +145,6 @@ def evaluate_message_with_nlu(message_data):
145
  number_api_resp = text2int(message_text.lower())
146
 
147
  if number_api_resp == 32202:
148
- print("MESSAGE TEXT")
149
- print(message_text)
150
- print("============")
151
  intent_api_response = run_intent_classification(message_text)
152
  if intent_api_response['data']:
153
  return intent_api_response
 
145
  number_api_resp = text2int(message_text.lower())
146
 
147
  if number_api_resp == 32202:
 
 
 
148
  intent_api_response = run_intent_classification(message_text)
149
  if intent_api_response['data']:
150
  return intent_api_response
scripts/make_request.py CHANGED
@@ -44,7 +44,7 @@ def run_simulated_request(endpoint, sample_answer, context=None):
44
  print(f"Case: {sample_answer}")
45
  b_string = add_message_text_to_sample_object(sample_answer)
46
 
47
- if endpoint == 'sentiment-analysis' or endpoint == 'text2int':
48
  request = requests.post(
49
  url=f'http://localhost:7860/{endpoint}',
50
  json={'content': sample_answer}
@@ -58,6 +58,7 @@ def run_simulated_request(endpoint, sample_answer, context=None):
58
  print(request)
59
 
60
 
 
61
  run_simulated_request('sentiment-analysis', 'I reject it')
62
  run_simulated_request('text2int', 'seven thousand nine hundred fifty seven')
63
  run_simulated_request('nlu', 'test message')
 
44
  print(f"Case: {sample_answer}")
45
  b_string = add_message_text_to_sample_object(sample_answer)
46
 
47
+ if endpoint == 'sentiment-analysis' or endpoint == 'text2int' or endpoint =='intent-classification':
48
  request = requests.post(
49
  url=f'http://localhost:7860/{endpoint}',
50
  json={'content': sample_answer}
 
58
  print(request)
59
 
60
 
61
+ run_simulated_request('intent-classification', 'exit')
62
  run_simulated_request('sentiment-analysis', 'I reject it')
63
  run_simulated_request('text2int', 'seven thousand nine hundred fifty seven')
64
  run_simulated_request('nlu', 'test message')