Add dependencies and update code for PDF parsing and searching

This commit is contained in:
n4ze3m
2024-02-25 00:12:46 +05:30
parent f87953ba5c
commit 06b32176a9
22 changed files with 577 additions and 249 deletions

View File

@@ -9,6 +9,16 @@ type HistoryInfo = {
createdAt: number
}
type WebSearch = {
search_engine: string
search_url: string
search_query: string
search_results: {
title: string
link: string
}[]
}
type Message = {
id: string
history_id: string
@@ -17,6 +27,7 @@ type Message = {
content: string
images?: string[]
sources?: string[]
search?: WebSearch
createdAt: number
}
@@ -168,3 +179,11 @@ export const updateHistory = async (id: string, title: string) => {
})
db.db.set({ chatHistories: newChatHistories })
}
export const removeMessageUsingHistoryId = async (history_id: string) => {
// remove the last message
const db = new PageAssitDatabase()
const chatHistory = await db.getChatHistory(history_id)
const newChatHistory = chatHistory.slice(0, -1)
await db.db.set({ [history_id]: newChatHistory })
}

View File

@@ -8,11 +8,11 @@ const _getHtml = () => {
)
return { url, html }
}
export const getHtmlOfCurrentTab = async () => {
const result = new Promise((resolve) => {
chrome.tabs.query({ active: true, currentWindow: true }, async (tabs) => {
const tab = tabs[0]
const data = await chrome.scripting.executeScript({
target: { tabId: tab.id },
func: _getHtml