-
Notifications
You must be signed in to change notification settings - Fork 22
/
StudioAPI.ts
168 lines (147 loc) · 6.02 KB
/
StudioAPI.ts
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/**********************************************************************
* Copyright (C) 2024 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
***********************************************************************/
import type { ModelInfo } from './models/IModelInfo';
import type { QueryState } from './models/IPlaygroundQueryState';
import type { ApplicationCatalog } from './models/IApplicationCatalog';
import type { PlaygroundState } from './models/IPlaygroundState';
import type { TelemetryTrustedValue } from '@podman-desktop/api';
import type { ApplicationState } from './models/IApplicationState';
import type { Task } from './models/ITask';
import type { LocalRepository } from './models/ILocalRepository';
import type { InferenceServer } from './models/IInference';
import type { RequestOptions } from './models/RequestOptions';
import type { Language } from 'postman-code-generators';
import type { CreationInferenceServerOptions } from './models/InferenceServerConfig';
import type { ModelOptions } from './models/IModelOptions';
import type { Conversation } from './models/IPlaygroundMessage';
import type { PlaygroundV2 } from './models/IPlaygroundV2';
export abstract class StudioAPI {
abstract ping(): Promise<string>;
abstract getCatalog(): Promise<ApplicationCatalog>;
abstract pullApplication(recipeId: string, modelId: string): Promise<void>;
abstract openURL(url: string): Promise<boolean>;
abstract openFile(file: string): Promise<boolean>;
/**
* Get the information of models saved locally into the user's directory
*/
abstract getModelsInfo(): Promise<ModelInfo[]>;
/**
* Delete the folder containing the model from local storage
*/
abstract requestRemoveLocalModel(modelId: string): Promise<void>;
/**
* @deprecated
*/
abstract startPlayground(modelId: string): Promise<void>;
/**
* @deprecated
*/
abstract stopPlayground(modelId: string): Promise<void>;
/**
* @deprecated
*/
abstract askPlayground(modelId: string, prompt: string): Promise<number>;
/**
* @deprecated
*/
abstract getPlaygroundQueriesState(): Promise<QueryState[]>;
/**
* @deprecated
*/
abstract getPlaygroundsState(): Promise<PlaygroundState[]>;
abstract getModelsDirectory(): Promise<string>;
abstract navigateToContainer(containerId: string): Promise<void>;
abstract navigateToPod(podId: string): Promise<void>;
abstract getApplicationsState(): Promise<ApplicationState[]>;
abstract requestRemoveApplication(recipeId: string, modelId: string): Promise<void>;
abstract requestRestartApplication(recipeId: string, modelId: string): Promise<void>;
abstract requestOpenApplication(recipeId: string, modelId: string): Promise<void>;
abstract telemetryLogUsage(eventName: string, data?: Record<string, unknown | TelemetryTrustedValue>): Promise<void>;
abstract telemetryLogError(eventName: string, data?: Record<string, unknown | TelemetryTrustedValue>): Promise<void>;
abstract getLocalRepositories(): Promise<LocalRepository[]>;
abstract getTasks(): Promise<Task[]>;
/**
* Open the VSCode editor
* @param directory the directory to open the editor from
*/
abstract openVSCode(directory: string): Promise<void>;
/**
* Download a model from the catalog
* @param modelId the id of the model we want to download
*/
abstract downloadModel(modelId: string): Promise<void>;
/**
* Get inference servers
*/
abstract getInferenceServers(): Promise<InferenceServer[]>;
/**
* Start an inference server
* @param options The options to use
*/
abstract createInferenceServer(options: CreationInferenceServerOptions): Promise<void>;
/**
* Start an inference server
* @param containerId the container id of the inference server
*/
abstract startInferenceServer(containerId: string): Promise<void>;
/**
* Stop an inference server
* @param containerId the container id of the inference server
*/
abstract stopInferenceServer(containerId: string): Promise<void>;
/**
* Return a free random port on the host machine
*/
abstract getHostFreePort(): Promise<number>;
/**
* Submit a user input to the Playground linked to a conversation, model, and inference server
* @param containerId the container id of the inference server we want to use
* @param modelId the model to use
* @param conversationId the conversation to input the message in
* @param userInput the user input, e.g. 'What is the capital of France ?'
* @param options the options for the model, e.g. temperature
*/
abstract submitPlaygroundMessage(
containerId: string,
modelId: string,
conversationId: string,
userInput: string,
options?: ModelOptions,
): Promise<void>;
/**
* Return the conversations
*/
abstract getPlaygroundConversations(): Promise<Conversation[]>;
/**
* Create a new conversation and return a conversationId
*/
abstract createPlaygroundConversation(): Promise<string>;
/**
* Return the list of supported languages to generate code from.
*/
abstract getSnippetLanguages(): Promise<Language[]>;
/**
* return a code snippet as a string matching the arguments and options provided
* @param options the options for the request
* @param language the language to use
* @param variant the variant of the language
*/
abstract createSnippet(options: RequestOptions, language: string, variant: string): Promise<string>;
abstract createPlayground(name: string, model: ModelInfo): Promise<void>;
abstract getPlaygroundsV2(): Promise<PlaygroundV2[]>;
}