-
Notifications
You must be signed in to change notification settings - Fork 290
Expand file tree
/
Copy pathIModel.cs
More file actions
92 lines (77 loc) · 3.53 KB
/
IModel.cs
File metadata and controls
92 lines (77 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Microsoft">
// Copyright (c) Microsoft. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace Microsoft.AI.Foundry.Local;
using System.Threading;
using System.Threading.Tasks;
public interface IModel
{
string Id { get; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1716:Identifiers should not match keywords",
Justification = "Alias is a suitable name in this context.")]
string Alias { get; }
ModelInfo Info { get; }
Task<bool> IsCachedAsync(CancellationToken? ct = null);
Task<bool> IsLoadedAsync(CancellationToken? ct = null);
/// <summary>
/// Download the model to local cache if not already present.
/// </summary>
/// <param name="downloadProgress">
/// Optional progress callback for download progress.
/// Percentage download (0 - 100.0) is reported.</param>
/// <param name="ct">Optional cancellation token.</param>
Task DownloadAsync(Action<float>? downloadProgress = null,
CancellationToken? ct = null);
/// <summary>
/// Gets the model path if cached.
/// </summary>
/// <param name="ct">Optional cancellation token.</param>
/// <returns>Path of model directory.</returns>
Task<string> GetPathAsync(CancellationToken? ct = null);
/// <summary>
/// Load the model into memory if not already loaded.
/// </summary>
/// <param name="ct">Optional cancellation token.</param>
Task LoadAsync(CancellationToken? ct = null);
/// <summary>
/// Remove the model from the local cache.
/// </summary>
/// <param name="ct">Optional cancellation token.</param>
Task RemoveFromCacheAsync(CancellationToken? ct = null);
/// <summary>
/// Unload the model if loaded.
/// </summary>
/// <param name="ct">Optional cancellation token.</param>
Task UnloadAsync(CancellationToken? ct = null);
/// <summary>
/// Get an OpenAI API based ChatClient
/// </summary>
/// <param name="ct">Optional cancellation token.</param>
/// <returns>OpenAI.ChatClient</returns>
Task<OpenAIChatClient> GetChatClientAsync(CancellationToken? ct = null);
/// <summary>
/// Get an OpenAI API based AudioClient
/// </summary>
/// <param name="ct">Optional cancellation token.</param>
/// <returns>OpenAI.AudioClient</returns>
Task<OpenAIAudioClient> GetAudioClientAsync(CancellationToken? ct = null);
/// <summary>
/// Get an OpenAI API based EmbeddingClient
/// </summary>
/// <param name="ct">Optional cancellation token.</param>
/// <returns>OpenAI.EmbeddingClient</returns>
Task<OpenAIEmbeddingClient> GetEmbeddingClientAsync(CancellationToken? ct = null);
/// <summary>
/// Variants of the model that are available. Variants of the model are optimized for different devices.
/// </summary>
IReadOnlyList<IModel> Variants { get; }
/// <summary>
/// Select a model variant from <see cref="Variants"/> to use for <see cref="IModel"/> operations.
/// An IModel from `Variants` can also be used directly.
/// </summary>
/// <param name="variant">Model variant to select. Must be one of the variants in <see cref="Variants"/>.</param>
/// <exception cref="FoundryLocalException">If variant is not valid for this model.</exception>
void SelectVariant(IModel variant);
}