* feat: plugin run (#1950) * feat: plugin run * fix * ui * fix * change user input type * fix * fix * temp * split out plugin chat * perf: chatbox * perf: chatbox * fix: plugin runtime (#2032) * fix: plugin runtime * fix * fix build * fix build * perf: chat send prompt * perf: chat log ux * perf: chatbox context and share page plugin runtime * perf: plugin run time config * fix: ts * feat: doc * perf: isPc check * perf: variable input render * feat: app search * fix: response box height * fix: phone ui * perf: lock * perf: plugin route * fix: chat (#2049) --------- Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
31 lines
551 B
TypeScript
31 lines
551 B
TypeScript
import { urlsFetch } from '@fastgpt/service/common/string/cheerio';
|
|
|
|
type Props = {
|
|
url: string;
|
|
};
|
|
type Response = Promise<{
|
|
result: any;
|
|
}>;
|
|
|
|
const main = async ({ url }: Props): Response => {
|
|
try {
|
|
const result = await urlsFetch({
|
|
urlList: [url],
|
|
selector: 'body'
|
|
});
|
|
|
|
const title = result[0]?.title;
|
|
const content = result[0]?.content;
|
|
|
|
return {
|
|
result: `${title ? `# ${title}\n\n` : ''}${content}`
|
|
};
|
|
} catch (error) {
|
|
return {
|
|
result: 'Fetch error'
|
|
};
|
|
}
|
|
};
|
|
|
|
export default main;
|