Advanced intent recognition with confidence scoring and classification.
from mcp_agent.app import MCPApp from mcp_agent.workflows.intent_classifier.intent_classifier_base import Intent from mcp_agent.workflows.intent_classifier.intent_classifier_llm_openai import OpenAILLMIntentClassifier from mcp_agent.workflows.intent_classifier.intent_classifier_embedding_openai import OpenAIEmbeddingIntentClassifier app = MCPApp(name="intent_example") async with app.run() as intent_app: context = intent_app.context embedding_intent_classifier = OpenAIEmbeddingIntentClassifier( intents=[ Intent( name="greeting", description="A friendly greeting", examples=["Hello", "Hi there", "Good morning"], ), Intent( name="farewell", description="A friendly farewell", examples=["Goodbye", "See you later", "Take care"], ), ], context=context, ) results = await embedding_intent_classifier.classify( request="Hello, how are you?", top_k=1, ) print(f"Embedding-based Intent classification results: {results}") llm_intent_classifier = OpenAILLMIntentClassifier( intents=[ Intent( name="greeting", description="A friendly greeting", examples=["Hello", "Hi there", "Good morning"], ), Intent( name="farewell", description="A friendly farewell", examples=["Goodbye", "See you later", "Take care"], ), ], context=context, ) results = await llm_intent_classifier.classify( request="Hello, how are you?", top_k=1, ) print(f"LLM-based Intent classification results: {results}")