@jupyter-ai/jupyternaut 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/message-footer/stop-button.js +1 -1
- package/lib/handler.d.ts +1 -1
- package/lib/handler.js +13 -14
- package/lib/index.js +1 -1
- package/package.json +1 -1
|
@@ -34,7 +34,7 @@ export function StopButton(props) {
|
|
|
34
34
|
}, [model]);
|
|
35
35
|
const onClick = () => {
|
|
36
36
|
// Post request to the stop streaming handler.
|
|
37
|
-
requestAPI('chats/stop_streaming', {
|
|
37
|
+
requestAPI('api/jupyternaut/chats/stop_streaming', {
|
|
38
38
|
method: 'POST',
|
|
39
39
|
body: JSON.stringify({
|
|
40
40
|
message_id: message.id
|
package/lib/handler.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ServerConnection } from '@jupyterlab/services';
|
|
|
2
2
|
/**
|
|
3
3
|
* Call the API extension
|
|
4
4
|
*
|
|
5
|
-
* @param endPoint API REST end point for the extension
|
|
5
|
+
* @param endPoint Full API REST end point path for the extension
|
|
6
6
|
* @param init Initial values for the request
|
|
7
7
|
* @returns The response body interpreted as JSON
|
|
8
8
|
*/
|
package/lib/handler.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { URLExt } from '@jupyterlab/coreutils';
|
|
2
2
|
import { ServerConnection } from '@jupyterlab/services';
|
|
3
|
-
const API_NAMESPACE = 'api/jupyternaut';
|
|
4
3
|
/**
|
|
5
4
|
* Call the API extension
|
|
6
5
|
*
|
|
7
|
-
* @param endPoint API REST end point for the extension
|
|
6
|
+
* @param endPoint Full API REST end point path for the extension
|
|
8
7
|
* @param init Initial values for the request
|
|
9
8
|
* @returns The response body interpreted as JSON
|
|
10
9
|
*/
|
|
11
10
|
export async function requestAPI(endPoint = '', init = {}) {
|
|
12
11
|
// Make request to Jupyter API
|
|
13
12
|
const settings = ServerConnection.makeSettings();
|
|
14
|
-
const requestUrl = URLExt.join(settings.baseUrl,
|
|
13
|
+
const requestUrl = URLExt.join(settings.baseUrl, endPoint);
|
|
15
14
|
let response;
|
|
16
15
|
try {
|
|
17
16
|
response = await ServerConnection.makeRequest(requestUrl, init, settings);
|
|
@@ -36,32 +35,32 @@ export async function requestAPI(endPoint = '', init = {}) {
|
|
|
36
35
|
export var AiService;
|
|
37
36
|
(function (AiService) {
|
|
38
37
|
async function getConfig() {
|
|
39
|
-
return requestAPI('config');
|
|
38
|
+
return requestAPI('api/jupyternaut/config');
|
|
40
39
|
}
|
|
41
40
|
AiService.getConfig = getConfig;
|
|
42
41
|
async function listLmProviders() {
|
|
43
|
-
return requestAPI('providers');
|
|
42
|
+
return requestAPI('api/jupyternaut/providers');
|
|
44
43
|
}
|
|
45
44
|
AiService.listLmProviders = listLmProviders;
|
|
46
45
|
async function listEmProviders() {
|
|
47
|
-
return requestAPI('providers/embeddings');
|
|
46
|
+
return requestAPI('api/jupyternaut/providers/embeddings');
|
|
48
47
|
}
|
|
49
48
|
AiService.listEmProviders = listEmProviders;
|
|
50
49
|
async function updateConfig(config) {
|
|
51
|
-
return requestAPI('config', {
|
|
50
|
+
return requestAPI('api/jupyternaut/config', {
|
|
52
51
|
method: 'POST',
|
|
53
52
|
body: JSON.stringify(config)
|
|
54
53
|
});
|
|
55
54
|
}
|
|
56
55
|
AiService.updateConfig = updateConfig;
|
|
57
56
|
async function listSecrets() {
|
|
58
|
-
return requestAPI('secrets/', {
|
|
57
|
+
return requestAPI('api/jupyternaut/secrets/', {
|
|
59
58
|
method: 'GET'
|
|
60
59
|
});
|
|
61
60
|
}
|
|
62
61
|
AiService.listSecrets = listSecrets;
|
|
63
62
|
async function updateSecrets(updatedSecrets) {
|
|
64
|
-
return requestAPI('secrets/', {
|
|
63
|
+
return requestAPI('api/jupyternaut/secrets/', {
|
|
65
64
|
method: 'PUT',
|
|
66
65
|
body: JSON.stringify({
|
|
67
66
|
updated_secrets: updatedSecrets
|
|
@@ -74,14 +73,14 @@ export var AiService;
|
|
|
74
73
|
}
|
|
75
74
|
AiService.deleteSecret = deleteSecret;
|
|
76
75
|
async function listChatModels() {
|
|
77
|
-
const response = await requestAPI('models/chat/', {
|
|
76
|
+
const response = await requestAPI('api/ai/models/chat/', {
|
|
78
77
|
method: 'GET'
|
|
79
78
|
});
|
|
80
79
|
return response.chat_models;
|
|
81
80
|
}
|
|
82
81
|
AiService.listChatModels = listChatModels;
|
|
83
82
|
async function getChatModel() {
|
|
84
|
-
const response = await requestAPI('config/');
|
|
83
|
+
const response = await requestAPI('api/jupyternaut/config/');
|
|
85
84
|
return response.model_provider_id;
|
|
86
85
|
}
|
|
87
86
|
AiService.getChatModel = getChatModel;
|
|
@@ -92,7 +91,7 @@ export var AiService;
|
|
|
92
91
|
}
|
|
93
92
|
AiService.updateChatModel = updateChatModel;
|
|
94
93
|
async function getCompletionModel() {
|
|
95
|
-
const response = await requestAPI('config/');
|
|
94
|
+
const response = await requestAPI('api/jupyternaut/config/');
|
|
96
95
|
return response.completions_model_provider_id;
|
|
97
96
|
}
|
|
98
97
|
AiService.getCompletionModel = getCompletionModel;
|
|
@@ -111,11 +110,11 @@ export var AiService;
|
|
|
111
110
|
params.append('provider', provider);
|
|
112
111
|
}
|
|
113
112
|
const endpoint = `model-parameters${params.toString() ? `?${params.toString()}` : ''}`;
|
|
114
|
-
return await requestAPI(endpoint);
|
|
113
|
+
return await requestAPI(`api/jupyternaut/${endpoint}`);
|
|
115
114
|
}
|
|
116
115
|
AiService.getModelParameters = getModelParameters;
|
|
117
116
|
async function saveModelParameters(modelId, parameters) {
|
|
118
|
-
return await requestAPI('model-parameters', {
|
|
117
|
+
return await requestAPI('api/jupyternaut/model-parameters', {
|
|
119
118
|
method: 'PUT',
|
|
120
119
|
headers: {
|
|
121
120
|
'Content-Type': 'application/json'
|
package/lib/index.js
CHANGED