Skip to content

Commit 93624e5

Browse files
authored
Merge pull request #371 from iceljc/features/refine-chat-window
add time range
2 parents 8d3c4a7 + 0039bd0 commit 93624e5

File tree

11 files changed

+227
-35
lines changed

11 files changed

+227
-35
lines changed

src/lib/helpers/constants.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { EditorType, UserRole } from "./enums";
1+
import { EditorType, TimeRange, UserRole } from "./enums";
22

33
export const CHAT_FRAME_ID = "chatbox-frame";
44

@@ -45,4 +45,20 @@ export const DEFAULT_KNOWLEDGE_COLLECTION = "BotSharp";
4545
export const IMAGE_DATA_PREFIX = 'data:image';
4646

4747
export const INTEGER_REGEX = "[0-9]+";
48-
export const DECIMAL_REGEX = "[0-9.]+";
48+
export const DECIMAL_REGEX = "[0-9.]+";
49+
50+
export const TIME_RANGE_OPTIONS = [
51+
{ label: TimeRange.Last15Minutes, value: TimeRange.Last15Minutes, qty: 15, unit: 'minutes' },
52+
{ label: TimeRange.Last30Minutes, value: TimeRange.Last30Minutes, qty: 30, unit: 'minutes' },
53+
{ label: TimeRange.Last1Hour, value: TimeRange.Last1Hour, qty: 1, unit: 'hours' },
54+
{ label: TimeRange.Last3Hours, value: TimeRange.Last3Hours, qty: 3, unit: 'hours' },
55+
{ label: TimeRange.Last12Hours, value: TimeRange.Last12Hours, qty: 12, unit: 'hours' },
56+
{ label: TimeRange.Today, value: TimeRange.Today, qty: 1, unit: 'days' },
57+
{ label: TimeRange.Yesterday, value: TimeRange.Yesterday, qty: 1, unit: 'days' },
58+
{ label: TimeRange.Last3Days, value: TimeRange.Last3Days, qty: 3, unit: 'days' },
59+
{ label: TimeRange.Last7Days, value: TimeRange.Last7Days, qty: 7, unit: 'days' },
60+
{ label: TimeRange.Last30Days, value: TimeRange.Last30Days, qty: 30, unit: 'days' },
61+
{ label: TimeRange.Last90Days, value: TimeRange.Last90Days, qty: 90, unit: 'days' },
62+
{ label: TimeRange.Last180Days, value: TimeRange.Last180Days, qty: 180, unit: 'days' },
63+
{ label: TimeRange.LastYear, value: TimeRange.LastYear, qty: 365, unit: 'days' }
64+
];

src/lib/helpers/enums.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,26 @@ const llmModelType = {
188188
export const LlmModelType = Object.freeze(llmModelType);
189189

190190
const reasoningEffortLevel = {
191+
Minimal: "minimal",
191192
Low: "low",
192193
Medium: "medium",
193194
High: "high"
194195
};
195-
export const ReasoningEffortLevel = Object.freeze(reasoningEffortLevel);
196+
export const ReasoningEffortLevel = Object.freeze(reasoningEffortLevel);
197+
198+
const timeRange = {
199+
Last15Minutes: "Last 15 minutes",
200+
Last30Minutes: "Last 30 minutes",
201+
Last1Hour: "Last 1 hour",
202+
Last3Hours: "Last 3 hours",
203+
Last12Hours: "Last 12 hours",
204+
Today: "Today",
205+
Yesterday: "Yesterday",
206+
Last3Days: "Last 3 days",
207+
Last7Days: "Last 7 days",
208+
Last30Days: "Last 30 days",
209+
Last90Days: "Last 90 days",
210+
Last180Days: "Last 180 days",
211+
LastYear: "Last year"
212+
};
213+
export const TimeRange = Object.freeze(timeRange);

src/lib/helpers/types/agentTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* @property {string?} model
1818
* @property {number} max_recursion_depth
1919
* @property {number?} [max_output_tokens]
20+
* @property {string?} [reasoning_effort_level]
2021
*/
2122

2223

src/lib/helpers/types/conversationTypes.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* @property {boolean?} [isLoadLatestStates]
1515
* @property {import('$commonTypes').KeyValuePair[]} [states] - The conversation status.
1616
* @property {string[]} [tags] - The tags.
17+
* @property {string?} [startTime]
18+
* @property {string?} [endTime]
1719
*/
1820

1921
/**
@@ -41,6 +43,8 @@
4143
* @property {number?} [convLimit] - The conversation limit.
4244
* @property {boolean?} [preload] - Whether it is preloading or not.
4345
* @property {string[]?} [agentIds]
46+
* @property {string?} [startTime]
47+
* @property {string?} [endTime]
4448
*/
4549

4650

@@ -307,6 +311,7 @@ IRichContent.prototype.language;
307311
* @property {string?} [status]
308312
* @property {UserStateDetailModel[]} states
309313
* @property {string[]} tags
314+
* @property {string?} [timeRange]
310315
*/
311316

312317
/**

src/lib/helpers/types/instructTypes.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* @property {string[]?} [providers]
2424
* @property {string[]?} [models]
2525
* @property {string[]?} [templateNames]
26+
* @property {string?} [startTime]
27+
* @property {string?} [endTime]
2628
* @property {{key: string, value: string}[]?} [states]
2729
*/
2830

@@ -49,6 +51,8 @@
4951
* @property {number?} [logLimit] - The log limit.
5052
* @property {boolean?} [preload] - Whether it is preloading or not.
5153
* @property {string[]?} [agentIds]
54+
* @property {string?} [startTime]
55+
* @property {string?} [endTime]
5256
*/
5357

5458
export default {};

src/lib/helpers/utils/common.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { goto } from '$app/navigation';
2+
import moment from 'moment';
3+
import { TIME_RANGE_OPTIONS } from '../constants';
4+
import { TimeRange } from '../enums';
25

36
export function range(size = 3, startAt = 0) {
47
return [...Array(size).keys()].map((i) => i + startAt);
@@ -155,4 +158,61 @@ export function splitTextByCase(str) {
155158
let text = words.map(word => word.toLowerCase()).join(' ');
156159
text = text.charAt(0).toUpperCase() + text.slice(1);
157160
return text;
161+
}
162+
163+
/**
164+
* @param {string} timeRange
165+
* @returns {{ startTime: string | null, endTime: string | null }}
166+
*/
167+
export function convertTimeRange(timeRange) {
168+
let ret = { startTime: null, endTime: null };
169+
170+
if (!timeRange) {
171+
return ret;
172+
}
173+
174+
const found = TIME_RANGE_OPTIONS.find(x => x.value === timeRange);
175+
if (!found) {
176+
return ret;
177+
}
178+
179+
switch (found.value) {
180+
case TimeRange.Last15Minutes:
181+
case TimeRange.Last30Minutes:
182+
case TimeRange.Last1Hour:
183+
case TimeRange.Last3Hours:
184+
case TimeRange.Last12Hours:
185+
case TimeRange.Last3Days:
186+
case TimeRange.Last7Days:
187+
case TimeRange.Last30Days:
188+
case TimeRange.Last90Days:
189+
case TimeRange.Last180Days:
190+
case TimeRange.LastYear:
191+
ret = {
192+
...ret,
193+
// @ts-ignore
194+
startTime: moment().subtract(found.qty, found.unit).utc().format()
195+
};
196+
break;
197+
case TimeRange.Today:
198+
ret = {
199+
...ret,
200+
// @ts-ignore
201+
startTime: moment().startOf('day').utc().format()
202+
};
203+
break;
204+
case TimeRange.Yesterday:
205+
ret = {
206+
...ret,
207+
// @ts-ignore
208+
startTime: moment().subtract(1, 'days').startOf('day').utc().format(),
209+
// @ts-ignore
210+
endTime: moment().subtract(1, 'days').endOf('day').utc().format()
211+
};
212+
break;
213+
default:
214+
break;
215+
}
216+
217+
return ret;
158218
}

src/routes/page/agent/[agentId]/agent-components/agent-knowledge-base.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@
8787
const found = innerKnowledgeBases.find((_, index) => index === idx);
8888
if (!found) return;
8989
90-
const vals = e.target.value.split("#");
91-
found.name = vals[0];
92-
found.type = vals[1];
90+
const val = JSON.parse(e.target.value);
91+
found.name = val?.name;
92+
found.type = val?.type;
9393
innerRefresh(innerKnowledgeBases);
9494
handleAgentChange();
9595
}
@@ -219,7 +219,7 @@
219219
on:change={e => changeKnowledgeBase(e, uid)}
220220
>
221221
{#each [...knowledgeBaseOptions] as option}
222-
<option value={`${option.name}#${option.type}`} selected={option.name == knowledge.name}>
222+
<option value={`${JSON.stringify(option)}`} selected={option.name == knowledge.name}>
223223
{option.displayName || option.name}
224224
</option>
225225
{/each}

src/routes/page/agent/[agentId]/agent-components/agent-llm-config.svelte

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@
9999
handleAgentChange();
100100
}
101101
102+
/** @param {any} e */
103+
function changeReasoningEffortLevel(e) {
104+
config.reasoning_effort_level = e.target.value || null;
105+
handleAgentChange();
106+
}
107+
102108
/** @param {any} e */
103109
function validateIntegerInput(e) {
104110
const reg = new RegExp(INTEGER_REGEX, 'g');
@@ -174,5 +180,20 @@
174180
/>
175181
</div>
176182
</div>
183+
184+
<div class="mb-3 row">
185+
<label for="example-text-input" class="col-md-3 col-form-label">
186+
Reasoning effort
187+
</label>
188+
<div class="col-md-9">
189+
<Input type="select" value={config.reasoning_effort_level} on:change={e => changeReasoningEffortLevel(e)}>
190+
{#each reasonLevelOptions as option}
191+
<option value={option.value} selected={option.value == config.reasoning_effort_level}>
192+
{option.label}
193+
</option>
194+
{/each}
195+
</Input>
196+
</div>
197+
</div>
177198
</CardBody>
178199
</Card>

0 commit comments

Comments
 (0)