diff --git a/src/lib/helpers/constants.js b/src/lib/helpers/constants.js index 5ddcf6ac..1b21bac0 100644 --- a/src/lib/helpers/constants.js +++ b/src/lib/helpers/constants.js @@ -1,4 +1,4 @@ -import { EditorType, UserRole } from "./enums"; +import { EditorType, TimeRange, UserRole } from "./enums"; export const CHAT_FRAME_ID = "chatbox-frame"; @@ -45,4 +45,20 @@ export const DEFAULT_KNOWLEDGE_COLLECTION = "BotSharp"; export const IMAGE_DATA_PREFIX = 'data:image'; export const INTEGER_REGEX = "[0-9]+"; -export const DECIMAL_REGEX = "[0-9.]+"; \ No newline at end of file +export const DECIMAL_REGEX = "[0-9.]+"; + +export const TIME_RANGE_OPTIONS = [ + { label: TimeRange.Last15Minutes, value: TimeRange.Last15Minutes, qty: 15, unit: 'minutes' }, + { label: TimeRange.Last30Minutes, value: TimeRange.Last30Minutes, qty: 30, unit: 'minutes' }, + { label: TimeRange.Last1Hour, value: TimeRange.Last1Hour, qty: 1, unit: 'hours' }, + { label: TimeRange.Last3Hours, value: TimeRange.Last3Hours, qty: 3, unit: 'hours' }, + { label: TimeRange.Last12Hours, value: TimeRange.Last12Hours, qty: 12, unit: 'hours' }, + { label: TimeRange.Today, value: TimeRange.Today, qty: 1, unit: 'days' }, + { label: TimeRange.Yesterday, value: TimeRange.Yesterday, qty: 1, unit: 'days' }, + { label: TimeRange.Last3Days, value: TimeRange.Last3Days, qty: 3, unit: 'days' }, + { label: TimeRange.Last7Days, value: TimeRange.Last7Days, qty: 7, unit: 'days' }, + { label: TimeRange.Last30Days, value: TimeRange.Last30Days, qty: 30, unit: 'days' }, + { label: TimeRange.Last90Days, value: TimeRange.Last90Days, qty: 90, unit: 'days' }, + { label: TimeRange.Last180Days, value: TimeRange.Last180Days, qty: 180, unit: 'days' }, + { label: TimeRange.LastYear, value: TimeRange.LastYear, qty: 365, unit: 'days' } +]; \ No newline at end of file diff --git a/src/lib/helpers/enums.js b/src/lib/helpers/enums.js index 87011624..76087c4f 100644 --- a/src/lib/helpers/enums.js +++ b/src/lib/helpers/enums.js @@ -188,8 +188,26 @@ const llmModelType = { export const LlmModelType = Object.freeze(llmModelType); const reasoningEffortLevel = { + Minimal: "minimal", Low: "low", Medium: "medium", High: "high" }; -export const ReasoningEffortLevel = Object.freeze(reasoningEffortLevel); \ No newline at end of file +export const ReasoningEffortLevel = Object.freeze(reasoningEffortLevel); + +const timeRange = { + Last15Minutes: "Last 15 minutes", + Last30Minutes: "Last 30 minutes", + Last1Hour: "Last 1 hour", + Last3Hours: "Last 3 hours", + Last12Hours: "Last 12 hours", + Today: "Today", + Yesterday: "Yesterday", + Last3Days: "Last 3 days", + Last7Days: "Last 7 days", + Last30Days: "Last 30 days", + Last90Days: "Last 90 days", + Last180Days: "Last 180 days", + LastYear: "Last year" +}; +export const TimeRange = Object.freeze(timeRange); \ No newline at end of file diff --git a/src/lib/helpers/types/agentTypes.js b/src/lib/helpers/types/agentTypes.js index 5cf7c6b6..846bf31c 100644 --- a/src/lib/helpers/types/agentTypes.js +++ b/src/lib/helpers/types/agentTypes.js @@ -17,6 +17,7 @@ * @property {string?} model * @property {number} max_recursion_depth * @property {number?} [max_output_tokens] + * @property {string?} [reasoning_effort_level] */ diff --git a/src/lib/helpers/types/conversationTypes.js b/src/lib/helpers/types/conversationTypes.js index 23862c00..cceb1505 100644 --- a/src/lib/helpers/types/conversationTypes.js +++ b/src/lib/helpers/types/conversationTypes.js @@ -14,6 +14,8 @@ * @property {boolean?} [isLoadLatestStates] * @property {import('$commonTypes').KeyValuePair[]} [states] - The conversation status. * @property {string[]} [tags] - The tags. + * @property {string?} [startTime] + * @property {string?} [endTime] */ /** @@ -41,6 +43,8 @@ * @property {number?} [convLimit] - The conversation limit. * @property {boolean?} [preload] - Whether it is preloading or not. * @property {string[]?} [agentIds] + * @property {string?} [startTime] + * @property {string?} [endTime] */ @@ -307,6 +311,7 @@ IRichContent.prototype.language; * @property {string?} [status] * @property {UserStateDetailModel[]} states * @property {string[]} tags + * @property {string?} [timeRange] */ /** diff --git a/src/lib/helpers/types/instructTypes.js b/src/lib/helpers/types/instructTypes.js index 9538dec6..102936a7 100644 --- a/src/lib/helpers/types/instructTypes.js +++ b/src/lib/helpers/types/instructTypes.js @@ -23,6 +23,8 @@ * @property {string[]?} [providers] * @property {string[]?} [models] * @property {string[]?} [templateNames] + * @property {string?} [startTime] + * @property {string?} [endTime] * @property {{key: string, value: string}[]?} [states] */ @@ -49,6 +51,8 @@ * @property {number?} [logLimit] - The log limit. * @property {boolean?} [preload] - Whether it is preloading or not. * @property {string[]?} [agentIds] + * @property {string?} [startTime] + * @property {string?} [endTime] */ export default {}; \ No newline at end of file diff --git a/src/lib/helpers/utils/common.js b/src/lib/helpers/utils/common.js index cf22a03b..5b263aa7 100644 --- a/src/lib/helpers/utils/common.js +++ b/src/lib/helpers/utils/common.js @@ -1,4 +1,7 @@ import { goto } from '$app/navigation'; +import moment from 'moment'; +import { TIME_RANGE_OPTIONS } from '../constants'; +import { TimeRange } from '../enums'; export function range(size = 3, startAt = 0) { return [...Array(size).keys()].map((i) => i + startAt); @@ -155,4 +158,61 @@ export function splitTextByCase(str) { let text = words.map(word => word.toLowerCase()).join(' '); text = text.charAt(0).toUpperCase() + text.slice(1); return text; +} + +/** + * @param {string} timeRange + * @returns {{ startTime: string | null, endTime: string | null }} + */ +export function convertTimeRange(timeRange) { + let ret = { startTime: null, endTime: null }; + + if (!timeRange) { + return ret; + } + + const found = TIME_RANGE_OPTIONS.find(x => x.value === timeRange); + if (!found) { + return ret; + } + + switch (found.value) { + case TimeRange.Last15Minutes: + case TimeRange.Last30Minutes: + case TimeRange.Last1Hour: + case TimeRange.Last3Hours: + case TimeRange.Last12Hours: + case TimeRange.Last3Days: + case TimeRange.Last7Days: + case TimeRange.Last30Days: + case TimeRange.Last90Days: + case TimeRange.Last180Days: + case TimeRange.LastYear: + ret = { + ...ret, + // @ts-ignore + startTime: moment().subtract(found.qty, found.unit).utc().format() + }; + break; + case TimeRange.Today: + ret = { + ...ret, + // @ts-ignore + startTime: moment().startOf('day').utc().format() + }; + break; + case TimeRange.Yesterday: + ret = { + ...ret, + // @ts-ignore + startTime: moment().subtract(1, 'days').startOf('day').utc().format(), + // @ts-ignore + endTime: moment().subtract(1, 'days').endOf('day').utc().format() + }; + break; + default: + break; + } + + return ret; } \ No newline at end of file diff --git a/src/routes/page/agent/[agentId]/agent-components/agent-knowledge-base.svelte b/src/routes/page/agent/[agentId]/agent-components/agent-knowledge-base.svelte index 5bab8f82..ec1414e6 100644 --- a/src/routes/page/agent/[agentId]/agent-components/agent-knowledge-base.svelte +++ b/src/routes/page/agent/[agentId]/agent-components/agent-knowledge-base.svelte @@ -87,9 +87,9 @@ const found = innerKnowledgeBases.find((_, index) => index === idx); if (!found) return; - const vals = e.target.value.split("#"); - found.name = vals[0]; - found.type = vals[1]; + const val = JSON.parse(e.target.value); + found.name = val?.name; + found.type = val?.type; innerRefresh(innerKnowledgeBases); handleAgentChange(); } @@ -219,7 +219,7 @@ on:change={e => changeKnowledgeBase(e, uid)} > {#each [...knowledgeBaseOptions] as option} - {/each} diff --git a/src/routes/page/agent/[agentId]/agent-components/agent-llm-config.svelte b/src/routes/page/agent/[agentId]/agent-components/agent-llm-config.svelte index 2ee52f2a..97393972 100644 --- a/src/routes/page/agent/[agentId]/agent-components/agent-llm-config.svelte +++ b/src/routes/page/agent/[agentId]/agent-components/agent-llm-config.svelte @@ -99,6 +99,12 @@ handleAgentChange(); } + /** @param {any} e */ + function changeReasoningEffortLevel(e) { + config.reasoning_effort_level = e.target.value || null; + handleAgentChange(); + } + /** @param {any} e */ function validateIntegerInput(e) { const reg = new RegExp(INTEGER_REGEX, 'g'); @@ -174,5 +180,20 @@ /> + +