Business Plugins

Enhance Semantic Kernel

Jan Kirenz

Business Plugins

Setup

Python

import semantic_kernel as sk
from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion, OpenAIChatCompletion
from IPython.display import display, Markdown

Kernel

kernel = sk.Kernel()

api_key, org_id = sk.openai_settings_from_dot_env()

kernel.add_text_completion_service(
    "openai", OpenAIChatCompletion("gpt-3.5-turbo", api_key, org_id))

Business Plugins

Business goals

  1. Grow the existing business
  2. Save money and time
  3. Add completely new business
  4. Prepare for the unknown

Plugins directory

plugins-sk/

└─── BusinessThinking/
     |
     └─── BasicStrategies/
     |    └─── config.json
     |    └─── skprompt.txt
     |
     └─── SeekCostEfficiency/
     |    └─── config.json
     |    └─── skprompt.txt
     |
     └─── SeekTimeEfficiency/
          └─── config.json
          └─── skprompt.txt

Activate plugins

pluginsDirectory = "../plugins-sk"

pluginBT = kernel.import_semantic_skill_from_directory(
    pluginsDirectory, "BusinessThinking")

Cost Efficiency

Input strengths and weaknesses

strengths = ["Unique garlic pizza recipe that wins top awards", "Owner trained in Sicily at some of the best pizzerias",
             "Strong local reputation", "Prime location on university campus"]

weaknesses = ["High staff turnover", "Floods in the area damaged the seating areas that are in need of repair",
              "Absence of popular calzones from menu", "Negative reviews from younger demographic for lack of hip ingredients"]

Context

my_context = kernel.create_new_context()

my_context['input'] = 'makes pizzas'
my_context['strengths'] = ", ".join(strengths)
my_context['weaknesses'] = ", ".join(weaknesses)

Run kernel with cost efficiency plugin

costefficiency_result = await kernel.run_async(pluginBT["SeekCostEfficiency"], input_context=my_context)

Output

costefficiency_str = str(
    "### ✨ Suggestions for how to gain cost efficiencies\n" + str(costefficiency_result))
display(Markdown(costefficiency_str))

Business Strategy

Input opportunities and threats

opportunities = ["Untapped catering potential", "Growing local tech startup community",
                 "Unexplored online presence and order capabilities", "Upcoming annual food fair"]

threats = ["Competition from cheaper pizza businesses nearby", "There's nearby street construction that will impact foot traffic",
           "Rising cost of cheese will increase the cost of pizzas", "No immediate local regulatory changes but it's election season"]

Import plugin

pluginBT = kernel.import_semantic_skill_from_directory(
    pluginsDirectory, "BusinessThinking")

Context

my_context = kernel.create_new_context()

my_context['input'] = 'makes pizzas'
my_context['strengths'] = ", ".join(strengths)
my_context['weaknesses'] = ", ".join(weaknesses)
my_context['opportunities'] = ", ".join(opportunities)
my_context['threats'] = ", ".join(threats)

Run kernel

bizstrat_result = await kernel.run_async(pluginBT["BasicStrategies"], input_context=my_context)

Output

bizstrat_str = "## ✨ Business strategy thinking based on SWOT analysis\n" + \
    str(bizstrat_result)
display(Markdown(bizstrat_str))

✨ Business strategy thinking based on SWOT analysis

Title Strength Weakness Description
Streamlining operations Strong local reputation High staff turnover Implementing efficient processes and systems to reduce the need for excessive staff and improve productivity. This can include automating certain tasks, cross-training employees, and optimizing workflow.
Renovating seating areas Prime location on university campus Floods damaging seating areas Investing in repairing and renovating the seating areas to attract more customers and enhance the dining experience. This can include redesigning the layout, upgrading furniture and fixtures, and creating a comfortable and inviting ambiance.
Adding popular calzones to the menu Unique garlic pizza recipe that wins top awards Absence of popular calzones from menu Expanding the menu to include popular calzones can attract a wider customer base and increase sales. This can be achieved by developing delicious and unique calzone recipes that align with the business’s culinary expertise and reputation.

Acknowledgments

This tutorial is mainly based on the excellent course “How Business Thinkers Can Start Building AI Plugins With Semantic Kernel” provided by John Maeda and Andrew Ng

What’s next?

Congratulations! You have completed this tutorial 👍

Next, you may want to go back to the lab’s website