|
| 1 | +import { ToolPreviewer } from '../_utils/ToolPreviewer.jsx'; |
| 2 | +import { AgentWithToolPreviewer } from '../_utils/AgentWithToolPreviewer.jsx'; |
| 3 | +import { JinaUrlToMarkdown } from './index.js'; |
| 4 | +import { Agent, Task, Team } from '../../../../src/index'; |
| 5 | +import React from 'react'; |
| 6 | + |
| 7 | +// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export |
| 8 | +export default { |
| 9 | + title: 'Tools/Jina URL to Markdown', |
| 10 | + parameters: { |
| 11 | + // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout |
| 12 | + layout: 'centered', |
| 13 | + }, |
| 14 | + // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs |
| 15 | + tags: ['autodocs'], |
| 16 | + // More on argTypes: https://storybook.js.org/docs/api/argtypes |
| 17 | + argTypes: { |
| 18 | + // backgroundColor: { control: 'color' }, |
| 19 | + // url: { control: 'text' }, |
| 20 | + // apiKey: { control: 'text' }, |
| 21 | + // format: { control: 'select', options: ['markdown', 'json']}, |
| 22 | + // initializationCode: { table: { disable: true } }, |
| 23 | + // executionCode: { table: { disable: true } } |
| 24 | + }, |
| 25 | +}; |
| 26 | + |
| 27 | +const jinaUrlToMarkdownTool = new JinaUrlToMarkdown({ |
| 28 | + // apiKey: import.meta.env.VITE_JINA_API_KEY, |
| 29 | + // options: { |
| 30 | + // targetSelector: ['body', '.class', '#id'], |
| 31 | + // retainImages: 'none', |
| 32 | + // }, |
| 33 | +}); |
| 34 | + |
| 35 | +// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args |
| 36 | +export const Default = { |
| 37 | + render: (args) => <ToolPreviewer {...args} />, |
| 38 | + args: { |
| 39 | + toolInstance: jinaUrlToMarkdownTool, |
| 40 | + callParams: { |
| 41 | + url: 'https://www.kaibanjs.com', |
| 42 | + }, |
| 43 | + }, |
| 44 | +}; |
| 45 | + |
| 46 | +// Create an agent with the firecrawl tool |
| 47 | +const webResearcher = new Agent({ |
| 48 | + name: 'Web Researcher', |
| 49 | + role: 'Web Content Analyzer', |
| 50 | + goal: 'Extract and analyze content from specified websites', |
| 51 | + tools: [jinaUrlToMarkdownTool], |
| 52 | +}); |
| 53 | + |
| 54 | +// Create a research task |
| 55 | +const webAnalysisTask = new Task({ |
| 56 | + description: |
| 57 | + 'Fetches web content from the followin URL: {url} and provides a structured summary', |
| 58 | + agent: webResearcher, |
| 59 | + expectedOutput: 'A well-formatted analysis of the website content', |
| 60 | +}); |
| 61 | + |
| 62 | +// Create the team |
| 63 | +const team = new Team({ |
| 64 | + name: 'Web Analysis Unit', |
| 65 | + description: 'Specialized team for web content extraction and analysis', |
| 66 | + agents: [webResearcher], |
| 67 | + tasks: [webAnalysisTask], |
| 68 | + inputs: { |
| 69 | + url: 'https://www.kaibanjs.com', |
| 70 | + }, |
| 71 | + env: { |
| 72 | + OPENAI_API_KEY: import.meta.env.VITE_OPENAI_API_KEY, |
| 73 | + }, |
| 74 | +}); |
| 75 | + |
| 76 | +// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args |
| 77 | +export const withAgent = { |
| 78 | + render: (args) => <AgentWithToolPreviewer {...args} />, |
| 79 | + args: { |
| 80 | + team: team, |
| 81 | + }, |
| 82 | +}; |
0 commit comments