Skip to content

Commit

Permalink
Use update_time returned by backend API to set the attribute updatedT…
Browse files Browse the repository at this point in the history
…imeMs of session

Signed-off-by: gaobinlong <[email protected]>
  • Loading branch information
gaobinlong committed Dec 5, 2023
1 parent 4ff6726 commit fa52adf
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions server/services/storage/agent_framework_storage_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ export class AgentFrameworkStorageService implements StorageService {
};
}

// TODO: return real update_time in the response once the agent framework supports update_time field
async getSessions(query: GetSessionsSchema): Promise<ISessionFindResponse> {
let sortField = '';
if (query.sortField === 'updatedTimeMs') {
sortField = 'updated_time';
} else if (query.sortField === 'createTimeMs') {
sortField = 'create_time';
}
let searchFields: string[] = [];
Expand Down Expand Up @@ -111,18 +112,23 @@ export class AgentFrameworkStorageService implements StorageService {
objects: sessions.body.hits.hits
.filter(
(hit: {
_source: { name: string; create_time: string };
_source: { name: string; create_time: string; updated_time: string };
}): hit is RequiredKey<typeof hit, '_source'> =>
hit._source !== null && hit._source !== undefined
)
.map((item: { _id: string; _source: { name: string; create_time: string } }) => ({
id: item._id,
title: item._source.name,
version: 1,
createdTimeMs: Date.parse(item._source.create_time),
updatedTimeMs: Date.parse(item._source.create_time),
messages: [] as IMessage[],
})),
.map(
(item: {
_id: string;
_source: { name: string; create_time: string; updated_time: string };
}) => ({
id: item._id,
title: item._source.name,
version: 1,
createdTimeMs: Date.parse(item._source.create_time),
updatedTimeMs: Date.parse(item._source.updated_time),
messages: [] as IMessage[],
})
),
total:
typeof sessions.body.hits.total === 'number'
? sessions.body.hits.total
Expand Down

0 comments on commit fa52adf

Please sign in to comment.