Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -356,18 +356,6 @@
"typescript": "^5.0.0",
},
},
"modules/tool/packages/linkMemo": {
"name": "@fastgpt-plugins/tool-link-memo",
"dependencies": {
"zod": "^3.24.2",
},
"devDependencies": {
"@types/bun": "latest",
},
"peerDependencies": {
"typescript": "^5.0.0",
},
},
"modules/tool/packages/markdownTransform": {
"name": "fastgpt-tools-markdownTransform",
"version": "1.0.0",
Expand Down Expand Up @@ -436,6 +424,19 @@
"typescript": "^5.0.0",
},
},
"modules/tool/packages/perplexity": {
"name": "@fastgpt-plugins/tool-perplexity",
"dependencies": {
"@perplexity-ai/perplexity_ai": "^0.10.0",
"zod": "^3.24.2",
},
"devDependencies": {
"@types/bun": "latest",
},
"peerDependencies": {
"typescript": "^5.0.0",
},
},
"modules/tool/packages/searchApi": {
"name": "fastgpt-tools-SearchApi",
"dependencies": {
Expand Down Expand Up @@ -764,10 +765,12 @@

"@fastgpt-plugins/tool-chat-ppt": ["@fastgpt-plugins/tool-chat-ppt@workspace:modules/tool/packages/chatPPT"],

"@fastgpt-plugins/tool-link-memo": ["@fastgpt-plugins/tool-link-memo@workspace:modules/tool/packages/linkMemo"],

"@fastgpt-plugins/tool-mineru": ["@fastgpt-plugins/tool-mineru@workspace:modules/tool/packages/mineru"],

"@fastgpt-plugins/tool-moji-weather": ["@fastgpt-plugins/tool-moji-weather@workspace:modules/tool/packages/mojiWeather"],

"@fastgpt-plugins/tool-perplexity": ["@fastgpt-plugins/tool-perplexity@workspace:modules/tool/packages/perplexity"],

"@fastgpt-plugins/tool-search-infinity": ["@fastgpt-plugins/tool-search-infinity@workspace:modules/tool/packages/searchInfinity"],

"@fastgpt-sdk/plugin": ["@fastgpt-sdk/plugin@workspace:sdk"],
Expand Down Expand Up @@ -878,6 +881,8 @@

"@opentelemetry/semantic-conventions": ["@opentelemetry/[email protected]", "", {}, "sha512-JD6DerIKdJGmRp4jQyX5FlrQjA4tjOw1cvfsPAZXfOOEErMUHjPcPSICS+6WnM0nB0efSFARh0KAZss+bvExOA=="],

"@perplexity-ai/perplexity_ai": ["@perplexity-ai/[email protected]", "", {}, "sha512-h+RHkdMPrvIQJFVhr5AQFbkJsvmtxl0+Gy6eacXLV/knRFR/8z3+9UfW3b+VifNq5myYC0OZyLl/zRieVq7AzQ=="],

"@pkgjs/parseargs": ["@pkgjs/[email protected]", "", {}, "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg=="],

"@protobufjs/aspromise": ["@protobufjs/[email protected]", "", {}, "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ=="],
Expand Down
2 changes: 1 addition & 1 deletion modules/tool/packages/chatPPT/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"dependencies": {
"zod": "^3.24.2"
}
}
}
46 changes: 46 additions & 0 deletions modules/tool/packages/perplexity/children/findResults/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { defineTool } from '@tool/type';
import { FlowNodeInputTypeEnum, WorkflowIOValueTypeEnum } from '@tool/type/fastgpt';

export default defineTool({
name: {
'zh-CN': '网络搜索',
en: 'Network search'
},
description: {
'zh-CN': '使用 Perplexity 进行网络搜索',
en: 'Use Perplexity to search the web'
},
toolDescription: '使用 Perplexity 进行网络搜索',
versionList: [
{
value: '0.1.0',
description: 'Default version',
inputs: [
{
key: 'query',
label: '查询词',
renderTypeList: [FlowNodeInputTypeEnum.input, FlowNodeInputTypeEnum.reference],
valueType: WorkflowIOValueTypeEnum.string,
required: true
},
{
key: 'max_results',
label: '最大查询量',
renderTypeList: [FlowNodeInputTypeEnum.numberInput, FlowNodeInputTypeEnum.reference],
valueType: WorkflowIOValueTypeEnum.number,
min: 1,
max: 20,
defaultValue: 10
}
],
outputs: [
{
valueType: WorkflowIOValueTypeEnum.arrayObject,
key: 'result',
label: '搜索结果',
description: '搜索结果'
}
]
}
]
});
10 changes: 10 additions & 0 deletions modules/tool/packages/perplexity/children/findResults/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import config from './config';
import { InputType, OutputType, tool as toolCb } from './src';
import { exportTool } from '@tool/utils/tool';

export default exportTool({
toolCb,
InputType,
OutputType,
config
});
39 changes: 39 additions & 0 deletions modules/tool/packages/perplexity/children/findResults/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { z } from 'zod';
import Perplexity from '@perplexity-ai/perplexity_ai';

export const InputType = z.object({
apiKey: z.string(),
query: z.string(),
max_results: z.number().min(1).max(20).optional().default(10)
});

export const OutputType = z.object({
result: z.array(
z.object({
title: z.string(),
url: z.string(),
snippet: z.string()
})
)
});

export async function tool({
apiKey,
query,
max_results
}: z.infer<typeof InputType>): Promise<z.infer<typeof OutputType>> {
const client = new Perplexity({ apiKey });

const search = await client.search.create({
query,
max_results
});

return {
result: search.results.map((item) => ({
title: item.title,
url: item.url,
snippet: item.snippet
}))
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { expect, test } from 'vitest';
import tool from '..';

test(async () => {
expect(tool.name).toBeDefined();
expect(tool.description).toBeDefined();
expect(tool.cb).toBeDefined();
});
24 changes: 24 additions & 0 deletions modules/tool/packages/perplexity/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineToolSet } from '@tool/type';
import { ToolTypeEnum } from '@tool/type/tool';

export default defineToolSet({
name: {
'zh-CN': 'Perplexity 工具集',
en: 'Perplexity Tool Set'
},
type: ToolTypeEnum.tools,
description: {
'zh-CN': '这是一个 Perplexity 工具集',
en: 'This is a Perplexity tool set'
},
courseUrl: 'https://docs.perplexity.ai/getting-started/overview',
secretInputConfig: [
{
key: 'apiKey',
label: 'API Key',
description: '可以在 Perplexity 获取',
required: true,
inputType: 'secret'
}
]
});
8 changes: 8 additions & 0 deletions modules/tool/packages/perplexity/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// You should not modify this file, if you need to modify the tool set configuration, please modify the config.ts file

import config from './config';
import { exportToolSet } from '@tool/utils/tool';

export default exportToolSet({
config
});
1 change: 1 addition & 0 deletions modules/tool/packages/perplexity/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions modules/tool/packages/perplexity/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@fastgpt-plugins/tool-perplexity",
"module": "index.ts",
"type": "module",
"scripts": {
"build": "bun ../../../../scripts/build.ts"
},
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"@perplexity-ai/perplexity_ai": "^0.10.0",
"zod": "^3.24.2"
}
}