Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/lib/helpers/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,13 @@ const globalEvent = {
Search: "search",
Chat: "chat"
};
export const GlobalEvent = Object.freeze(globalEvent);
export const GlobalEvent = Object.freeze(globalEvent);

const llmModelType = {
Text: 1,
Chat: 2,
Image: 3,
Embedding: 4,
Audio: 5
};
export const LlmModelType = Object.freeze(llmModelType);
3 changes: 2 additions & 1 deletion src/lib/helpers/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ function skipLoader(config) {
new RegExp('http(s*)://(.*?)/knowledge/(.*?)/search', 'g'),
new RegExp('http(s*)://(.*?)/knowledge/vector/(.*?)/create', 'g'),
new RegExp('http(s*)://(.*?)/knowledge/document/(.*?)/page', 'g'),
new RegExp('http(s*)://(.*?)/users', 'g')
new RegExp('http(s*)://(.*?)/users', 'g'),
new RegExp('http(s*)://(.*?)/instruct/chat-completion', 'g')
];

/** @type {RegExp[]} */
Expand Down
13 changes: 13 additions & 0 deletions src/lib/helpers/types/commonTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@
* @property {T[]} items - Items.
*/

/**
* @typedef {Object} LlmConfigOption
* @property {number?} [type]
* @property {boolean?} [multiModal]
* @property {boolean?} [imageGeneration]
*/

/**
* @typedef {Object} LlmConfig
* @property {string} provider
* @property {LlmModelSetting[]} models
*/

/**
* @typedef {Object} LlmModelSetting
* @property {string} name
Expand Down
6 changes: 0 additions & 6 deletions src/lib/helpers/types/conversationTypes.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/**
* @typedef {Object} InstructMessageModel
* @property {string} [instruction] - User provided prompt instead of predefined template.
* @property {string} [template] - The template name.
*/

/**
* @typedef {Object} MessageConfig
* @property {string} [taskId] - Optional task id.
Expand Down
17 changes: 17 additions & 0 deletions src/lib/helpers/types/instructTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @typedef {Object} InstructMessageModel
* @property {string} [instruction] - User provided prompt instead of predefined template.
* @property {string} [template] - The template name.
*/

/**
* @typedef {Object} IncomingInstructRequest
* @property {string} text
* @property {string} [agentId]
* @property {string} [instruction]
* @property {string} [provider]
* @property {string} [model]
* @property {import('$conversationTypes').ConversationStateModel[]} [states]
*/

export default {};
1 change: 1 addition & 0 deletions src/lib/scss/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ File: Main Css File
@import "custom/pages/knowledgebase";
@import "custom/pages/users";
@import "custom/pages/roles";
@import "custom/pages/instruction";

// Common
@import "custom/common/animation";
Expand Down
85 changes: 85 additions & 0 deletions src/lib/scss/custom/pages/_instruction.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
.instruction-container {
.text-count {
margin-top: 2px;
font-size: 10px;
}

.instruction-result-container {
.instruction-result-body {
font-size: 15px;
padding: 5px 10px;
overflow-y: auto;
max-height: 500px;
scrollbar-width: thin;
}
}
}

.instruction-border {
border: 1px dashed var(--bs-primary);
border-radius: 5px;
}

.instruct-header {
font-size: 17px;
display: flex;
justify-content: space-between;
}

.instruct-text-header {
font-size: 17px;
display: flex;
gap: 5px;
}

.instruct-setting-container {
display: flex;
flex-wrap: wrap;

.instruct-setting-section {
display: flex;
flex-direction: column;
gap: 20px;
}

@media (max-width: 992px) {
.instruct-setting-section {
margin-top: 10px;
}

.instruction-gap {
margin-top: 10px;
}
}

.instruct-setting-item {
display: flex;
justify-content: center;

.instruct-setting-dropdown {
width: 60%;
}

@media (max-width: 992px) {
.instruct-setting-dropdown {
width: 100%;
}
}
}
}

.instruct-setting-padding {
padding: 20px 10px;
}

.instruct-state-container {
display: flex;
flex-direction: column;
gap: 10px;

.instruct-state-item {
display: flex;
gap: 10px;
justify-content: center;
}
}
2 changes: 2 additions & 0 deletions src/lib/services/api-endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const endpoints = {

// agent instruct
instructCompletionUrl: `${host}/instruct/{agentId}`,
chatCompletionUrl: `${host}/instruct/chat-completion`,

// agent realtime interaction
agentInitRealtimeSessionUrl: `${host}/agent/{agentId}/realtime/session`,
Expand Down Expand Up @@ -73,6 +74,7 @@ export const endpoints = {
// LLM provider
llmProvidersUrl: `${host}/llm-providers`,
llmProviderModelsUrl: `${host}/llm-provider/{provider}/models`,
llmConfigsUrl: `${host}/llm-configs`,

// logging
loggingFullLogUrl: `${host}/logger/full-log`,
Expand Down
15 changes: 13 additions & 2 deletions src/lib/services/instruct-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@ import axios from 'axios';
/**
* Execute agent instruction by template or user provided prompt.
* @param {string} agentId
* @param {import('$conversationTypes').InstructMessageModel} instruction
* @param {import('$instructTypes').InstructMessageModel} instruction
*/
export async function executeAgentInstruction(agentId, instruction) {
let url = replaceUrl(endpoints.instructCompletionUrl, {agentId: agentId});
await axios.post(url, instruction);
}
}


/**
* Execute chat completion.
* @param {import('$instructTypes').IncomingInstructRequest} request
*/
export async function sendChatCompletion(request) {
const url = endpoints.chatCompletionUrl;
const response = await axios.post(url, request);
return response.data;
}
20 changes: 20 additions & 0 deletions src/lib/services/llm-provider-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,24 @@ export async function getLlmProviderModels(provider) {
let url = replaceUrl(endpoints.llmProviderModelsUrl, {provider: provider});
const response = await axios.get(url);
return response.data;
}


/**
* Get llm configs
* @param {import('$commonTypes').LlmConfigOption?} [options]
* @returns {Promise<import('$commonTypes').LlmConfig[]>}
*/
export async function getLlmConfigs(options = null) {
const url = endpoints.llmConfigsUrl;
const response = await axios.get(url, {
params: {
options: options
},
paramsSerializer: {
dots: true,
indexes: null,
}
});
return response.data;
}
2 changes: 1 addition & 1 deletion src/routes/page/conversation/state-search.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
placeholder="Enter a value"
/>
</div>
<div class="state-delete line-align-center" style="flex: 0 0 13px;">
<div class="line-align-center" style="flex: 0 0 13px;">
<div>
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
Expand Down
Loading