| | | 1 | | using Intentum.Core.Behavior; |
| | | 2 | | using Intentum.Core.Contracts; |
| | | 3 | | using Intentum.Core.Intents; |
| | | 4 | | |
| | | 5 | | namespace Intentum.Testing; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Stub implementation of <see cref="IIntentModel"/> for unit tests. |
| | | 9 | | /// Returns a configurable intent (name, confidence, reasoning) for any input. |
| | | 10 | | /// Use when testing policy, chaining, or pipeline without a real model. |
| | | 11 | | /// </summary> |
| | | 12 | | public sealed class StubIntentModel : IIntentModel |
| | | 13 | | { |
| | | 14 | | private readonly Func<BehaviorSpace, Intent> _infer; |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Creates a stub that always returns the same intent. |
| | | 18 | | /// </summary> |
| | 0 | 19 | | public StubIntentModel(string intentName, double confidenceScore = 0.8, string? reasoning = null) |
| | 0 | 20 | | { |
| | 0 | 21 | | var confidence = IntentConfidence.FromScore(confidenceScore); |
| | 0 | 22 | | _infer = _ => new Intent(intentName, [], confidence, reasoning); |
| | 0 | 23 | | } |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Creates a stub that uses a custom function to produce intent from behavior space. |
| | | 27 | | /// </summary> |
| | 0 | 28 | | public StubIntentModel(Func<BehaviorSpace, Intent> infer) |
| | 0 | 29 | | { |
| | 0 | 30 | | _infer = infer ?? throw new ArgumentNullException(nameof(infer)); |
| | 0 | 31 | | } |
| | | 32 | | |
| | | 33 | | /// <inheritdoc /> |
| | | 34 | | public Intent Infer(BehaviorSpace behaviorSpace, BehaviorVector? precomputedVector = null) |
| | 0 | 35 | | => _infer(behaviorSpace); |
| | | 36 | | } |