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
20 changes: 18 additions & 2 deletions src/lib/helpers/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EditorType, UserRole } from "./enums";
import { EditorType, TimeRange, UserRole } from "./enums";

export const CHAT_FRAME_ID = "chatbox-frame";

Expand Down Expand Up @@ -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.]+";
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' }
];
20 changes: 19 additions & 1 deletion src/lib/helpers/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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);
1 change: 1 addition & 0 deletions src/lib/helpers/types/agentTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* @property {string?} model
* @property {number} max_recursion_depth
* @property {number?} [max_output_tokens]
* @property {string?} [reasoning_effort_level]
*/


Expand Down
5 changes: 5 additions & 0 deletions src/lib/helpers/types/conversationTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
*/

/**
Expand Down Expand Up @@ -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]
*/


Expand Down Expand Up @@ -307,6 +311,7 @@ IRichContent.prototype.language;
* @property {string?} [status]
* @property {UserStateDetailModel[]} states
* @property {string[]} tags
* @property {string?} [timeRange]
*/

/**
Expand Down
4 changes: 4 additions & 0 deletions src/lib/helpers/types/instructTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
*/

Expand All @@ -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 {};
60 changes: 60 additions & 0 deletions src/lib/helpers/utils/common.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -219,7 +219,7 @@
on:change={e => changeKnowledgeBase(e, uid)}
>
{#each [...knowledgeBaseOptions] as option}
<option value={`${option.name}#${option.type}`} selected={option.name == knowledge.name}>
<option value={`${JSON.stringify(option)}`} selected={option.name == knowledge.name}>
{option.displayName || option.name}
</option>
{/each}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -174,5 +180,20 @@
/>
</div>
</div>

<div class="mb-3 row">
<label for="example-text-input" class="col-md-3 col-form-label">
Reasoning effort
</label>
<div class="col-md-9">
<Input type="select" value={config.reasoning_effort_level} on:change={e => changeReasoningEffortLevel(e)}>
{#each reasonLevelOptions as option}
<option value={option.value} selected={option.value == config.reasoning_effort_level}>
{option.label}
</option>
{/each}
</Input>
</div>
</div>
</CardBody>
</Card>
Loading