diff --git a/example/src/ecommerce_product_description.ts b/example/src/ecommerce_product_description.ts index f26981e..b941dcb 100644 --- a/example/src/ecommerce_product_description.ts +++ b/example/src/ecommerce_product_description.ts @@ -8,8 +8,7 @@ import path from 'path' const techExpert = agent({ description: ` - You are skilled at extracting and describing most detailed - technical information about the product from the photo. + You are skilled at extracting and describing most detailed technical information about the product from the photo. `, tools: { visionTool, @@ -18,29 +17,23 @@ const techExpert = agent({ const marketingManager = agent({ description: ` - You are skilled at writing catchy product descriptions - making customers to instantly fall in love with the product. - Use the technical information provided by the technical expert to create a compelling product description. + You are skilled at writing catchy product descriptions making customers to instantly fall in love with the product. + You always answer why they should buy the product, how it will make their life better, + and what emotions it will evoke. `, }) const productDescriptionWorkflow = workflow({ team: { techExpert, marketingManager }, description: ` - Based on the picture '${path.resolve(import.meta.dirname, '../assets/example-sneakers.jpg')}' make the eCommerce product to - list this product on the website. - - Focus: - - find all technical features of the product - - color, size, material, brand if possible, etc. - - write a compelling product description - - why they should buy this product? - - how it will make their life better? - - emotions? + Based on the picture '${path.resolve(import.meta.dirname, '../assets/example-sneakers.jpg')}' + make the product description to list it on the website. + `, + knowledge: ` + Focus on all technical features of the product, including color, size, material, brand if possible, etc. `, output: ` - Catchy, yet detailed product description that will make customers to instantly fall in love with the product. - Should contain all the product features + marketing description. + Catchy product description covering all the product features. `, snapshot: logger, }) diff --git a/example/src/github_trending.ts b/example/src/github_trending.ts index 9c7eae5..d29e117 100644 --- a/example/src/github_trending.ts +++ b/example/src/github_trending.ts @@ -32,17 +32,15 @@ const wrapupRedactor = agent({ const wrapUpTrending = workflow({ team: { githubResearcher, wrapupRedactor }, description: ` - Research the URL "https://github.com/trending/typescript" page using firecrawl tool - Summarize information about 3 top projects into a comprehensive report markdown output. - - Here are some ground rules to follow: - - Include one sentence summary for each project. + Research the "https://github.com/trending/typescript" page. + Summarize information about 3 top projects into a comprehensive markdown report. + Include one sentence summary for each project. `, knowledge: ` - We are preparing a report for the Typescript community. + We are preparing a report for the TypeScript community. `, output: ` - Comprehensive markdown report with the top trending typescript projects. + Comprehensive markdown report with the top trending TypeScript projects. `, snapshot: logger, }) diff --git a/example/src/github_trending_vector.ts b/example/src/github_trending_vector.ts index bbf138e..dc7548f 100644 --- a/example/src/github_trending_vector.ts +++ b/example/src/github_trending_vector.ts @@ -20,7 +20,7 @@ const { firecrawl } = createFireCrawlTool({ const webCrawler = agent({ description: ` You are skilled at browsing Web pages. - You are saving the documents to vector store for later usage. + You can save the documents to Vector store for later usage. `, tools: { firecrawl, @@ -39,9 +39,8 @@ const human = agent({ const reportCompiler = agent({ description: ` - You can search Vector Store to find relevant informations and create reports based on it - Based on the information from Vector Store you can compile a comprehensive report. - You're famous of beautiful Markdown formatting. + You can create a comprehensive report based on the information from Vector store. + You're famous for beautiful Markdown formatting. `, tools: { searchInVectorStore, @@ -51,26 +50,20 @@ const reportCompiler = agent({ const wrapUpTrending = workflow({ team: { webCrawler, human, reportCompiler }, description: ` - Research the URL "https://github.com/trending/typescript" page. - Select 3 top projects. Browse details about these projects on their subpages. - Store each page in Vector Store for further usage. - After you store the information you don't need to browse the page again - because everything is stored in Vector Store. - - Ask user about which project he wants to learn more. Ask user only once. - `, + Research the "https://github.com/trending/typescript" page. + Select 3 top projects. + For each project, browse details about it on their subpages. + Store each page in Vector store for later usage. + + Ask user about which project he wants to learn more. + `, knowledge: ` - Create a comprehensive markdown report using information from Vector Store, based on user selection: - - create a one, two sentence summary about every project. - - include detailed summary about the project selected by the user. - - Here are some ground rules to follow: - - Use Vector Store if you need information about the project. + Each document in Vector store is a page from the website. `, output: ` - Comprehensive markdown report including: - - summary on top trending Typescript projects. - - detailed info about the project selected by the user. + Create a comprehensive markdown report: + - create a one, two sentences summary about every project. + - include detailed summary about the project selected by the user. `, snapshot: logger, }) diff --git a/example/src/library_photo_to_website.ts b/example/src/library_photo_to_website.ts index c640f97..34bcc22 100644 --- a/example/src/library_photo_to_website.ts +++ b/example/src/library_photo_to_website.ts @@ -1,3 +1,6 @@ +import fs from 'node:fs/promises' +import path from 'node:path' + import { createFileSystemTools } from '@fabrice-ai/tools/filesystem' import { visionTool } from '@fabrice-ai/tools/vision' import { agent } from 'fabrice-ai/agent' @@ -5,7 +8,6 @@ import { solution } from 'fabrice-ai/solution' import { teamwork } from 'fabrice-ai/teamwork' import { logger } from 'fabrice-ai/telemetry' import { workflow } from 'fabrice-ai/workflow' -import path from 'path' const workingDir = path.resolve(import.meta.dirname, '../assets/') @@ -16,7 +18,7 @@ const { saveFile, readFile, listFilesFromDirectory } = createFileSystemTools({ const librarian = agent({ description: ` You are skilled at scanning and identifying books in the library. - When asked, you will analyze the photo of the library and list all the books that you see, in details. + You can analyze the photo of the library and list all the books that you see, in details. `, tools: { visionTool, @@ -39,21 +41,25 @@ const webmaster = agent({ const imagePath = path.join(workingDir, 'photo-library.jpg') const outputPath = path.join(workingDir, 'library.html') +await fs.rm(outputPath, { force: true }) + const bookLibraryWorkflow = workflow({ team: { librarian, webmaster }, description: ` Analyze the photo of the library and list all the books in the library. - Generate a website that lists all the books in the library. + Find the best template to use for the website. + Copy the template to "${outputPath}" file. + Replace the content of the new with the list of books. `, knowledge: ` Important information: - The photo of books in the library is in the "${imagePath}" file. - - All available templates are in "${workingDir}" directory. Find the best template to use. + - All available templates are in "${workingDir}" directory. - You only have access to files in "${workingDir}" directory. - Use absolute paths for tool calls. - `, + `, output: ` - Create a new HTML page in "${outputPath}" directory, based on the best template you found. + Valid HTML page with the list of books in the library, stored in "${outputPath}" file. `, snapshot: logger, }) diff --git a/example/src/medical_survey/workflow.ts b/example/src/medical_survey/workflow.ts index 4f5e1f6..28195db 100644 --- a/example/src/medical_survey/workflow.ts +++ b/example/src/medical_survey/workflow.ts @@ -6,10 +6,12 @@ import { askUser } from '../tools/askUser.js' const nurse = agent({ description: ` You are skilled nurse / doctor assistant. - You role is to cooperate with reporter to create a pre-visit note for a patient that is about to come for a visit. - Ask user questions about the patient's health and symptoms. - Ask one question at time up to 5 questions. - Analyze the answer and ask another question based on the answer and context. + You are proffesional and kind. + + You can ask patient questions about their health and symptoms by running "askPatient" tool. + You can only ask one question at a time. + + You never ask for personal data that could be used to identify the patient. `, tools: { askPatient: askUser, @@ -27,29 +29,16 @@ const reporter = agent({ export const preVisitNoteWorkflow = workflow({ team: { nurse, reporter }, description: ` - Create a pre-visit note for a patient that is about to come for a visit. - The note should include the patient's health and symptoms. - `, - knowledge: ` - Behaviour: - - be professional and kind, - - ask questions one at a time, - - listen and analyze the answer before asking another question, - - be inquisitive and ask for details. + Interview a patient that is about to come for a visit. - Include: + You can only ask up to 5 questions in total. + You analyze the answer and ask another question based on the answer and context. + `, + output: ` + Comprehensive markdown pre-visit report that covers: - symptoms, - - health issues, - medications, - allergies, - - surgeries - - Never ask fo: - - personal data, - - sensitive data, - - any data that can be used to identify the patient. - `, - output: ` - A markdown report for the patient's pre-visit note. + - any other relevant information. `, }) diff --git a/example/src/news_wrap_up.ts b/example/src/news_wrap_up.ts index 8a348a5..802ae49 100644 --- a/example/src/news_wrap_up.ts +++ b/example/src/news_wrap_up.ts @@ -36,23 +36,19 @@ const wrapupRedactor = agent({ description: ` Your role is to wrap up the news and trends for the last week into a comprehensive report. Generalization is also one of your powerfull skills, however you're not a fortune teller. - You're famous of precisely getting the overal picture, trends and summarizing it all. + You're famous for precisely getting the overal picture, trends and summarizing it all. `, }) const wrapUpTheNewsWorkflow = workflow({ team: { newsResearcher, newsReader, wrapupRedactor }, description: ` - Research the top news and trends for the last week - get title and headline description. - Then summarize it all into a comprehensive report markdown output. - `, - knowledge: ` - Here are some ground rules to follow: - - Include one sentence summary for each article. - - Include top takeaways - bulletpoints from each article. + Research the top news and trends for the last week. `, output: ` Comprehensive markdown report with the listing including top news headlines for the last week. + - Include one sentence summary for each article. + - Include top takeaways - bulletpoints from each article. `, snapshot: logger, }) diff --git a/example/src/surprise_trip.ts b/example/src/surprise_trip.ts index 5d90d41..aa2d817 100644 --- a/example/src/surprise_trip.ts +++ b/example/src/surprise_trip.ts @@ -9,7 +9,7 @@ const personalizedActivityPlanner = agent({ description: ` You are skilled at creating personalized itineraries that cater to the specific preferences and demographics of travelers. - Your goal is to research and find cool things to do at the destination, + Your research and find cool things to do at the destination, including activities and events that match the traveler's interests and age group. `, }) @@ -17,7 +17,7 @@ const personalizedActivityPlanner = agent({ const landmarkScout = agent({ description: ` You are skilled at researching and finding interesting landmarks at the destination. - Your goal is to find historical landmarks, museums, and other interesting places. + Your find historical landmarks, museums, and other interesting places. `, tools: { lookupWikipedia, @@ -28,7 +28,7 @@ const restaurantScout = agent({ description: ` As a food lover, you know the best spots in town for a delightful culinary experience. You also have a knack for finding picturesque and entertaining locations. - Your goal is to find highly-rated restaurants and dining experiences at the destination, + Your find highly-rated restaurants and dining experiences at the destination, and recommend scenic locations and fun activities. `, }) @@ -36,8 +36,6 @@ const restaurantScout = agent({ const itineraryCompiler = agent({ description: ` With an eye for detail, you organize all the information into a coherent and enjoyable travel plan. - Your goal is to compile all researched information into a comprehensive day-by-day itinerary, - ensuring the integration of flights and hotel information. `, }) @@ -65,10 +63,12 @@ const researchTripWorkflow = workflow({ - Hotel location: Main Square, Wrocław - Flight information: Flight AA123, arriving on 2023-12-15 - How long is the trip: 7 days - `, + + Consider flights confirmed. + `, output: ` - Comprehensive day-by-day itinerary for the trip to Wrocław, Poland. - Ensure the itinerary includes flights, hotel information, and all planned activities and dining experiences. + Comprehensive day-by-day plan for the trip to Wrocław, Poland. + Ensure the plan includes flights, hotel information, and all planned activities and dining experiences. `, }) diff --git a/example/src/wikipedia_vector.ts b/example/src/wikipedia_vector.ts index c76954b..388a6c9 100644 --- a/example/src/wikipedia_vector.ts +++ b/example/src/wikipedia_vector.ts @@ -12,8 +12,8 @@ const { saveDocumentInVectorStore, searchInVectorStore } = createVectorStoreTool const wikipediaIndexer = agent({ description: ` You are skilled at reading and understanding the context of Wikipedia articles. - You split Wikipedia articles by each sentence. - Save each sentence as a document in Vector store. + You can save Wikipedia articles in Vector store for later use. + When saving articles in Vector store, you only save first 10 sentences. `, tools: { lookupWikipedia, @@ -24,8 +24,7 @@ const wikipediaIndexer = agent({ const reportCompiler = agent({ description: ` You are skilled at compiling information from various sources into a coherent report. - You have access to Vector database with indexed sentences of Wikipedia articles. - You are making use of it to find relevant information. + You can search for specific sentences in Vector database. `, tools: { searchInVectorStore, @@ -35,19 +34,16 @@ const reportCompiler = agent({ const wikipediaResearch = workflow({ team: { wikipediaIndexer, reportCompiler }, description: ` - Find information about John III Sobieski on Wikipedia. - Index the data into vector database. - List exact some example sentences related to: - - Battle of Vienna. - - John III later years and death. + Find information about John III Sobieski on Wikipedia and save it in Vector store. + Lookup sentences related to the following topics: + - "Battle of Vienna" + - "John III later years and death" `, - knowledge:` - Wikipedia article should be splited into sentences. - Every sentence should be stored as a document in Vector Store. + knowledge: ` + Each document in Vector store is a sentence. `, output: ` - Report with: - - bullet points - list of 2 sentences per each topic from vector store. + List of sentences looked up for each topic. Each sentence should be in separate bullet point. `, snapshot: logger, }) diff --git a/packages/framework/src/state.ts b/packages/framework/src/state.ts index fcbef31..2e8840e 100644 --- a/packages/framework/src/state.ts +++ b/packages/framework/src/state.ts @@ -28,8 +28,11 @@ export const rootState = (workflow: Workflow): WorkflowState => messages: [ user(s` Here is description of my workflow: - ${workflow.description} - ${workflow.output} + + ${workflow.description} + Create ${workflow.output} + + Here is all the knowledge available: ${workflow.knowledge} `),