feat: add metering data

This commit is contained in:
zhaoweijie
2025-02-23 13:02:32 +08:00
parent c50bb49b37
commit 7b8879a7a8
9 changed files with 225 additions and 162 deletions

View File

@@ -91,7 +91,13 @@ export async function localIodSearch(
)
).flat()
return results
// results 根据 doId 去重
const map = new Map<string, IodRegistryEntry>()
for (const r of results) {
map.set(r.doId, r)
}
return Array.from(map.values())
}
const ARXIV_URL_PATTERN = /^https?:\/\/arxiv\.org\//

View File

@@ -95,13 +95,17 @@ export const getSystemPromptForWeb = async (
// )
// .join("\n")
}
const iod_search_results = iodSearchResults
.map((res) => ({
doId: res.doId,
name: res.name,
url: res.url,
content: res.content || res.description
}))
const _iodSearchResults = iodSearchResults
.map((res) => ({
doId: res.doId,
name: res.name,
url: res.url,
data_space: res.data_space,
tokenCount: (res.content || res.description)?.length ?? 0,
content: res.content || res.description
}))
const iod_search_results = _iodSearchResults
.map(
(result, idx) =>
`<result doId="${result.doId}" name="${result.name}" source="${result.url}" id="${idx + 1}">${result.content}</result>`
@@ -135,7 +139,9 @@ export const getSystemPromptForWeb = async (
type: "url"
}
}),
iodSources: iodSearchResults
iodSources: iodSearchResults,
iodData: _iodSearchResults,
iodDataTokenCount: _iodSearchResults.reduce((acc, cur) => (acc + cur.content.length), 0)
}
} catch (e) {
console.error(e)