You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

IModelService.cs 2.5 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using LLama.Web.Common;
  2. using LLama.Web.Models;
  3. namespace LLama.Web.Services
  4. {
  5. /// <summary>
  6. /// Service for managing language Models
  7. /// </summary>
  8. public interface IModelService
  9. {
  10. /// <summary>
  11. /// Gets the model with the specified name.
  12. /// </summary>
  13. /// <param name="modelName">Name of the model.</param>
  14. Task<LLamaModel> GetModel(string modelName);
  15. /// <summary>
  16. /// Loads a model from a ModelConfig object.
  17. /// </summary>
  18. /// <param name="modelOptions">The model configuration.</param>
  19. Task<LLamaModel> LoadModel(ModelOptions modelOptions);
  20. /// <summary>
  21. /// Loads all models found in appsettings.json
  22. /// </summary>
  23. Task LoadModels();
  24. /// <summary>
  25. /// Unloads the model with the specified name.
  26. /// </summary>
  27. /// <param name="modelName">Name of the model.</param>
  28. Task UnloadModel(string modelName);
  29. /// <summary>
  30. /// Unloads all models.
  31. /// </summary>
  32. Task UnloadModels();
  33. /// <summary>
  34. /// Gets a context with the specified identifier
  35. /// </summary>
  36. /// <param name="modelName">Name of the model.</param>
  37. /// <param name="contextName">The context identifier.</param>
  38. Task<LLamaContext> GetContext(string modelName, string contextName);
  39. /// <summary>
  40. /// Removes the context.
  41. /// </summary>
  42. /// <param name="modelName">Name of the model.</param>
  43. /// <param name="contextName">The context identifier.</param>
  44. Task<bool> RemoveContext(string modelName, string contextName);
  45. /// <summary>
  46. /// Creates a context.
  47. /// </summary>
  48. /// <param name="modelName">Name of the model.</param>
  49. /// <param name="contextName">The context identifier.</param>
  50. Task<LLamaContext> CreateContext(string modelName, string contextName);
  51. /// <summary>
  52. /// Gets the or create model and context.
  53. /// This will load a model from disk if not already loaded, and also create the context
  54. /// </summary>
  55. /// <param name="modelName">Name of the model.</param>
  56. /// <param name="contextName">The context identifier.</param>
  57. /// <returns>Both loaded Model and Context</returns>
  58. Task<(LLamaModel, LLamaContext)> GetOrCreateModelAndContext(string modelName, string contextName);
  59. }
  60. }