@kapeta/local-cluster-service 0.64.3 → 0.65.0
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/CHANGELOG.md +7 -0
- package/dist/cjs/src/storm/routes.js +12 -0
- package/dist/cjs/src/storm/stormClient.d.ts +14 -0
- package/dist/cjs/src/storm/stormClient.js +21 -0
- package/dist/esm/src/storm/routes.js +12 -0
- package/dist/esm/src/storm/stormClient.d.ts +14 -0
- package/dist/esm/src/storm/stormClient.js +21 -0
- package/package.json +1 -1
- package/src/storm/routes.ts +16 -0
- package/src/storm/stormClient.ts +37 -0
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# [0.65.0](https://github.com/kapetacom/local-cluster-service/compare/v0.64.3...v0.65.0) (2024-08-26)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* Add votes endpoints ([82c1ee7](https://github.com/kapetacom/local-cluster-service/commit/82c1ee7a959f61475a7403845f8037b11fdd5084))
|
7
|
+
|
1
8
|
## [0.64.3](https://github.com/kapetacom/local-cluster-service/compare/v0.64.2...v0.64.3) (2024-08-23)
|
2
9
|
|
3
10
|
|
@@ -360,6 +360,18 @@ router.post('/ui/edit', async (req, res) => {
|
|
360
360
|
}
|
361
361
|
}
|
362
362
|
});
|
363
|
+
router.post('/ui/vote', async (req, res) => {
|
364
|
+
const conversationId = req.headers[stormClient_1.ConversationIdHeader.toLowerCase()] || '';
|
365
|
+
const aiRequest = JSON.parse(req.stringBody ?? '{}');
|
366
|
+
const { topic, vote, mainConversationId } = aiRequest;
|
367
|
+
return stormClient_1.stormClient.voteUIPage(topic, conversationId, vote, mainConversationId);
|
368
|
+
});
|
369
|
+
router.post('/ui/get-vote', async (req, res) => {
|
370
|
+
const conversationId = req.headers[stormClient_1.ConversationIdHeader.toLowerCase()] || '';
|
371
|
+
const aiRequest = JSON.parse(req.stringBody ?? '{}');
|
372
|
+
const { topic, mainConversationId } = aiRequest;
|
373
|
+
return stormClient_1.stormClient.getVoteUIPage(topic, conversationId, mainConversationId);
|
374
|
+
});
|
363
375
|
router.post('/:handle/all', async (req, res) => {
|
364
376
|
const handle = req.params.handle;
|
365
377
|
try {
|
@@ -1,3 +1,4 @@
|
|
1
|
+
/// <reference types="node" />
|
1
2
|
import { ConversationItem, StormFileImplementationPrompt, StormStream, StormUIImplementationPrompt, StormUIListPrompt } from './stream';
|
2
3
|
import { Page, StormEventPageUrl } from './events';
|
3
4
|
export declare const STORM_ID = "storm";
|
@@ -38,6 +39,15 @@ export interface UIPageEditRequest {
|
|
38
39
|
pages: StormEventPageUrl['payload'][];
|
39
40
|
prompt: BasePromptRequest;
|
40
41
|
}
|
42
|
+
export interface UIPageVoteRequest {
|
43
|
+
topic: string;
|
44
|
+
vote: -1 | 0 | 1;
|
45
|
+
mainConversationId: string;
|
46
|
+
}
|
47
|
+
export interface UIPageGetVoteRequest {
|
48
|
+
topic: string;
|
49
|
+
mainConversationId: string;
|
50
|
+
}
|
41
51
|
export interface BasePromptRequest {
|
42
52
|
prompt: string;
|
43
53
|
skipImprovement?: boolean;
|
@@ -53,6 +63,10 @@ declare class StormClient {
|
|
53
63
|
createUIShells(prompt: UIShellsPrompt, conversationId?: string): Promise<StormStream>;
|
54
64
|
createUILandingPages(prompt: BasePromptRequest, conversationId?: string): Promise<StormStream>;
|
55
65
|
createUIPage(prompt: UIPagePrompt, conversationId?: string, history?: ConversationItem[]): Promise<StormStream>;
|
66
|
+
voteUIPage(topic: string, conversationId: string, vote: -1 | 0 | 1, mainConversationId?: string): Promise<Response>;
|
67
|
+
getVoteUIPage(topic: string, conversationId: string, mainConversationId?: string): Promise<{
|
68
|
+
vote: -1 | 0 | 1;
|
69
|
+
}>;
|
56
70
|
classifyUIReferences(prompt: string, conversationId?: string): Promise<StormStream>;
|
57
71
|
editPages(prompt: UIPageEditPrompt, conversationId?: string): Promise<StormStream>;
|
58
72
|
listScreens(prompt: StormUIListPrompt, conversationId?: string): Promise<StormStream>;
|
@@ -110,6 +110,27 @@ class StormClient {
|
|
110
110
|
history,
|
111
111
|
});
|
112
112
|
}
|
113
|
+
async voteUIPage(topic, conversationId, vote, mainConversationId) {
|
114
|
+
const options = await this.createOptions('/v2/ui/vote', 'POST', {
|
115
|
+
prompt: JSON.stringify({ topic, vote, mainConversationId }),
|
116
|
+
conversationId,
|
117
|
+
});
|
118
|
+
return fetch(options.url, {
|
119
|
+
method: options.method,
|
120
|
+
headers: options.headers,
|
121
|
+
});
|
122
|
+
}
|
123
|
+
async getVoteUIPage(topic, conversationId, mainConversationId) {
|
124
|
+
const options = await this.createOptions('/v2/ui/get-vote', 'POST', {
|
125
|
+
prompt: JSON.stringify({ topic, mainConversationId }),
|
126
|
+
conversationId,
|
127
|
+
});
|
128
|
+
const response = await fetch(options.url, {
|
129
|
+
method: options.method,
|
130
|
+
headers: options.headers,
|
131
|
+
});
|
132
|
+
return response.json();
|
133
|
+
}
|
113
134
|
classifyUIReferences(prompt, conversationId) {
|
114
135
|
return this.send('/v2/ui/references', {
|
115
136
|
prompt: prompt,
|
@@ -360,6 +360,18 @@ router.post('/ui/edit', async (req, res) => {
|
|
360
360
|
}
|
361
361
|
}
|
362
362
|
});
|
363
|
+
router.post('/ui/vote', async (req, res) => {
|
364
|
+
const conversationId = req.headers[stormClient_1.ConversationIdHeader.toLowerCase()] || '';
|
365
|
+
const aiRequest = JSON.parse(req.stringBody ?? '{}');
|
366
|
+
const { topic, vote, mainConversationId } = aiRequest;
|
367
|
+
return stormClient_1.stormClient.voteUIPage(topic, conversationId, vote, mainConversationId);
|
368
|
+
});
|
369
|
+
router.post('/ui/get-vote', async (req, res) => {
|
370
|
+
const conversationId = req.headers[stormClient_1.ConversationIdHeader.toLowerCase()] || '';
|
371
|
+
const aiRequest = JSON.parse(req.stringBody ?? '{}');
|
372
|
+
const { topic, mainConversationId } = aiRequest;
|
373
|
+
return stormClient_1.stormClient.getVoteUIPage(topic, conversationId, mainConversationId);
|
374
|
+
});
|
363
375
|
router.post('/:handle/all', async (req, res) => {
|
364
376
|
const handle = req.params.handle;
|
365
377
|
try {
|
@@ -1,3 +1,4 @@
|
|
1
|
+
/// <reference types="node" />
|
1
2
|
import { ConversationItem, StormFileImplementationPrompt, StormStream, StormUIImplementationPrompt, StormUIListPrompt } from './stream';
|
2
3
|
import { Page, StormEventPageUrl } from './events';
|
3
4
|
export declare const STORM_ID = "storm";
|
@@ -38,6 +39,15 @@ export interface UIPageEditRequest {
|
|
38
39
|
pages: StormEventPageUrl['payload'][];
|
39
40
|
prompt: BasePromptRequest;
|
40
41
|
}
|
42
|
+
export interface UIPageVoteRequest {
|
43
|
+
topic: string;
|
44
|
+
vote: -1 | 0 | 1;
|
45
|
+
mainConversationId: string;
|
46
|
+
}
|
47
|
+
export interface UIPageGetVoteRequest {
|
48
|
+
topic: string;
|
49
|
+
mainConversationId: string;
|
50
|
+
}
|
41
51
|
export interface BasePromptRequest {
|
42
52
|
prompt: string;
|
43
53
|
skipImprovement?: boolean;
|
@@ -53,6 +63,10 @@ declare class StormClient {
|
|
53
63
|
createUIShells(prompt: UIShellsPrompt, conversationId?: string): Promise<StormStream>;
|
54
64
|
createUILandingPages(prompt: BasePromptRequest, conversationId?: string): Promise<StormStream>;
|
55
65
|
createUIPage(prompt: UIPagePrompt, conversationId?: string, history?: ConversationItem[]): Promise<StormStream>;
|
66
|
+
voteUIPage(topic: string, conversationId: string, vote: -1 | 0 | 1, mainConversationId?: string): Promise<Response>;
|
67
|
+
getVoteUIPage(topic: string, conversationId: string, mainConversationId?: string): Promise<{
|
68
|
+
vote: -1 | 0 | 1;
|
69
|
+
}>;
|
56
70
|
classifyUIReferences(prompt: string, conversationId?: string): Promise<StormStream>;
|
57
71
|
editPages(prompt: UIPageEditPrompt, conversationId?: string): Promise<StormStream>;
|
58
72
|
listScreens(prompt: StormUIListPrompt, conversationId?: string): Promise<StormStream>;
|
@@ -110,6 +110,27 @@ class StormClient {
|
|
110
110
|
history,
|
111
111
|
});
|
112
112
|
}
|
113
|
+
async voteUIPage(topic, conversationId, vote, mainConversationId) {
|
114
|
+
const options = await this.createOptions('/v2/ui/vote', 'POST', {
|
115
|
+
prompt: JSON.stringify({ topic, vote, mainConversationId }),
|
116
|
+
conversationId,
|
117
|
+
});
|
118
|
+
return fetch(options.url, {
|
119
|
+
method: options.method,
|
120
|
+
headers: options.headers,
|
121
|
+
});
|
122
|
+
}
|
123
|
+
async getVoteUIPage(topic, conversationId, mainConversationId) {
|
124
|
+
const options = await this.createOptions('/v2/ui/get-vote', 'POST', {
|
125
|
+
prompt: JSON.stringify({ topic, mainConversationId }),
|
126
|
+
conversationId,
|
127
|
+
});
|
128
|
+
const response = await fetch(options.url, {
|
129
|
+
method: options.method,
|
130
|
+
headers: options.headers,
|
131
|
+
});
|
132
|
+
return response.json();
|
133
|
+
}
|
113
134
|
classifyUIReferences(prompt, conversationId) {
|
114
135
|
return this.send('/v2/ui/references', {
|
115
136
|
prompt: prompt,
|
package/package.json
CHANGED
package/src/storm/routes.ts
CHANGED
@@ -20,6 +20,8 @@ import {
|
|
20
20
|
UIPageEditPrompt,
|
21
21
|
UIPageEditRequest,
|
22
22
|
BasePromptRequest,
|
23
|
+
UIPageVoteRequest,
|
24
|
+
UIPageGetVoteRequest,
|
23
25
|
} from './stormClient';
|
24
26
|
import { Page, StormEvent, StormEventPage, StormEventPhaseType, UserJourneyScreen } from './events';
|
25
27
|
|
@@ -449,6 +451,20 @@ router.post('/ui/edit', async (req: KapetaBodyRequest, res: Response) => {
|
|
449
451
|
}
|
450
452
|
});
|
451
453
|
|
454
|
+
router.post('/ui/vote', async (req: KapetaBodyRequest, res: Response) => {
|
455
|
+
const conversationId = (req.headers[ConversationIdHeader.toLowerCase()] as string | undefined) || '';
|
456
|
+
const aiRequest: UIPageVoteRequest = JSON.parse(req.stringBody ?? '{}');
|
457
|
+
const { topic, vote, mainConversationId } = aiRequest;
|
458
|
+
return stormClient.voteUIPage(topic, conversationId, vote, mainConversationId);
|
459
|
+
});
|
460
|
+
|
461
|
+
router.post('/ui/get-vote', async (req: KapetaBodyRequest, res: Response) => {
|
462
|
+
const conversationId = (req.headers[ConversationIdHeader.toLowerCase()] as string | undefined) || '';
|
463
|
+
const aiRequest: UIPageGetVoteRequest = JSON.parse(req.stringBody ?? '{}');
|
464
|
+
const { topic, mainConversationId } = aiRequest;
|
465
|
+
return stormClient.getVoteUIPage(topic, conversationId, mainConversationId);
|
466
|
+
});
|
467
|
+
|
452
468
|
router.post('/:handle/all', async (req: KapetaBodyRequest, res: Response) => {
|
453
469
|
const handle = req.params.handle as string;
|
454
470
|
|
package/src/storm/stormClient.ts
CHANGED
@@ -62,6 +62,17 @@ export interface UIPageEditRequest {
|
|
62
62
|
prompt: BasePromptRequest;
|
63
63
|
}
|
64
64
|
|
65
|
+
export interface UIPageVoteRequest {
|
66
|
+
topic: string;
|
67
|
+
vote: -1 | 0 | 1;
|
68
|
+
mainConversationId: string;
|
69
|
+
}
|
70
|
+
|
71
|
+
export interface UIPageGetVoteRequest {
|
72
|
+
topic: string;
|
73
|
+
mainConversationId: string;
|
74
|
+
}
|
75
|
+
|
65
76
|
export interface BasePromptRequest {
|
66
77
|
prompt: string;
|
67
78
|
skipImprovement?: boolean;
|
@@ -195,6 +206,32 @@ class StormClient {
|
|
195
206
|
});
|
196
207
|
}
|
197
208
|
|
209
|
+
public async voteUIPage(topic: string, conversationId: string, vote: -1 | 0 | 1, mainConversationId?: string) {
|
210
|
+
const options = await this.createOptions('/v2/ui/vote', 'POST', {
|
211
|
+
prompt: JSON.stringify({ topic, vote, mainConversationId }),
|
212
|
+
conversationId,
|
213
|
+
});
|
214
|
+
|
215
|
+
return fetch(options.url, {
|
216
|
+
method: options.method,
|
217
|
+
headers: options.headers,
|
218
|
+
});
|
219
|
+
}
|
220
|
+
|
221
|
+
public async getVoteUIPage(topic: string, conversationId: string, mainConversationId?: string) {
|
222
|
+
const options = await this.createOptions('/v2/ui/get-vote', 'POST', {
|
223
|
+
prompt: JSON.stringify({ topic, mainConversationId }),
|
224
|
+
conversationId,
|
225
|
+
});
|
226
|
+
|
227
|
+
const response = await fetch(options.url, {
|
228
|
+
method: options.method,
|
229
|
+
headers: options.headers,
|
230
|
+
});
|
231
|
+
|
232
|
+
return response.json() as Promise<{ vote: -1 | 0 | 1 }>;
|
233
|
+
}
|
234
|
+
|
198
235
|
public classifyUIReferences(prompt: string, conversationId?: string) {
|
199
236
|
return this.send('/v2/ui/references', {
|
200
237
|
prompt: prompt,
|