Skip to content

Commit

Permalink
🐛 fix: fix topic summary field on server db (#4655)
Browse files Browse the repository at this point in the history
* 🐛 fix: fix topic summary field

* 🐛 fix: add antd icons deps
  • Loading branch information
arvinxx authored Nov 9, 2024
1 parent a4355fc commit ce10f9a
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 19 deletions.
16 changes: 1 addition & 15 deletions src/database/server/models/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export class TopicModel {
.select({
createdAt: topics.createdAt,
favorite: topics.favorite,
historySummary: topics.historySummary,
id: topics.id,
metadata: topics.metadata,
summary: topics.historySummary,
title: topics.title,
updatedAt: topics.updatedAt,
})
Expand All @@ -49,20 +49,6 @@ export class TopicModel {
.limit(pageSize)
.offset(offset)
);

// return result.map(({ summary, metadata, ...item }) => {
// const meta = metadata as ChatTopicMetadata;
// return {
// ...item,
// summary: !!summary
// ? ({
// content: summary,
// model: meta?.model,
// provider: meta?.provider,
// } as ChatTopicSummary)
// : undefined,
// };
// });
}

async findById(id: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const ReactRenderer = memo<ReactRendererProps>(({ code }) => {
<SandpackProvider
customSetup={{
dependencies: {
'@ant-design/icons': 'latest',
'@lshay/ui': 'latest',
'@radix-ui/react-alert-dialog': 'latest',
'@radix-ui/react-dialog': 'latest',
Expand Down
2 changes: 1 addition & 1 deletion src/server/routers/lambda/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const topicRouter = router({
id: z.string(),
value: z.object({
favorite: z.boolean().optional(),
historySummary: z.string().optional(),
messages: z.array(z.string()).optional(),
metadata: z
.object({
Expand All @@ -128,7 +129,6 @@ export const topicRouter = router({
})
.optional(),
sessionId: z.string().optional(),
summary: z.string().optional(),
title: z.string().optional(),
}),
}),
Expand Down
2 changes: 1 addition & 1 deletion src/store/chat/slices/aiChat/actions/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export const chatMemory: StateCreator<
});

await topicService.updateTopic(topicId, {
historySummary,
metadata: { model, provider },
summary: historySummary,
});
await get().refreshTopic();
await get().refreshMessages();
Expand Down
2 changes: 1 addition & 1 deletion src/store/chat/slices/topic/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const currentActiveTopicSummary = (s: ChatStoreState): ChatTopicSummary | undefi
if (!activeTopic) return undefined;

return {
content: activeTopic.summary || '',
content: activeTopic.historySummary || '',
model: activeTopic.metadata?.model || '',
provider: activeTopic.metadata?.provider || '',
};
Expand Down
2 changes: 1 addition & 1 deletion src/types/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export interface ChatTopicSummary {

export interface ChatTopic extends Omit<BaseDataModel, 'meta'> {
favorite?: boolean;
historySummary?: string;
metadata?: ChatTopicMetadata;
sessionId?: string;
summary?: string;
title: string;
}

Expand Down

0 comments on commit ce10f9a

Please sign in to comment.