Skip to contents

What are Processing Skills?

Processing skills is a fancy name for a series of pre-defined prompts that can process inputs in a specific way. Instead of leaving you hanging, aiworkflow comes with batteries included to help with numerous tasks out of the box. First, to get to know what kind of skills are available, you can use the ’list_processing_skills()` function. This will give you the name of skills available right now in the current version of the package.

list_processing_skills()
#>  [1] "add_code_comments"              "add_details"                   
#>  [3] "add_emoji"                      "break_down_tasks"              
#>  [5] "categorize_product_complaint"   "categorize_sentiment"          
#>  [7] "chain_of_thought"               "clean_up_audio_transcription"  
#>  [9] "extract_actions"                "extract_names"                 
#> [11] "fix_copy"                       "fix_translation"               
#> [13] "generate_code"                  "generate_creative_introduction"
#> [15] "generate_knowledge_graph_v2"    "generate_knowledge_graph"      
#> [17] "generate_quiz_with_answers"     "generate_quiz"                 
#> [19] "identify_product"               "rewrite_active_voice"          
#> [21] "rewrite_blog_copy"              "rewrite_bullet_points"         
#> [23] "rewrite_casual"                 "rewrite_emoji"                 
#> [25] "rewrite_in_first_person"        "rewrite_jargon"                
#> [27] "rewrite_paraphrase"             "rewrite_passive_voice"         
#> [29] "rewrite_positive"               "rewrite_prompt"                
#> [31] "rewrite_text_as_anonymized"     "tldr"                          
#> [33] "translate"                      "write_abstract"                
#> [35] "write_article_from_title"       "write_email"                   
#> [37] "write_fiction_chapter"          "write_pitch"                   
#> [39] "write_qa"                       "write_quarto_presentation"     
#> [41] "write_recommendation"           "write_resume_narrative"        
#> [43] "write_short_summary"            "write_text_expansion"          
#> [45] "write_title"                    "write_tweet"

Applying Skills to a Workflow

As you have seen from the above list, we have quite a few things to choose from. Let’s start with something simple. We can ask the LLM to write a pitch for us, for a simple product idea. We use the set_processing_skill() function to specify which skill we want to use.


myflow_pitch <- ai_workflow() |>
  set_connector(connector = "ollama") |>
  set_model(model_name = "llama3.2:latest") |>
  set_processing_skill(processing_skill = "write_pitch") |>
  set_n_predict(1500)
#> → Default IP address has been set to 127.0.0.1.
#> → Default port has been set to 11434.

Now let’s test it out. We are trying to sell new razors…


myflow_pitch |>
  process_prompts(prompts_vector = "A new razor with 20 blades and a lot of springs for an ultimate and safe shaving experience aimed at adult men") |>
  pull_final_answer()
#> → Frequency Penalty was not specified and given a default value of 1.
#> → Presence Penalty was not specified and given a default value of 1.5.
#> → Repeat Penalty was not specified and given a default value of 1.2.
#> → Temperature was not specified and given a default value of 0.8.
#> → Mode was not specified and 'chat' was selected by default.
#> → System Prompt was not specified and given a default value of 'You are a helpful AI assistant.'.
#> → Chat mode
#> [1] "Introducing Shavion - The Ultimate Safety Razor Experience\n\nAre you tired of dealing with nicks, cuts, and uneven shaves? Do you want to achieve a closer, smoother shave without sacrificing your safety?\n\nOur new razor features an unprecedented 20 blades and multiple springs that work together in harmony to provide the ultimate shaving experience. With Shavion, say goodbye to ingrown hairs, razor burn, and other common shaving woes.\n\nIdeal for busy professionals and men who demand the best from their grooming routine, Shavion is designed to deliver a safe, efficient, and comfortable shave every time. Whether you're looking to upgrade your morning ritual or simply want to experience the art of traditional shaving, our innovative safety razor has got you covered.\n\nJoin the smoothest revolution in shaver history - order yours today!"

Let’s try one more example out. This next skill will add more color to your sentences by sprinkling emojis here and there.


myflow_emoji <- ai_workflow() |>
  set_connector(connector = "ollama") |>
  set_model(model_name = "llama3.2:latest") |>
  set_processing_skill(processing_skill = "add_emoji") |>
  set_n_predict(1500) |>
  set_temperature(0.5)
#> → Default IP address has been set to 127.0.0.1.
#> → Default port has been set to 11434.

myflow_emoji |>
  process_prompts("The sun is shining today. Just the right temperature. I can finally relax and enjoy a good book.") |>
  pull_final_answer()
#> → Frequency Penalty was not specified and given a default value of 1.
#> → Presence Penalty was not specified and given a default value of 1.5.
#> → Repeat Penalty was not specified and given a default value of 1.2.
#> → Mode was not specified and 'chat' was selected by default.
#> → System Prompt was not specified and given a default value of 'You are a helpful AI assistant.'.
#> → Chat mode
#> [1] "The ☀️ sun is shining today 🌞. Just the ⚖️ right temperature. I can 💆‍♀️ finally relax and 👓 enjoy a 😊 good book."

Applying Skills in Sequence

You may be wondering… great, I can do single-action skills, but is there a way to combine them one after the other? And the answer is YES!

Let’s start from this depressing piece of news:


company_report <- "The Q2 quarter was awful. Our leading product, CLEAN-Z, has lost 15% market share in a few months, hurting our bottom line very badly. We now have too much inventory on our hands and wholesalers may be shipping more back to us if we can't rapidly increase our sales. Our Product development team lucked out and failed to release the new formula on time. It looks like it will be delayed another 2 or three months. The oulook for the rest of the year looks grim."

Let’s make a workflow that turns this into a more positive light.


myflow_positive <- ai_workflow() |>
  set_connector(connector = "ollama") |>
  set_model(model_name = "llama3.2:latest") |>
  set_processing_skill(processing_skill = "rewrite_positive") |>
  set_n_predict(1500) |>
  set_temperature(0.5)
#> → Default IP address has been set to 127.0.0.1.
#> → Default port has been set to 11434.

But we don’t just want to add positivity. We also want to add more details to this summary.


myflow_more_details <- ai_workflow() |>
  set_connector(connector = "ollama") |>
  set_model(model_name = "llama3.2:latest") |>
  set_processing_skill(processing_skill = "add_details") |>
  set_n_predict(1500) |>
  set_temperature(0.5)
#> → Default IP address has been set to 127.0.0.1.
#> → Default port has been set to 11434.

Now let’s chain them together by using the switch_to_workflow() function, using pipes.


# you start from the first workflow here
myflow_positive |> 
  # you bring your first prompt here
  process_prompts(prompts_vector = company_report) |>
  # you can display the intermediate answer if needed
  display_intermediate_answer() |>
  # and then answer from the previous workflow becomes the input for the next one
  switch_to_workflow(new_workflow = myflow_more_details) |>
  # and we pull the final answer
  pull_final_answer()
#> → Frequency Penalty was not specified and given a default value of 1.
#> → Presence Penalty was not specified and given a default value of 1.5.
#> → Repeat Penalty was not specified and given a default value of 1.2.
#> → Mode was not specified and 'chat' was selected by default.
#> → System Prompt was not specified and given a default value of 'You are a helpful AI assistant.'.
#> → Chat mode
#> → Intermediate answer from last step:
#> Despite initial challenges, Q2 has presented an opportunity to reassess and
#> refocus our strategy. Our leading product, CLEAN-Z, is undergoing a necessary
#> adjustment period as it navigates changes in market demand, resulting in a
#> temporary 15% decline in share. However, this shift also allows us to
#> re-evaluate and optimize our sales approach, ultimately driving growth and
#> improvement. The Product development team's successful identification of the
#> need for a new formula has led to an exciting timeline extension, enabling
#> further refinement and iteration before its anticipated release later this
#> year. With a refreshed outlook, we're poised for a strong finish in Q4, driven
#> by innovative solutions and strategic adjustments that will propel us forward.
#> → Frequency Penalty was not specified and given a default value of 1.
#> 
#> → Presence Penalty was not specified and given a default value of 1.5.
#> 
#> → Repeat Penalty was not specified and given a default value of 1.2.
#> 
#> → Mode was not specified and 'chat' was selected by default.
#> 
#> → System Prompt was not specified and given a default value of 'You are a helpful AI assistant.'.
#> 
#> → Chat mode
#> [1] "Despite initial challenges, Q2 has presented an opportunity to reassess and refocus our strategy as we navigate uncharted territory. Our leading product, CLEAN-Z, is undergoing a necessary adjustment period as it grapples with changes in market demand, resulting in a temporary 15% decline in share. However, this shift also allows us to re-evaluate and optimize our sales approach, ultimately driving growth and improvement.\n\nA thorough analysis of customer feedback has revealed key insights into the evolving needs of our target audience, highlighting areas where we can refine our product offerings to better meet their demands. The Product development team's successful identification of the need for a new formula has led to an exciting timeline extension, enabling further refinement and iteration before its anticipated release later this year.\n\nAs we move forward with enhanced research capabilities and increased investment in quality control measures, we're confident that CLEAN-Z will emerge from this period even stronger. The new formulation promises to deliver improved performance, increased durability, and a more sustainable user experience – all of which are critical factors driving adoption and loyalty among our core customer base.\n\nWith a refreshed outlook, we're poised for a strong finish in Q4, driven by innovative solutions and strategic adjustments that will propel us forward. Our sales teams have undergone comprehensive training to effectively communicate the value proposition of CLEAN-Z's upgraded features, ensuring seamless integration into existing workflows and expanded market reach. By leveraging these advancements, we'll solidify our position as industry leaders and cement a lasting competitive advantage in an increasingly dynamic marketplace."

Chaining Workflows (Other Method)

There is another way to chain workflow together, using the add_workflow_step() function.


# you start from the first workflow here
myflow_chained <-
  myflow_positive |>
  add_workflow_step(myflow_more_details)
  

And the result should be very similar to the previous example:


# you start from the combined workflow here
myflow_chained |> 
  # you bring your prompt here
  process_prompts(prompts_vector = company_report) |>
  pull_final_answer()
#> → Frequency Penalty was not specified and given a default value of 1.
#> → Presence Penalty was not specified and given a default value of 1.5.
#> → Repeat Penalty was not specified and given a default value of 1.2.
#> → Mode was not specified and 'chat' was selected by default.
#> → System Prompt was not specified and given a default value of 'You are a helpful AI assistant.'.
#> → Chat mode
#> → Frequency Penalty was not specified and given a default value of 1.
#> → Presence Penalty was not specified and given a default value of 1.5.
#> → Repeat Penalty was not specified and given a default value of 1.2.
#> → Mode was not specified and 'chat' was selected by default.
#> → System Prompt was not specified and given a default value of 'You are a helpful AI assistant.'.
#> → Chat mode
#> [[1]]
#> [1] "Despite initial setbacks, we're taking a proactive approach to address our Q2 quarter challenges. Our leading product, CLEAN-Z, has experienced an opportunity for growth as it faces increased competition in the market from rival brands that have been aggressively expanding their portfolios of eco-friendly cleaning solutions. While this shift presents some short-term difficulties, such as managing inventory levels and meeting sales targets - particularly with regards to maintaining our competitive pricing strategy while also investing in new marketing campaigns to reach a wider audience - it also opens doors for strategic re-evaluation of our offerings.\n\nThe Product development team's recent misstep serves as a valuable learning experience that will inform their approach to future product launches, including more rigorous testing and quality control measures. This is particularly important given the growing demand from environmentally conscious consumers who are willing to pay a premium for products with proven efficacy in reducing waste and promoting sustainability. With a revised timeline now in place, we're confident that our new CLEAN-Z formula will hit the market with renewed excitement - featuring enhanced performance characteristics such as improved stain resistance and longer-lasting fragrances.\n\nWe anticipate significant growth for the remainder of the year, driven by both existing customers who have come to trust our brand's commitment to innovation and customer satisfaction. Additionally, we expect a boost in new business from retailers looking to capitalize on emerging trends in eco-friendly cleaning solutions. As we move forward with this revised plan, we remain committed to delivering exceptional value to our shareholders while also staying true to the core values that have driven our success since inception: quality, innovation, and customer satisfaction.\n\nThe Product development team's renewed focus on R&D is expected to yield a pipeline of new products in the coming months - including potential spin-offs from CLEAN-Z technology. This will not only help us stay ahead of competitors but also provide opportunities for growth through strategic partnerships with key industry players. With our revised strategy firmly in place, we're confident that we'll emerge stronger and more resilient than ever, poised to capitalize on emerging trends and drive long-term success for the company."

The only key difference is that you have no way to observe the intermediate results when you do this.

But it makes it easier to add more steps into a single workflow:


myflow_translate_to_spanish <- ai_workflow() |>
  set_connector(connector = "ollama") |>
  set_model(model_name = "llama3.2:latest") |>
  set_processing_skill(processing_skill = "translate",target_language="spanish") |>
  set_n_predict(2000) |>
  set_temperature(0.5)
#> → Default IP address has been set to 127.0.0.1.
#> → Default port has been set to 11434.

myflow_chained <-
  myflow_positive |>
  add_workflow_step(myflow_more_details) |>
  add_workflow_step(myflow_translate_to_spanish)

And now you should be able to get in one go, the final text translated in Spanish this way.


# you start from the combined workflow here
myflow_chained |> 
  # you bring your prompt here
  process_prompts(prompts_vector = company_report) |>
  pull_final_answer()
#> → Frequency Penalty was not specified and given a default value of 1.
#> → Presence Penalty was not specified and given a default value of 1.5.
#> → Repeat Penalty was not specified and given a default value of 1.2.
#> → Mode was not specified and 'chat' was selected by default.
#> → System Prompt was not specified and given a default value of 'You are a helpful AI assistant.'.
#> → Chat mode
#> → Frequency Penalty was not specified and given a default value of 1.
#> → Presence Penalty was not specified and given a default value of 1.5.
#> → Repeat Penalty was not specified and given a default value of 1.2.
#> → Mode was not specified and 'chat' was selected by default.
#> → System Prompt was not specified and given a default value of 'You are a helpful AI assistant.'.
#> → Chat mode
#> → Frequency Penalty was not specified and given a default value of 1.
#> → Presence Penalty was not specified and given a default value of 1.5.
#> → Repeat Penalty was not specified and given a default value of 1.2.
#> → Mode was not specified and 'chat' was selected by default.
#> → System Prompt was not specified and given a default value of 'You are a helpful AI assistant.'.
#> → Chat mode
#> → Applying additional variables to working env
#> [[1]]
#> [1] "===\nEl cuarto del año II presentó una oportunidad para el crecimiento y la mejora, ya que nuestro producto líder CLEAN-Z experimentó un lento descenso en su participación de mercado debido a la competencia aumentada por marcas emergentes en el segmento de productos limpiadores premium.\nEstas nuevas entrantes han logrado con éxito aprovechar las plataformas de redes sociales para conectarse con consumidores conscientes del medio ambiente, quienes están impulsando la demanda de alternativas amigables con el medio ambiente como CLEAN-Z.\n\nEste breve contratiempo nos ha motivado a reevaluar nuestra estrategia de ventas y explorar soluciones innovadoras para aumentar la demanda por parte de nuestros clientes.\nAhora estamos enfocándonos en campañas publicitarias dirigidas que resaltan los beneficios únicos del formula de CLEAN-Z basada en plantas, como su embalaje biodegradable y huella de carbono reducida.\nAdemás, aumentaremos nuestra presencia en línea a través de capacidades comerciales electrónicas mejoradas y acuerdos estratégicos con influencers benéficos para la salud.\n\nMientras tanto, nuestro equipo de desarrollo de productos está trabajando incansablemente para llevar al mercado el nuevo formula altamente esperado codificado como \"CLEAN-Z 2.0\".\nEste producto innovador presenta tecnología nanotecnológica que mejora la eficiencia limpia mientras minimiza su impacto ambiental.\nCon su lanzamiento previsto en los próximos 2-3 meses, CLEAN-Z 2.0 promete consolidar aún más nuestra marca como líder en el segmentio de productos limpiadores premium.\n\nCon este nuevo impulso, estamos preparados para un fuerte segundo semestre del año, impulsado por la mayor interés consumista en los beneficios únicos y características de CLEAN-Z.\nAnticipamos crecimiento significativo a través de todos nuestros canales de ventas, incluyendo retail electrónico, tiendas físicas y nuestro modelo directo al cliente.\nAl entrar en el resto del Q2 y más allá, estamos confiados que nuestras ajustes estratégicos producirán un gran retorno sobre la inversión y impulsarán éxito a largo plazo para CLEAN-Z."

Note that the quality of the Spanish translation in this case will depend heavily on how well the model you have selected can handle this kind of tasks. Not all models are equal when it comes to multilingual capabilities.