Skip to content

Commit 24e3254

Browse files
authored
Merge pull request #325 from iceljc/features/refine-chat-window
refine state key search
2 parents 84fb2fc + 3f7c343 commit 24e3254

File tree

10 files changed

+69
-12
lines changed

10 files changed

+69
-12
lines changed

src/lib/common/StateModal.svelte

+7-5
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,16 @@
196196
</FormGroup>
197197
</div>
198198
{/if}
199-
<div class="state-delete mb-3 line-align-center">
200-
{#if idx !== 0}
201-
<div>
199+
<div class="state-delete mb-3 line-align-center" style={`padding-top: ${idx === 0 ? '28px' : '0px'}`}>
200+
<div class="line-align-center">
202201
<!-- svelte-ignore a11y-click-events-have-key-events -->
203202
<!-- svelte-ignore a11y-no-static-element-interactions -->
204-
<span><i class="bx bx-no-entry clickable" on:click={() => remove(idx)} /></span>
203+
<i
204+
class="bx bx-no-entry clickable"
205+
class:hide={states.length === 1}
206+
on:click={() => remove(idx)}
207+
/>
205208
</div>
206-
{/if}
207209
</div>
208210
</Row>
209211
{/each}

src/lib/helpers/http.js

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ function skipLoader(config) {
108108
new RegExp('http(s*)://(.*?)/user/(.*?)/details', 'g'),
109109
new RegExp('http(s*)://(.*?)/agent/labels', 'g'),
110110
new RegExp('http(s*)://(.*?)/conversation/state/keys', 'g'),
111+
new RegExp('http(s*)://(.*?)/logger/instruction/log/keys', 'g')
111112
];
112113

113114
if (config.method === 'post' && postRegexes.some(regex => regex.test(config.url || ''))) {

src/lib/helpers/types/conversationTypes.js

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
* @property {number?} [keyLimit] - The key limit.
3838
* @property {number?} [convLimit] - The conversation limit.
3939
* @property {boolean?} [preload] - Whether it is preloading or not.
40+
* @property {string[]?} [agentIds]
4041
*/
4142

4243

src/lib/helpers/types/instructTypes.js

+9
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,13 @@
4242
* @property {Date} created_time
4343
*/
4444

45+
/**
46+
* @typedef {Object} StateSearchQuery
47+
* @property {string} query - The search query.
48+
* @property {number?} [keyLimit] - The key limit.
49+
* @property {number?} [logLimit] - The log limit.
50+
* @property {boolean?} [preload] - Whether it is preloading or not.
51+
* @property {string[]?} [agentIds]
52+
*/
53+
4554
export default {};

src/lib/scss/custom/pages/_chat.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@
671671
.state-delete {
672672
flex: 0.1;
673673
color: var(--bs-danger);
674-
font-size: 17px;
674+
font-size: 12px;
675675
}
676676

677677
.invalid {

src/lib/services/api-endpoints.js

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export const endpoints = {
4646
instructCompletionUrl: `${host}/instruct/{agentId}`,
4747
chatCompletionUrl: `${host}/instruct/chat-completion`,
4848
instructLogUrl: `${host}/logger/instruction/log`,
49+
instructLogSearchKeysUrl: `${host}/logger/instruction/log/keys`,
4950

5051
// agent realtime interaction
5152
agentInitRealtimeSessionUrl: `${host}/agent/{agentId}/realtime/session`,

src/lib/services/conversation-service.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { replaceUrl } from '$lib/helpers/http';
21
import axios from 'axios';
3-
import { endpoints } from './api-endpoints.js';
2+
import qs from 'qs';
3+
import { replaceUrl } from '$lib/helpers/http';
44
import { conversationUserStateStore } from '$lib/helpers/store.js';
5+
import { endpoints } from './api-endpoints.js';
56

67
/**
78
* New conversation
@@ -44,7 +45,12 @@ export async function getConversationUser(id) {
4445
*/
4546
export async function getConversations(filter) {
4647
let url = endpoints.conversationsUrl;
47-
const response = await axios.post(url, { ...filter});
48+
const response = await axios.get(url, {
49+
params: {
50+
...filter
51+
},
52+
paramsSerializer: (params) => qs.stringify(params, { encode: false, allowDots: true, arrayFormat: "indices" })
53+
});
4854
return response.data;
4955
}
5056

@@ -304,6 +310,10 @@ export async function getConversationStateSearchKeys(request) {
304310
params: {
305311
...request
306312
},
313+
paramsSerializer: {
314+
dots: true,
315+
indexes: null,
316+
},
307317
signal: controller.signal
308318
});
309319
return response.data;

src/lib/services/instruct-service.js

+19
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,22 @@ export async function getInstructionLogs(filter) {
4040
});
4141
return response.data;
4242
}
43+
44+
/**
45+
* get instruction log search keys
46+
* @param {import('$instructTypes').StateSearchQuery} request
47+
* @returns {Promise<string[]>}
48+
*/
49+
export async function getInstructionLogSearchKeys(request) {
50+
let url = endpoints.instructLogSearchKeysUrl;
51+
const response = await axios.get(url, {
52+
params: {
53+
...request
54+
},
55+
paramsSerializer: {
56+
dots: true,
57+
indexes: null,
58+
}
59+
});
60+
return response.data;
61+
}

src/routes/page/conversation/+page.svelte

+2-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,8 @@
335335
return new Promise((resolve) => {
336336
getConversationStateSearchKeys({
337337
query: query,
338-
keyLimit: 20
338+
keyLimit: 20,
339+
agentIds: searchOption.agentId ? [searchOption.agentId] : null
339340
}).then(res => {
340341
resolve(res || []);
341342
}).catch(() => resolve([]));

src/routes/page/instruction/log/+page.svelte

+15-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import TablePagination from '$lib/common/TablePagination.svelte';
99
import { getAgentOptions } from '$lib/services/agent-service';
1010
import { getLlmConfigs } from '$lib/services/llm-provider-service';
11-
import { getInstructionLogs } from '$lib/services/instruct-service';
11+
import { getInstructionLogs, getInstructionLogSearchKeys } from '$lib/services/instruct-service';
1212
import LoadingToComplete from '$lib/common/LoadingToComplete.svelte';
1313
import LogItem from './log-item.svelte';
1414
import { removeDuplicates } from '$lib/helpers/utils/common';
@@ -218,6 +218,19 @@
218218
};
219219
getPagedInstructionLogs();
220220
}
221+
222+
/** @param {string} query */
223+
function handleStateSearch(query) {
224+
return new Promise((resolve) => {
225+
getInstructionLogSearchKeys({
226+
query: query,
227+
keyLimit: 20,
228+
agentIds: searchOption.agentId ? [searchOption.agentId] : null
229+
}).then(res => {
230+
resolve(res || []);
231+
}).catch(() => resolve([]));
232+
});
233+
}
221234
</script>
222235
223236
@@ -256,7 +269,7 @@
256269
<CardBody class="border-bottom">
257270
<Row class="g-3 justify-content-end">
258271
<Col lg="6">
259-
<StateSearch bind:states={states} />
272+
<StateSearch bind:states={states} onSearch={(query) => handleStateSearch(query)} />
260273
</Col>
261274
</Row>
262275
</CardBody>

0 commit comments

Comments
 (0)