Spaces:
Runtime error
Runtime error
Greg Thompson commited on
Commit ·
fc4d327
1
Parent(s): 71befd1
Update test cases for intent-classification endpoint
Browse filesFiles changed (3)
17 unmodified lines1819202122232464 unmodified lines899091929394959697989910010117 unmodified linesfrom mathtext_fastapi.logging import prepare_message_data_for_loggingfrom mathtext_fastapi.conversation_manager import manage_conversation_responsefrom mathtext_fastapi.nlu import evaluate_message_with_nlufrom mathtext_fastapi.nlu import run_intent_classification
app = FastAPI()
64 unmodified lines return JSONResponse(context)
@app.post("/intent-classification")def intent_classification_ep(content: Text = None): ml_response = run_intent_classification(content.content) content = {"message": ml_response} return JSONResponse(content=content)
@app.post("/nlu")async def evaluate_user_message_with_nlu_api(request: Request): """ Calls nlu evaluation and returns the nlu_response144 unmodified lines145146147148149150148149150144 unmodified lines number_api_resp = text2int(message_text.lower())
if number_api_resp == 32202: print("MESSAGE TEXT") print(message_text) print("============") intent_api_response = run_intent_classification(message_text) if intent_api_response['data']: return intent_api_response43 unmodified lines44454647474849507 unmodified lines5859606162636443 unmodified lines print(f"Case: {sample_answer}") b_string = add_message_text_to_sample_object(sample_answer)
if endpoint == 'sentiment-analysis' or endpoint == 'text2int': if endpoint == 'sentiment-analysis' or endpoint == 'text2int' or endpoint =='intent-classification': request = requests.post( url=f'http://localhost:7860/{endpoint}', json={'content': sample_answer}7 unmodified lines print(request)
run_simulated_request('intent-classification', 'exit')run_simulated_request('sentiment-analysis', 'I reject it')run_simulated_request('text2int', 'seven thousand nine hundred fifty seven')run_simulated_request('nlu', 'test message')app.py+8
mathtext_fastapi/nlu.py-3
scripts/make_request.py+2-1