Skip to content

Commit e90c9ad

Browse files
authored
Merge pull request #369 from iceljc/features/refine-chat-window
Features/refine vector knowledge
2 parents 04e1e6d + a9a2bd6 commit e90c9ad

File tree

11 files changed

+589
-210
lines changed

11 files changed

+589
-210
lines changed

src/lib/helpers/enums.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,11 @@ const llmModelType = {
185185
Embedding: 4,
186186
Audio: 5
187187
};
188-
export const LlmModelType = Object.freeze(llmModelType);
188+
export const LlmModelType = Object.freeze(llmModelType);
189+
190+
const reasoningEffortLevel = {
191+
Low: "low",
192+
Medium: "medium",
193+
High: "high"
194+
};
195+
export const ReasoningEffortLevel = Object.freeze(reasoningEffortLevel);

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,22 @@
1515
* @property {number} [limit] - Data limit.
1616
* @property {number} [confidence] - Confidence.
1717
* @property {boolean} [with_vector] - Include vector or not.
18+
* @property {VectorFilterGroup[]} [filter_groups] - Search filter groups.
1819
*/
1920

2021
/**
2122
* @typedef {Object} KnowledgeFilter
2223
* @property {string | null} [start_id] - The start id.
2324
* @property {number} size - Page size.
2425
* @property {boolean} [with_vector] - Include vector or not.
25-
* @property {string[]} [included_payloads] - Included payload keys.
26-
* @property {{ key: string, value: string }[]} [search_pairs] - Search pairs.
26+
* @property {string[]} [fields] - Included payload fields.
27+
* @property {VectorFilterGroup[]} [filter_groups] - Search filter groups.
28+
*/
29+
30+
/**
31+
* @typedef {Object} VectorFilterGroup
32+
* @property {string} [filter_operator] - The filter operator.
33+
* @property {{ key: string, value: string }[]} [filters] - Search filters.
2734
*/
2835

2936
/**
@@ -32,6 +39,7 @@
3239
* @property {any} data - The knowledge data.
3340
* @property {number} [score] - The knowledge score.
3441
* @property {number[]} [vector] - The knowledge vector.
42+
* @property {number} [vector_dimension] - The vector dimension.
3543
*/
3644

3745
/**

src/lib/helpers/utils/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export function splitTextByCase(str) {
147147
if (!str) return str;
148148

149149
let words = str.split("_");
150-
if (words.length === 0) {
150+
if (words.length === 1) {
151151
// split by camel case
152152
words = str.split(/(?=[A-Z])/);
153153
}

src/lib/scss/custom/pages/_knowledgebase.scss

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
}
4242
}
4343

44+
.operator-tooltip {
45+
.tooltip-inner {
46+
width: fit-content !important;
47+
max-width: 300px !important;
48+
text-align: left !important;
49+
}
50+
}
51+
4452
.knowledge-textarea {
4553
border-radius: 5px;
4654
border-color: var(--#{$prefix}light) !important;
@@ -245,6 +253,24 @@
245253
font-size: 15px;
246254
}
247255
}
256+
257+
.payload-container {
258+
display: flex;
259+
flex-direction: column;
260+
gap: 10px;
261+
max-height: 280px;
262+
overflow-y: auto;
263+
scrollbar-width: none;
264+
265+
.payload-item {
266+
display: flex;
267+
gap: 10px;
268+
269+
.payload-item-content {
270+
flex: 0.5;
271+
}
272+
}
273+
}
248274
}
249275

250276
.knowledge-doc-upload-container {
@@ -360,6 +386,9 @@
360386
display: flex;
361387
flex-direction: column;
362388
gap: 10px;
389+
max-height: 300px;
390+
overflow-y: auto;
391+
scrollbar-width: none;
363392

364393
.knowledge-adv-search-item {
365394
display: flex;

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { Card, CardBody, Input } from '@sveltestrap/sveltestrap';
44
import { getLlmProviders, getLlmProviderModels } from '$lib/services/llm-provider-service';
55
import { INTEGER_REGEX } from '$lib/helpers/constants';
6+
import { ReasoningEffortLevel } from '$lib/helpers/enums';
67
78
/** @type {import('$agentTypes').AgentModel} */
89
export let agent;
@@ -18,6 +19,14 @@
1819
}
1920
2021
const recursiveDepthLowerLimit = 1;
22+
/** @type {import('$commonTypes').LabelValuePair[]} */
23+
const reasonLevelOptions = [
24+
{ value: '', label: '' },
25+
...Object.entries(ReasoningEffortLevel).map(([k, v]) => ({
26+
value: v,
27+
label: v
28+
}))
29+
];
2130
2231
let config = agent.llm_config;
2332
@@ -89,6 +98,12 @@
8998
handleAgentChange();
9099
}
91100
101+
/** @param {any} e */
102+
function changeReasoningEffortLevel(e) {
103+
config.reasoning_effort_level = e.target.value || null;
104+
handleAgentChange();
105+
}
106+
92107
/** @param {any} e */
93108
function validateIntegerInput(e) {
94109
const reg = new RegExp(INTEGER_REGEX, 'g');
@@ -164,5 +179,20 @@
164179
/>
165180
</div>
166181
</div>
182+
183+
<div class="mb-3 row">
184+
<label for="example-text-input" class="col-md-3 col-form-label">
185+
Reasoning level
186+
</label>
187+
<div class="col-md-9">
188+
<Input type="select" value={config.reasoning_effort_level} on:change={e => changeReasoningEffortLevel(e)}>
189+
{#each reasonLevelOptions as option}
190+
<option value={option.value} selected={option.value == config.reasoning_effort_level}>
191+
{option.label}
192+
</option>
193+
{/each}
194+
</Input>
195+
</div>
196+
</div>
167197
</CardBody>
168198
</Card>

0 commit comments

Comments
 (0)