Add dependencies and update code for PDF parsing and searching
This commit is contained in:
@@ -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 })
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user