feat: upgrade registry
This commit is contained in:
@@ -11,6 +11,7 @@ import { webBaiduSearch } from "./search-engines/baidu"
|
||||
import { searchIod } from "./iod"
|
||||
import type { WebSearchResult } from "~/types/web"
|
||||
import type { IodRegistryEntry } from "~/types/iod"
|
||||
import {calculateTokenCount} from "./iod"
|
||||
|
||||
const getHostName = (url: string) => {
|
||||
try {
|
||||
@@ -100,18 +101,24 @@ export const getSystemPromptForWeb = async (
|
||||
doId: res.doId,
|
||||
name: res.name,
|
||||
url: res.url,
|
||||
data_type: res.data_type,
|
||||
data_space: res.data_space,
|
||||
content: res.content || res.description,
|
||||
tokenCount: (res.content || res.description)?.length ?? 0,
|
||||
tokenCount: (res.content || res.description)?calculateTokenCount((res.content || res.description)):0,
|
||||
traceId:res?.traceId
|
||||
}))
|
||||
|
||||
const iod_search_results = _iodSearchResults
|
||||
.map(
|
||||
(result, idx) =>
|
||||
`<result doId="${result.doId}" name="${result.name}" source="${result.url}" id="${idx + 1}">${result.content}</result>`
|
||||
(result, idx) =>{
|
||||
const nameAttr = result.name ? ` name="${result.name}"` : '';
|
||||
const sourceAttr = result.url ? ` source="${result.url}"` : '';
|
||||
const dataTypeAttr = result.data_type ? ` dataType="${result.data_type}"` : '';
|
||||
const dataSourceAttr = result.data_space ?` 数据来源="${result.data_space}"`:''
|
||||
return `<result doId="${result.doId}"${nameAttr}${sourceAttr}${dataTypeAttr}${dataSourceAttr}" >${result.content}</result>`
|
||||
}
|
||||
)
|
||||
.join("\n")
|
||||
console.log("iod_search_result: " + iod_search_results)
|
||||
|
||||
const web_search_results = webSearchResults
|
||||
.map(
|
||||
@@ -119,7 +126,6 @@ export const getSystemPromptForWeb = async (
|
||||
`<result source="${result.url}" name="${result.name}" id="${idx + 1}">${result.content}</result>`
|
||||
)
|
||||
.join("\n")
|
||||
console.log("web_search_result: " + web_search_results)
|
||||
|
||||
const current_date_time = new Date().toLocaleString()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user