Skip to content

Commit

Permalink
🔥 refactor: remove searchEngine
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Aug 18, 2023
1 parent 91663ea commit d0fc888
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 171 deletions.
20 changes: 4 additions & 16 deletions api/v1/runner.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// TODO:后续替换为 sdk
import { LobeChatPlugins } from '@lobehub/lobe-chat-plugins';

import { PluginsMap } from '../../plugins';
import { OpenAIPluginPayload } from '../../types/plugins';

export const config = {
Expand All @@ -15,14 +14,14 @@ const INDEX_URL = `https://registry.npmmirror.com/${INDEX_PKG}/latest/files`;
export default async (req: Request) => {
if (req.method !== 'POST') return new Response('Method Not Allowed', { status: 405 });

const res = await fetch(INDEX_URL);
const manifest: LobeChatPlugins = await res.json();
console.log('manifest:', manifest);

const { name, arguments: args } = (await req.json()) as OpenAIPluginPayload;

console.log(`检测到 functionCall: ${name}`);

const res = await fetch(INDEX_URL);
const manifest: LobeChatPlugins = await res.json();
console.log(manifest);

const item = manifest.plugins.find((i) => i.name === name);

// 先通过插件资产 endpoint 路径查询
Expand All @@ -33,16 +32,5 @@ export default async (req: Request) => {
return new Response(data);
}

// TODO:兼容性代码,全量完成迁移后移除
const func = PluginsMap[name];

if (func) {
const data = JSON.parse(args);
const result = await func.runner(data);

console.log(`[${name}]`, args, `result:`, JSON.stringify(result, null, 2).slice(0, 3600));

return new Response(JSON.stringify(result));
}
return;
};
6 changes: 0 additions & 6 deletions plugins/index.ts

This file was deleted.

27 changes: 0 additions & 27 deletions plugins/searchEngine/index.ts

This file was deleted.

40 changes: 0 additions & 40 deletions plugins/searchEngine/runner.ts

This file was deleted.

82 changes: 0 additions & 82 deletions plugins/searchEngine/type.ts

This file was deleted.

0 comments on commit d0fc888

Please sign in to comment.