Skip to content

Commit 674af54

Browse files
authored
Python: Rename skills to plugins. Update prompt template config to use execution settings to align with dotnet. (microsoft#4595)
### Motivation and Context To better align with SK dotnet v1, Python skills have been renamed to plugins. This removes the root samples skills directory as dotnet supports the plugins and their configs. This the beginning of more work to consolidate other files/names, per the backlog. I've run several greps for files or file names containing "skill" (case insensitive), and no results appear. Do alert if you find anything else that includes "skill." Fixes microsoft#3319 <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description This is a large, breaking change PR as the replacement of "skills" to "plugins" affects many files. It was difficult to break this up into smaller chunks without leaving the SK Python repo in a bad state for some time. Other updates include: - Prompt template has been updated to use `execution_settings`, which aligns with dotnet, from the previous `completion` that Python used. - AzureOpenAI/OpenAI function calling has been updated to match the current versions of tools/tool_choice. Parsing messages in the open_ai utils respects this as it now looks for tool_calls and it configures the function_call with the id (new), name, and argument). - File renames, where the filename used to contain "skill" will look like new code, but it's the same code, just with "plugin" in the name. - Kernel examples and notebooks have been tested and are working. Unit tests and integration tests are passing. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 --------- Co-authored-by: Evan Mattson <[email protected]>
1 parent f357b45 commit 674af54

File tree

153 files changed

+2579
-2452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+2579
-2452
lines changed

python/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Python notebooks:
9898
- [Using Context Variables to Build a Chat Experience](./notebooks/04-context-variables-chat.ipynb)
9999
- [Introduction to planners](./notebooks/05-using-the-planner.ipynb)
100100
- [Building Memory with Embeddings](./notebooks/06-memory-and-embeddings.ipynb)
101-
- [Using Hugging Face for Skills](./notebooks/07-hugging-face-for-skills.ipynb)
101+
- [Using Hugging Face for Plugins](./notebooks/07-hugging-face-for-plugins.ipynb)
102102
- [Combining native functions and semantic functions](./notebooks/08-native-function-inline.ipynb)
103103
- [Groundedness Checking with Semantic Kernel](./notebooks/09-groundedness-checking.ipynb)
104104
- [Returning multiple results per prompt](./notebooks/10-multiple-results-per-prompt.ipynb)

python/notebooks/00-getting-started.ipynb

+7-5
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
"api_key, org_id = sk.openai_settings_from_dot_env()\n",
5959
"\n",
6060
"kernel.add_chat_service(\n",
61-
" \"chat-gpt\", OpenAIChatCompletion(ai_model_id=\"gpt-3.5-turbo-1106\", api_key=api_key, org_id=org_id)\n",
61+
" \"chat-gpt\",\n",
62+
" OpenAIChatCompletion(ai_model_id=\"gpt-3.5-turbo-1106\", api_key=api_key, org_id=org_id),\n",
6263
")"
6364
]
6465
},
@@ -91,7 +92,8 @@
9192
"deployment, api_key, endpoint = sk.azure_openai_settings_from_dot_env()\n",
9293
"\n",
9394
"kernel.add_chat_service(\n",
94-
" \"chat_completion\", AzureChatCompletion(deployment_name=deployment, endpoint=endpoint, api_key=api_key)\n",
95+
" \"chat_completion\",\n",
96+
" AzureChatCompletion(deployment_name=deployment, endpoint=endpoint, api_key=api_key),\n",
9597
")"
9698
]
9799
},
@@ -102,7 +104,7 @@
102104
"source": [
103105
"# Run a Semantic Function\n",
104106
"\n",
105-
"**Step 3**: Load a Skill and run a semantic function:"
107+
"**Step 3**: Load a Plugin and run a semantic function:"
106108
]
107109
},
108110
{
@@ -111,8 +113,8 @@
111113
"metadata": {},
112114
"outputs": [],
113115
"source": [
114-
"skill = kernel.import_semantic_skill_from_directory(\"../../samples/skills\", \"FunSkill\")\n",
115-
"joke_function = skill[\"Joke\"]\n",
116+
"plugin = kernel.import_semantic_plugin_from_directory(\"../../samples/plugins\", \"FunPlugin\")\n",
117+
"joke_function = plugin[\"Joke\"]\n",
116118
"\n",
117119
"print(joke_function(\"time travel to dinosaur age\"))"
118120
]

python/notebooks/02-running-prompts-from-file.ipynb

+13-18
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
"id": "692e361b",
77
"metadata": {},
88
"source": [
9-
"# How to run a semantic skills from file\n",
10-
"Now that you're familiar with Kernel basics, let's see how the kernel allows you to run Semantic Skills and Semantic Functions stored on disk. \n",
9+
"# How to run a semantic plugins from file\n",
10+
"Now that you're familiar with Kernel basics, let's see how the kernel allows you to run Semantic Plugins and Semantic Functions stored on disk. \n",
1111
"\n",
12-
"A Semantic Skill is a collection of Semantic Functions, where each function is defined with natural language that can be provided with a text file. \n",
12+
"A Semantic Plugin is a collection of Semantic Functions, where each function is defined with natural language that can be provided with a text file. \n",
1313
"\n",
1414
"Refer to our [glossary](https://github.com/microsoft/semantic-kernel/blob/main/docs/GLOSSARY.md) for an in-depth guide to the terms.\n",
1515
"\n",
1616
"The repository includes some examples under the [samples](https://github.com/microsoft/semantic-kernel/tree/main/samples) folder.\n",
1717
"\n",
18-
"For instance, [this](../../skills/FunSkill/Joke/skprompt.txt) is the **Joke function** part of the **FunSkill skill**:"
18+
"For instance, [this](../../plugins/FunPlugin/Joke/skprompt.txt) is the **Joke function** part of the **FunPlugin plugin**:"
1919
]
2020
},
2121
{
@@ -55,7 +55,7 @@
5555
"metadata": {},
5656
"source": [
5757
"\n",
58-
"In the same folder you'll notice a second [config.json](../../skills/FunSkill/Joke/config.json) file. The file is optional, and is used to set some parameters for large language models like Temperature, TopP, Stop Sequences, etc.\n",
58+
"In the same folder you'll notice a second [config.json](../../plugins/FunPlugin/Joke/config.json) file. The file is optional, and is used to set some parameters for large language models like Temperature, TopP, Stop Sequences, etc.\n",
5959
"\n",
6060
"```\n",
6161
"{\n",
@@ -128,7 +128,7 @@
128128
"id": "fd5ff1f4",
129129
"metadata": {},
130130
"source": [
131-
"Import the skill and all its functions:"
131+
"Import the plugin and all its functions:"
132132
]
133133
},
134134
{
@@ -138,10 +138,10 @@
138138
"metadata": {},
139139
"outputs": [],
140140
"source": [
141-
"# note: using skills from the samples folder\n",
142-
"skills_directory = \"../../samples/skills\"\n",
141+
"# note: using plugins from the samples folder\n",
142+
"plugins_directory = \"../../samples/plugins\"\n",
143143
"\n",
144-
"funFunctions = kernel.import_semantic_skill_from_directory(skills_directory, \"FunSkill\")\n",
144+
"funFunctions = kernel.import_semantic_plugin_from_directory(plugins_directory, \"FunPlugin\")\n",
145145
"\n",
146146
"jokeFunction = funFunctions[\"Joke\"]"
147147
]
@@ -152,7 +152,7 @@
152152
"id": "edd99fa0",
153153
"metadata": {},
154154
"source": [
155-
"How to use the skill functions, e.g. generate a joke about \"*time travel to dinosaur age*\":"
155+
"How to use the plugin functions, e.g. generate a joke about \"*time travel to dinosaur age*\":"
156156
]
157157
},
158158
{
@@ -162,13 +162,8 @@
162162
"metadata": {},
163163
"outputs": [],
164164
"source": [
165-
"result = jokeFunction(\"time travel to dinosaur age\")\n",
166-
"\n",
167-
"print(result)\n",
168-
"\n",
169-
"# You can also invoke functions asynchronously\n",
170-
"# result = await jokeFunction.invoke_async(\"time travel to dinosaur age\")\n",
171-
"# print(result)"
165+
"result = await jokeFunction.invoke_async(\"time travel to dinosaur age\")\n",
166+
"print(result)"
172167
]
173168
},
174169
{
@@ -177,7 +172,7 @@
177172
"id": "2281a1fc",
178173
"metadata": {},
179174
"source": [
180-
"Great, now that you know how to load a skill from disk, let's show how you can [create and run a semantic function inline.](./03-semantic-function-inline.ipynb)"
175+
"Great, now that you know how to load a plugin from disk, let's show how you can [create and run a semantic function inline.](./03-semantic-function-inline.ipynb)"
181176
]
182177
}
183178
],

python/notebooks/03-semantic-function-inline.ipynb

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
" kernel.add_text_completion_service(\"dv\", azure_text_service)\n",
8585
"else:\n",
8686
" api_key, org_id = sk.openai_settings_from_dot_env()\n",
87-
" oai_text_service = OpenAITextCompletion(ai_model_id=\"text-davinci-003\", api_key=api_key, org_id=org_id)\n",
87+
" oai_text_service = OpenAITextCompletion(ai_model_id=\"gpt-3.5-turbo-instruct\", api_key=api_key, org_id=org_id)\n",
8888
" kernel.add_text_completion_service(\"dv\", oai_text_service)"
8989
]
9090
},
@@ -170,7 +170,7 @@
170170
"id": "1c2c1262",
171171
"metadata": {},
172172
"source": [
173-
"# Using ChatCompletion for Semantic Skills"
173+
"# Using ChatCompletion for Semantic Plugins"
174174
]
175175
},
176176
{
@@ -179,7 +179,7 @@
179179
"id": "29b59b28",
180180
"metadata": {},
181181
"source": [
182-
"You can also use chat completion models (like `gpt-35-turbo` and `gpt4`) for creating skills. Normally you would have to tweak the API to accommodate for a system and user role, but SK abstracts that away for you by using `kernel.add_chat_service` and `AzureChatCompletion` or `OpenAIChatCompletion`"
182+
"You can also use chat completion models (like `gpt-35-turbo` and `gpt4`) for creating plugins. Normally you would have to tweak the API to accommodate for a system and user role, but SK abstracts that away for you by using `kernel.add_chat_service` and `AzureChatCompletion` or `OpenAIChatCompletion`"
183183
]
184184
},
185185
{
@@ -271,7 +271,7 @@
271271
"name": "python",
272272
"nbconvert_exporter": "python",
273273
"pygments_lexer": "ipython3",
274-
"version": "3.11.6"
274+
"version": "3.10.12"
275275
}
276276
},
277277
"nbformat": 4,

python/notebooks/04-context-variables-chat.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@
279279
"name": "python",
280280
"nbconvert_exporter": "python",
281281
"pygments_lexer": "ipython3",
282-
"version": "3.11.6"
282+
"version": "3.10.12"
283283
}
284284
},
285285
"nbformat": 4,

0 commit comments

Comments
 (0)