Merge remote-tracking branch 'origin/next' into openai

This commit is contained in:
n4ze3m
2024-10-02 20:10:21 +05:30
18 changed files with 264 additions and 117 deletions

View File

@@ -81,6 +81,12 @@ export class PageAssitDatabase {
})
}
async getChatHistoryTitleById(id: string): Promise<string> {
const chatHistories = await this.getChatHistories()
const chatHistory = chatHistories.find((history) => history.id === id)
return chatHistory?.title || ""
}
async addChatHistory(history: HistoryInfo) {
const chatHistories = await this.getChatHistories()
const newChatHistories = [history, ...chatHistories]
@@ -482,4 +488,11 @@ export const getRecentChatFromCopilot = async () => {
const messages = await db.getChatHistory(history.id)
return { history, messages }
}
export const getTitleById = async (id: string) => {
const db = new PageAssitDatabase()
const title = await db.getChatHistoryTitleById(id)
return title
}