mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
Spell checking automation: * Add typos checker to PR flow using https://github.com/marketplace/actions/typos-action * Fix existing typos * Add config file, with exclusions and exceptions: `.github/_typos.toml` The checker can be run locally, e.g. * Install: `brew install typos-cli` * Install: `conda install typos` Run: `typos -c .github/_typos.toml`
6.9 KiB
6.9 KiB
In [ ]:
!python -m pip install semantic-kernel==0.2.7.dev0In [ ]:
import semantic_kernel as sk
from semantic_kernel.connectors.ai.open_ai import AzureTextCompletion, OpenAITextCompletion
kernel = sk.Kernel()
useAzureOpenAI = False
# Configure AI backend used by the kernel
if useAzureOpenAI:
deployment, api_key, endpoint = sk.azure_openai_settings_from_dot_env()
kernel.add_text_completion_service("dv", AzureTextCompletion(deployment, endpoint, api_key))
else:
api_key, org_id = sk.openai_settings_from_dot_env()
kernel.add_text_completion_service("dv", OpenAITextCompletion("text-davinci-003", api_key, org_id))In [ ]:
from semantic_kernel.planning.basic_planner import BasicPlanner
planner = BasicPlanner()In [ ]:
from semantic_kernel.core_skills.text_skill import TextSkill
skills_directory = "../../skills/"
summarize_skill = kernel.import_semantic_skill_from_directory(skills_directory, "SummarizeSkill")
writer_skill = kernel.import_semantic_skill_from_directory(skills_directory, "WriterSkill")
text_skill = kernel.import_skill(TextSkill(), "TextSkill")In [ ]:
ask = """
Tomorrow is Valentine's day. I need to come up with a few date ideas. She speaks French so write it in French.
Convert the text to uppercase"""
original_plan = await planner.create_plan_async(ask, kernel)In [ ]:
print(original_plan.generated_plan)In [ ]:
sk_prompt = """
{{$input}}
Rewrite the above in the style of Shakespeare.
"""
shakespeareFunction = kernel.create_semantic_function(sk_prompt, "shakespeare", "ShakespeareSkill",
max_tokens=2000, temperature=0.8)In [ ]:
ask = """
Tomorrow is Valentine's day. I need to come up with a few date ideas.
She likes Shakespeare so write using his style. She speaks French so write it in French.
Convert the text to uppercase."""
new_plan = await planner.create_plan_async(ask, kernel)In [ ]:
print(new_plan.generated_plan)In [ ]:
results = await planner.execute_plan_async(new_plan, kernel)In [ ]:
print(results)