Skip to content

Commit 0b67f8f

Browse files
authored
Merge pull request #313 from iceljc/features/refine-chat-window
Features/refine chat window
2 parents 9b41497 + 3751aa6 commit 0b67f8f

File tree

15 files changed

+752
-11
lines changed

15 files changed

+752
-11
lines changed

src/lib/helpers/enums.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,13 @@ const globalEvent = {
164164
Search: "search",
165165
Chat: "chat"
166166
};
167-
export const GlobalEvent = Object.freeze(globalEvent);
167+
export const GlobalEvent = Object.freeze(globalEvent);
168+
169+
const llmModelType = {
170+
Text: 1,
171+
Chat: 2,
172+
Image: 3,
173+
Embedding: 4,
174+
Audio: 5
175+
};
176+
export const LlmModelType = Object.freeze(llmModelType);

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/commonTypes.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@
2424
* @property {T[]} items - Items.
2525
*/
2626

27+
/**
28+
* @typedef {Object} LlmConfigOption
29+
* @property {number?} [type]
30+
* @property {boolean?} [multiModal]
31+
* @property {boolean?} [imageGeneration]
32+
*/
33+
34+
/**
35+
* @typedef {Object} LlmConfig
36+
* @property {string} provider
37+
* @property {LlmModelSetting[]} models
38+
*/
39+
2740
/**
2841
* @typedef {Object} LlmModelSetting
2942
* @property {string} name

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: 2 additions & 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`,
@@ -73,6 +74,7 @@ export const endpoints = {
7374
// LLM provider
7475
llmProvidersUrl: `${host}/llm-providers`,
7576
llmProviderModelsUrl: `${host}/llm-provider/{provider}/models`,
77+
llmConfigsUrl: `${host}/llm-configs`,
7678

7779
// logging
7880
loggingFullLogUrl: `${host}/logger/full-log`,

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/lib/services/llm-provider-service.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,24 @@ export async function getLlmProviderModels(provider) {
2121
let url = replaceUrl(endpoints.llmProviderModelsUrl, {provider: provider});
2222
const response = await axios.get(url);
2323
return response.data;
24+
}
25+
26+
27+
/**
28+
* Get llm configs
29+
* @param {import('$commonTypes').LlmConfigOption?} [options]
30+
* @returns {Promise<import('$commonTypes').LlmConfig[]>}
31+
*/
32+
export async function getLlmConfigs(options = null) {
33+
const url = endpoints.llmConfigsUrl;
34+
const response = await axios.get(url, {
35+
params: {
36+
options: options
37+
},
38+
paramsSerializer: {
39+
dots: true,
40+
indexes: null,
41+
}
42+
});
43+
return response.data;
2444
}

0 commit comments

Comments
 (0)