Skip to content

Commit a851aef

Browse files
author
Jicheng Lu
committed
integrate chat completion endpoint
1 parent cfaa874 commit a851aef

File tree

12 files changed

+640
-10
lines changed

12 files changed

+640
-10
lines changed

src/lib/helpers/http.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ function skipLoader(config) {
7474
new RegExp('http(s*)://(.*?)/knowledge/(.*?)/search', 'g'),
7575
new RegExp('http(s*)://(.*?)/knowledge/vector/(.*?)/create', 'g'),
7676
new RegExp('http(s*)://(.*?)/knowledge/document/(.*?)/page', 'g'),
77-
new RegExp('http(s*)://(.*?)/users', 'g')
77+
new RegExp('http(s*)://(.*?)/users', 'g'),
78+
new RegExp('http(s*)://(.*?)/instruct/chat-completion', 'g')
7879
];
7980

8081
/** @type {RegExp[]} */

src/lib/helpers/types/conversationTypes.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
/**
2-
* @typedef {Object} InstructMessageModel
3-
* @property {string} [instruction] - User provided prompt instead of predefined template.
4-
* @property {string} [template] - The template name.
5-
*/
6-
71
/**
82
* @typedef {Object} MessageConfig
93
* @property {string} [taskId] - Optional task id.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @typedef {Object} InstructMessageModel
3+
* @property {string} [instruction] - User provided prompt instead of predefined template.
4+
* @property {string} [template] - The template name.
5+
*/
6+
7+
/**
8+
* @typedef {Object} IncomingInstructRequest
9+
* @property {string} text
10+
* @property {string} [agentId]
11+
* @property {string} [instruction]
12+
* @property {string} [provider]
13+
* @property {string} [model]
14+
* @property {import('$conversationTypes').ConversationStateModel[]} [states]
15+
*/
16+
17+
export default {};

src/lib/scss/app.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ File: Main Css File
9595
@import "custom/pages/knowledgebase";
9696
@import "custom/pages/users";
9797
@import "custom/pages/roles";
98+
@import "custom/pages/instruction";
9899

99100
// Common
100101
@import "custom/common/animation";
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
.instruction-container {
2+
.text-count {
3+
margin-top: 2px;
4+
font-size: 10px;
5+
}
6+
7+
.instruction-result-container {
8+
.instruction-result-body {
9+
font-size: 15px;
10+
padding: 5px 10px;
11+
overflow-y: auto;
12+
max-height: 500px;
13+
scrollbar-width: thin;
14+
}
15+
}
16+
}
17+
18+
.instruction-border {
19+
border: 1px dashed var(--bs-primary);
20+
border-radius: 5px;
21+
}
22+
23+
.instruct-header {
24+
font-size: 17px;
25+
display: flex;
26+
justify-content: space-between;
27+
}
28+
29+
.instruct-text-header {
30+
font-size: 17px;
31+
display: flex;
32+
gap: 5px;
33+
}
34+
35+
.instruct-setting-container {
36+
display: flex;
37+
flex-wrap: wrap;
38+
39+
.instruct-setting-section {
40+
display: flex;
41+
flex-direction: column;
42+
gap: 20px;
43+
}
44+
45+
@media (max-width: 992px) {
46+
.instruct-setting-section {
47+
margin-top: 10px;
48+
}
49+
50+
.instruction-gap {
51+
margin-top: 10px;
52+
}
53+
}
54+
55+
.instruct-setting-item {
56+
display: flex;
57+
justify-content: center;
58+
59+
.instruct-setting-dropdown {
60+
width: 60%;
61+
}
62+
63+
@media (max-width: 992px) {
64+
.instruct-setting-dropdown {
65+
width: 100%;
66+
}
67+
}
68+
}
69+
}
70+
71+
.instruct-setting-padding {
72+
padding: 20px 10px;
73+
}
74+
75+
.instruct-state-container {
76+
display: flex;
77+
flex-direction: column;
78+
gap: 10px;
79+
80+
.instruct-state-item {
81+
display: flex;
82+
gap: 10px;
83+
justify-content: center;
84+
}
85+
}

src/lib/services/api-endpoints.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export const endpoints = {
4444

4545
// agent instruct
4646
instructCompletionUrl: `${host}/instruct/{agentId}`,
47+
chatCompletionUrl: `${host}/instruct/chat-completion`,
4748

4849
// agent realtime interaction
4950
agentInitRealtimeSessionUrl: `${host}/agent/{agentId}/realtime/session`,

src/lib/services/instruct-service.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,20 @@ import axios from 'axios';
55
/**
66
* Execute agent instruction by template or user provided prompt.
77
* @param {string} agentId
8-
* @param {import('$conversationTypes').InstructMessageModel} instruction
8+
* @param {import('$instructTypes').InstructMessageModel} instruction
99
*/
1010
export async function executeAgentInstruction(agentId, instruction) {
1111
let url = replaceUrl(endpoints.instructCompletionUrl, {agentId: agentId});
1212
await axios.post(url, instruction);
13-
}
13+
}
14+
15+
16+
/**
17+
* Execute chat completion.
18+
* @param {import('$instructTypes').IncomingInstructRequest} request
19+
*/
20+
export async function sendChatCompletion(request) {
21+
const url = endpoints.chatCompletionUrl;
22+
const response = await axios.post(url, request);
23+
return response.data;
24+
}

src/routes/page/conversation/state-search.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
placeholder="Enter a value"
5454
/>
5555
</div>
56-
<div class="state-delete line-align-center" style="flex: 0 0 13px;">
56+
<div class="line-align-center" style="flex: 0 0 13px;">
5757
<div>
5858
<!-- svelte-ignore a11y-click-events-have-key-events -->
5959
<!-- svelte-ignore a11y-no-static-element-interactions -->

0 commit comments

Comments
 (0)