| | | 1 | | using Intentum.AI.Catalog; |
| | | 2 | | using Intentum.AI.Embeddings; |
| | | 3 | | using Intentum.Core.Behavior; |
| | | 4 | | using Intentum.Core.Contracts; |
| | | 5 | | using Intentum.Core.Intents; |
| | | 6 | | using Intentum.Core.Pipeline; |
| | | 7 | | |
| | | 8 | | namespace Intentum.AI.Models; |
| | | 9 | | |
| | | 10 | | /// <summary> |
| | | 11 | | /// Intent model that classifies behavior against a catalog of known intents |
| | | 12 | | /// using embedding cosine similarity (nearest neighbor classification). |
| | | 13 | | /// Returns the actual intent name from the catalog instead of a generic "AI-Inferred-Intent". |
| | | 14 | | /// </summary> |
| | | 15 | | public sealed class CatalogIntentModel : IIntentModel |
| | | 16 | | { |
| | | 17 | | private readonly IntentResolutionPipeline _pipeline; |
| | | 18 | | |
| | 4 | 19 | | public CatalogIntentModel( |
| | 4 | 20 | | IIntentEmbeddingProvider embeddingProvider, |
| | 4 | 21 | | IntentCatalog catalog) |
| | 4 | 22 | | { |
| | 4 | 23 | | var step = new CatalogInferenceStep( |
| | 4 | 24 | | embeddingProvider ?? throw new ArgumentNullException(nameof(embeddingProvider)), |
| | 4 | 25 | | catalog ?? throw new ArgumentNullException(nameof(catalog))); |
| | 2 | 26 | | _pipeline = new IntentResolutionPipeline(step); |
| | 2 | 27 | | } |
| | | 28 | | |
| | | 29 | | /// <inheritdoc /> |
| | | 30 | | public Intent Infer(BehaviorSpace behaviorSpace, BehaviorVector? precomputedVector = null) |
| | 2 | 31 | | => _pipeline.Infer(behaviorSpace, precomputedVector); |
| | | 32 | | } |