update configs
This commit is contained in:
parent
8d6a9b39bb
commit
30aa0faaa1
@ -31,39 +31,39 @@ export const PlaygroundEmpty = () => {
|
|||||||
|
|
||||||
const questions = [
|
const questions = [
|
||||||
{
|
{
|
||||||
title: "最近一年大型语言模型的技术进展有哪些?",
|
title: "如何开发一个适合超大型城市的碳普惠方法学?",
|
||||||
icon: <img src={RocketSvg} alt="Rocket" className="w-10 my-0" />,
|
icon: <img src={RocketSvg} alt="Rocket" className="w-10 my-0" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "生成式AI在企业中有哪些具体应用场景?",
|
title: "如何开发一个零碳园区的数字化评价系统?",
|
||||||
icon: <img src={BulbSvg} alt="Rocket" className="w-10 my-0" />,
|
icon: <img src={BulbSvg} alt="Rocket" className="w-10 my-0" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "多模态学习技术的最新研究方向是什么?",
|
title: "如何开发一个碳定价预测系统?",
|
||||||
icon: <img src={EyeSvg} alt="Rocket" className="w-10 my-0" />,
|
icon: <img src={EyeSvg} alt="Rocket" className="w-10 my-0" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "当前AI芯片市场格局和未来三年发展趋势如何?",
|
title: "新药临床研究如何提升实验安全性?",
|
||||||
icon: <img src={ASvg} alt="Rocket" className="w-10 my-0" />,
|
icon: <img src={ASvg} alt="Rocket" className="w-10 my-0" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "主流深度学习框架性能与易用性对比分析?",
|
title: "如何加速新药申报和审批?",
|
||||||
icon: <img src={BSvg} alt="Rocket" className="w-10 my-0" />,
|
icon: <img src={BSvg} alt="Rocket" className="w-10 my-0" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "国内外AI伦理治理框架有哪些最佳实践?",
|
title: "如何研制与司美格鲁肽相似的新药?",
|
||||||
icon: <img src={CSvg} alt="Rocket" className="w-10 my-0" />,
|
icon: <img src={CSvg} alt="Rocket" className="w-10 my-0" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "大规模知识图谱构建与应用最新进展?",
|
title: "如何解决固态电池的成本和寿命难题?",
|
||||||
icon: <img src={DSvg} alt="Rocket" className="w-10 my-0" />,
|
icon: <img src={DSvg} alt="Rocket" className="w-10 my-0" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "计算机视觉领域近期突破性技术有哪些?",
|
title: "如何解决船舶制造中的材料腐蚀难题?",
|
||||||
icon: <img src={ESvg} alt="Rocket" className="w-10 my-0" />,
|
icon: <img src={ESvg} alt="Rocket" className="w-10 my-0" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "量子计算对AI算法的影响与应用前景?",
|
title: "如何解决船舶制造中流体模拟和建模优化难题?",
|
||||||
icon: <img src={FSvg} alt="Rocket" className="w-10 my-0" />,
|
icon: <img src={FSvg} alt="Rocket" className="w-10 my-0" />,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
178
src/web/iod.ts
178
src/web/iod.ts
@ -26,14 +26,65 @@ export const tokenizeInput = function (input: string): string[] {
|
|||||||
}
|
}
|
||||||
//doipUrl = tcp://reg01.public.internetofdata.cn:21037
|
//doipUrl = tcp://reg01.public.internetofdata.cn:21037
|
||||||
export const iodConfig = {
|
export const iodConfig = {
|
||||||
"gatewayUrl": "tcp://021.node.internetapi.cn:21052",
|
"gatewayUrl": "tcp://reg01.public.internetofdata.cn:21037",
|
||||||
"registry":"data/Registry",
|
"registry":"data/Registry",
|
||||||
"localRepository":"data/Repository",
|
"localRepository":"data/Repository",
|
||||||
"doBrowser":"http://021.node.internetapi.cn:21030/SCIDE/SCManager"
|
"doBrowser":"http://021.node.internetapi.cn:21030/SCIDE/SCManager"
|
||||||
}
|
}
|
||||||
|
export const iodConfigLocal = {
|
||||||
|
"gatewayUrl": "tcp://127.0.0.1:21036",
|
||||||
|
"registry":"bdware/Registry",
|
||||||
|
"localRepository":"bdtest.local/myrepo1",
|
||||||
|
"doBrowser":"http://127.0.0.1:21030/SCIDE/SCManager"
|
||||||
|
}
|
||||||
function inGrepList(str: string){
|
function inGrepList(str: string){
|
||||||
return "什么|问题|需要|合适|设计|考虑|合作|精度|传感器|最新|研究|药物".indexOf(str)!=-1;
|
return "什么|问题|需要|合适|设计|考虑|合作|精度|传感器|最新|研究|药物".indexOf(str)!=-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const makeSearchParamsWithDataType = function(count: number, keyword: string| string[], dataType: string){
|
||||||
|
const searchMode = [];
|
||||||
|
searchMode.push({"key":"data_type", "type":"MUST", "value":dataType})
|
||||||
|
if (typeof keyword === 'string') {
|
||||||
|
// 如果 keyword 是字符串,则直接添加一个 searchMode 条目
|
||||||
|
searchMode.push({
|
||||||
|
key: "description",
|
||||||
|
type: "MUST",
|
||||||
|
value: keyword
|
||||||
|
});
|
||||||
|
} else if (Array.isArray(keyword)) {
|
||||||
|
// 如果 keyword 是数组,则为每个元素添加一个 searchMode 条目
|
||||||
|
keyword.forEach(str => {
|
||||||
|
if (!inGrepList(str))
|
||||||
|
searchMode.push({
|
||||||
|
key: "description",
|
||||||
|
type: "SHOULD",
|
||||||
|
value: str
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
action: "executeContract",
|
||||||
|
contractID: "BDBrowser",
|
||||||
|
operation: "sendRequestDirectly",
|
||||||
|
arg: {
|
||||||
|
id: iodConfig.registry,
|
||||||
|
//doipUrl:"tcp://127.0.0.1:21039",
|
||||||
|
doipUrl: iodConfig.gatewayUrl,
|
||||||
|
op: "Search",
|
||||||
|
vars:{
|
||||||
|
timeout:15000
|
||||||
|
},
|
||||||
|
attributes: {
|
||||||
|
offset: 0,
|
||||||
|
count,
|
||||||
|
bodyBase64Encoded: false,
|
||||||
|
searchMode:searchMode
|
||||||
|
},
|
||||||
|
body: ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const makeRegSearchParams = function(count: number, keyword: string| string[]){
|
export const makeRegSearchParams = function(count: number, keyword: string| string[]){
|
||||||
const searchMode = [];
|
const searchMode = [];
|
||||||
if (typeof keyword === 'string') {
|
if (typeof keyword === 'string') {
|
||||||
@ -185,91 +236,61 @@ export async function localIodSearch(
|
|||||||
const abortController = new AbortController();
|
const abortController = new AbortController();
|
||||||
setTimeout(() => abortController.abort(), 10000);
|
setTimeout(() => abortController.abort(), 10000);
|
||||||
const params = makeRegSearchParams(TOTAL_SEARCH_RESULTS, keywords);
|
const params = makeRegSearchParams(TOTAL_SEARCH_RESULTS, keywords);
|
||||||
console.log('params------->',params)
|
const dataParams = makeSearchParamsWithDataType(TOTAL_SEARCH_RESULTS,keywords, "data");
|
||||||
|
const scenarioParams = makeSearchParamsWithDataType(TOTAL_SEARCH_RESULTS,keywords, "scenario");
|
||||||
|
const orgParams = makeSearchParamsWithDataType(TOTAL_SEARCH_RESULTS,keywords, "organization");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(iodConfig.doBrowser, {
|
console.log('params------->',params)
|
||||||
method: "POST",
|
const requests = [
|
||||||
body: JSON.stringify(params),
|
fetch(iodConfig.doBrowser,{method: "POST", body: JSON.stringify(dataParams),signal: abortController.signal}),
|
||||||
signal: abortController.signal
|
fetch(iodConfig.doBrowser,{method: "POST", body: JSON.stringify(scenarioParams),signal: abortController.signal}),
|
||||||
});
|
fetch(iodConfig.doBrowser,{method: "POST", body: JSON.stringify(orgParams),signal: abortController.signal})
|
||||||
|
];
|
||||||
|
//TODO @Zhaoweijie, 这三类分别是数据、场景、团队的搜索请求。
|
||||||
|
const responses = await Promise.all(requests);
|
||||||
|
const results = await Promise.all(responses.map(res => res.json()));
|
||||||
|
const allResults: IodRegistryEntry[] = [];
|
||||||
|
for (const res of results) {
|
||||||
|
// 检查顶层状态
|
||||||
|
if (res.status !== "Success") {
|
||||||
|
continue; // 跳过失败的请求
|
||||||
|
}
|
||||||
|
let body;
|
||||||
|
try {
|
||||||
|
body = JSON.parse(res.result.body);
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("Failed to parse result.body as JSON", e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const res = await response.json();
|
if (body.code !== 0) {
|
||||||
if (res.status !== "Success") {
|
continue;
|
||||||
return [];
|
}
|
||||||
|
const entries: IodRegistryEntry[] = body.data?.results || [];
|
||||||
|
// 数据清洗:补全 url 和 doId
|
||||||
|
for (const r of entries) {
|
||||||
|
r.url = r.url || r.pdf_url;
|
||||||
|
r.doId = r.doId || r.doid;
|
||||||
|
}
|
||||||
|
// 合并到总结果
|
||||||
|
allResults.push(...entries);
|
||||||
}
|
}
|
||||||
|
const seenDoIds = new Set<string>();
|
||||||
const body = JSON.parse(res.result.body);
|
const prunedResults: IodRegistryEntry[] = [];
|
||||||
if (body.code !== 0) {
|
for (const r of allResults) {
|
||||||
return [];
|
if (r.doId && !seenDoIds.has(r.doId)) {
|
||||||
|
seenDoIds.add(r.doId);
|
||||||
|
prunedResults.push(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return prunedResults;
|
||||||
let results: IodRegistryEntry[] = body.data?.results || [];
|
|
||||||
for (const r of results) {
|
|
||||||
r.url = r.url || r.pdf_url;
|
|
||||||
}
|
|
||||||
for (const r of results) {
|
|
||||||
r.doId = r.doId || r.doid;
|
|
||||||
}
|
|
||||||
|
|
||||||
// results 根据 doId 去重
|
|
||||||
const map = new Map<string, IodRegistryEntry>();
|
|
||||||
for (const r of results) {
|
|
||||||
map.set(r.doId, r);
|
|
||||||
}
|
|
||||||
return Array.from(map.values());
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
const results = (
|
|
||||||
await Promise.all(
|
|
||||||
keywords.map(async (keyword) => {
|
|
||||||
const abortController = new AbortController()
|
|
||||||
setTimeout(() => abortController.abort(), 10000)
|
|
||||||
//http://47.93.156.31:21033/SCIDE/SCManager
|
|
||||||
|
|
||||||
const params = makeRegSearchParams(TOTAL_SEARCH_RESULTS, keyword)
|
|
||||||
return fetch(iodConfig.doBrowser, {
|
|
||||||
method: "POST",
|
|
||||||
body: JSON.stringify(params),
|
|
||||||
signal: abortController.signal
|
|
||||||
})
|
|
||||||
.then((response) => response.json())
|
|
||||||
.then((res) => {
|
|
||||||
if (res.status !== "Success") {
|
|
||||||
console.log(res)
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
const body = JSON.parse(res.result.body)
|
|
||||||
if (body.code !== 0) {
|
|
||||||
console.log(body)
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
const results: IodRegistryEntry[] = body.data?.results || []
|
|
||||||
for (const r of results) {
|
|
||||||
r.url = r.url || r.pdf_url
|
|
||||||
}
|
|
||||||
for (const r of results) {
|
|
||||||
r.doId = r.doId || r.doid
|
|
||||||
}
|
|
||||||
return results
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
console.log(e)
|
|
||||||
return []
|
|
||||||
})
|
|
||||||
})
|
|
||||||
)
|
|
||||||
).flat()
|
|
||||||
|
|
||||||
// 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\//
|
const ARXIV_URL_PATTERN = /^https?:\/\/arxiv\.org\//
|
||||||
@ -280,6 +301,7 @@ export const searchIod = async (query: string, keywords: string[]) => {
|
|||||||
|
|
||||||
const isSimpleMode = await getIsSimpleInternetSearch()
|
const isSimpleMode = await getIsSimpleInternetSearch()
|
||||||
console.log("searchMode:"+isSimpleMode+"\n kw:"+JSON.stringify(keywords)+"\n"+" ->searchResult:\n"+JSON.stringify(searchResults))
|
console.log("searchMode:"+isSimpleMode+"\n kw:"+JSON.stringify(keywords)+"\n"+" ->searchResult:\n"+JSON.stringify(searchResults))
|
||||||
|
console.log("pruned Search Result:"+JSON.stringify(searchResults.map(r=>r.doId+" "+r.name)))
|
||||||
if (isSimpleMode) {
|
if (isSimpleMode) {
|
||||||
await getOllamaURL()
|
await getOllamaURL()
|
||||||
return searchResults
|
return searchResults
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user