Skip to content

Commit

Permalink
Python: Move notebooks into language folders (microsoft#2368)
Browse files Browse the repository at this point in the history
### Motivation and Context
In an effort to move all samples to their respective language folder,
I've moved all of the notebooks to the correct language folder.


### Contribution Checklist

- [ ] The code builds clean without any errors or warnings
- [ ] 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
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
  • Loading branch information
matthewbolanos authored Aug 9, 2023
1 parent 3ce874b commit 54ee340
Show file tree
Hide file tree
Showing 39 changed files with 57 additions and 57 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ Getting Semantic Kernel deployed to Azure as web app service is easy with one-cl
For a more hands-on overview, you can also check out the C# and Python Jupyter notebooks, starting
from here:

- [Getting Started with C# notebook](samples/notebooks/dotnet/00-getting-started.ipynb)
- [Getting Started with Python notebook](samples/notebooks/python/00-getting-started.ipynb)
- [Getting Started with C# notebook](dotnet/notebooks/00-getting-started.ipynb)
- [Getting Started with Python notebook](python/notebooks/00-getting-started.ipynb)

**Requirements:** C# notebooks require [.NET 7](https://dotnet.microsoft.com/download)
and the VS Code [Polyglot extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.dotnet-interactive-vscode).
Expand Down
32 changes: 16 additions & 16 deletions dotnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,18 @@ Console.WriteLine(output);
The repository contains also a few C# Jupyter notebooks that demonstrates
how to get started with the Semantic Kernel.

See [here](../samples/notebooks/dotnet/README.md) for the full list, with
See [here](./notebooks/README.md) for the full list, with
requirements and setup instructions.

1. [Getting started](../samples/notebooks//dotnet/00-getting-started.ipynb)
2. [Loading and configuring Semantic Kernel](../samples/notebooks//dotnet/01-basic-loading-the-kernel.ipynb)
3. [Running AI prompts from file](../samples/notebooks//dotnet/02-running-prompts-from-file.ipynb)
4. [Creating Semantic Functions at runtime (i.e. inline functions)](../samples/notebooks//dotnet/03-semantic-function-inline.ipynb)
5. [Using Context Variables to Build a Chat Experience](../samples/notebooks//dotnet/04-context-variables-chat.ipynb)
6. [Creating and Executing Plans](../samples/notebooks//dotnet/05-using-the-planner.ipynb)
7. [Building Memory with Embeddings](../samples/notebooks//dotnet/06-memory-and-embeddings.ipynb)
8. [Creating images with DALL-E 2](../samples/notebooks//dotnet/07-DALL-E-2.ipynb)
9. [Chatting with ChatGPT and Images](../samples/notebooks//dotnet/08-chatGPT-with-DALL-E-2.ipynb)
1. [Getting started](./notebooks/00-getting-started.ipynb)
2. [Loading and configuring Semantic Kernel](./notebooks/01-basic-loading-the-kernel.ipynb)
3. [Running AI prompts from file](./notebooks/02-running-prompts-from-file.ipynb)
4. [Creating Semantic Functions at runtime (i.e. inline functions)](./notebooks/03-semantic-function-inline.ipynb)
5. [Using Context Variables to Build a Chat Experience](./notebooks/04-context-variables-chat.ipynb)
6. [Creating and Executing Plans](./notebooks/05-using-the-planner.ipynb)
7. [Building Memory with Embeddings](./notebooks/06-memory-and-embeddings.ipynb)
8. [Creating images with DALL-E 2](./notebooks/07-DALL-E-2.ipynb)
9. [Chatting with ChatGPT and Images](./notebooks/08-chatGPT-with-DALL-E-2.ipynb)

# Nuget packages

Expand All @@ -121,20 +121,20 @@ more features, such as connectors to services and Skills to perform specific act
Unless you need to optimize which packages to include in your app, you will usually
start by installing this meta-package first:

* **Microsoft.SemanticKernel**
- **Microsoft.SemanticKernel**

This meta package includes core packages and OpenAI connectors, allowing to run
most samples and build apps with OpenAI and Azure OpenAI.

Packages included in **Microsoft.SemanticKernel**:

1. **Microsoft.SemanticKernel.Abstractions**: contains common interfaces and classes
used by the core and other SK components.
used by the core and other SK components.
1. **Microsoft.SemanticKernel.Core**: contains the core logic of SK, such as prompt
engineering, semantic memory and semantic functions definition and orchestration.
engineering, semantic memory and semantic functions definition and orchestration.
1. **Microsoft.SemanticKernel.Connectors.AI.OpenAI**: connectors to OpenAI and Azure
OpenAI, allowing to run semantic functions, chats, image generation with GPT3,
GPT3.5, GPT4, DALL-E2. Includes also GPT tokenizers.
OpenAI, allowing to run semantic functions, chats, image generation with GPT3,
GPT3.5, GPT4, DALL-E2. Includes also GPT tokenizers.

Other SK packages available at nuget.org:

Expand All @@ -148,4 +148,4 @@ Other SK packages available at nuget.org:
tenant data, schedule meetings, send emails, etc.
5. **Microsoft.SemanticKernel.Skills.OpenAPI**: OpenAPI skill.
6. **Microsoft.SemanticKernel.Skills.Web**: Web Skill: search the web, download
files, etc.
files, etc.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"outputs": [],
"source": [
"// Load the Skills Directory\n",
"var skillsDirectory = Path.Combine(System.IO.Directory.GetCurrentDirectory(), \"..\", \"..\", \"skills\");\n",
"var skillsDirectory = Path.Combine(System.IO.Directory.GetCurrentDirectory(), \"..\", \"..\", \"samples\", \"skills\");\n",
"\n",
"// Load the FunSkill from the Skills Directory\n",
"var funSkillFunctions = kernel.ImportSemanticSkillFromDirectory(skillsDirectory, \"FunSkill\");\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
Expand Down Expand Up @@ -118,7 +118,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
Expand All @@ -130,7 +130,7 @@
"outputs": [],
"source": [
"// note: using skills from the repo\n",
"var skillsDirectory = Path.Combine(System.IO.Directory.GetCurrentDirectory(), \"..\", \"..\", \"skills\");\n",
"var skillsDirectory = Path.Combine(System.IO.Directory.GetCurrentDirectory(), \"..\", \"..\", \"samples\", \"skills\");\n",
"\n",
"var funSkillFunctions = kernel.ImportSemanticSkillFromDirectory(skillsDirectory, \"FunSkill\");"
]
Expand All @@ -145,7 +145,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
},
"outputs": [],
"source": [
"var skillsDirectory = Path.Combine(System.IO.Directory.GetCurrentDirectory(), \"..\", \"..\", \"skills\");\n",
"var skillsDirectory = Path.Combine(System.IO.Directory.GetCurrentDirectory(), \"..\", \"..\", \"samples\", \"skills\");\n",
"kernel.ImportSemanticSkillFromDirectory(skillsDirectory, \"SummarizeSkill\");\n",
"kernel.ImportSemanticSkillFromDirectory(skillsDirectory, \"WriterSkill\");"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,9 @@
"{\n",
" [\"https://github.com/microsoft/semantic-kernel/blob/main/README.md\"]\n",
" = \"README: Installation, getting started, and how to contribute\",\n",
" [\"https://github.com/microsoft/semantic-kernel/blob/main/samples/notebooks/dotnet/02-running-prompts-from-file.ipynb\"]\n",
" [\"https://github.com/microsoft/semantic-kernel/blob/main/dotnet/notebooks/02-running-prompts-from-file.ipynb\"]\n",
" = \"Jupyter notebook describing how to pass prompts from a file to a semantic skill or function\",\n",
" [\"https://github.com/microsoft/semantic-kernel/blob/main/samples/notebooks/dotnet/00-getting-started.ipynb\"]\n",
" [\"https://github.com/microsoft/semantic-kernel/blob/main/dotnet/notebooks/00-getting-started.ipynb\"]\n",
" = \"Jupyter notebook describing how to get started with the Semantic Kernel\",\n",
" [\"https://github.com/microsoft/semantic-kernel/tree/main/samples/skills/ChatSkill/ChatGPT\"]\n",
" = \"Sample demonstrating how to create a chat skill interfacing with ChatGPT\",\n",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,9 @@
"{\n",
" [\"https://github.com/microsoft/semantic-kernel/blob/main/README.md\"]\n",
" = \"README: Installation, getting started, and how to contribute\",\n",
" [\"https://github.com/microsoft/semantic-kernel/blob/main/samples/notebooks/dotnet/02-running-prompts-from-file.ipynb\"]\n",
" [\"https://github.com/microsoft/semantic-kernel/blob/main/dotnet/notebooks/02-running-prompts-from-file.ipynb\"]\n",
" = \"Jupyter notebook describing how to pass prompts from a file to a semantic skill or function\",\n",
" [\"https://github.com/microsoft/semantic-kernel/blob/main/samples/notebooks/dotnet/00-getting-started.ipynb\"]\n",
" [\"https://github.com/microsoft/semantic-kernel/blob/main/dotnet/notebooks/00-getting-started.ipynb\"]\n",
" = \"Jupyter notebook describing how to get started with the Semantic Kernel\",\n",
" [\"https://github.com/microsoft/semantic-kernel/tree/main/samples/skills/ChatSkill/ChatGPT\"]\n",
" = \"Sample demonstrating how to create a chat skill interfacing with ChatGPT\",\n",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ private static Dictionary<string, string> SampleData()
{
["https://github.com/microsoft/semantic-kernel/blob/main/README.md"]
= "README: Installation, getting started, and how to contribute",
["https://github.com/microsoft/semantic-kernel/blob/main/samples/notebooks/dotnet/02-running-prompts-from-file.ipynb"]
["https://github.com/microsoft/semantic-kernel/blob/main/dotnet/notebooks/02-running-prompts-from-file.ipynb"]
= "Jupyter notebook describing how to pass prompts from a file to a semantic skill or function",
["https://github.com/microsoft/semantic-kernel/blob/main/samples/notebooks/dotnet/00-getting-started.ipynb"]
["https://github.com/microsoft/semantic-kernel/blob/main/dotnet/notebooks//00-getting-started.ipynb"]
= "Jupyter notebook describing how to get started with the Semantic Kernel",
["https://github.com/microsoft/semantic-kernel/tree/main/samples/skills/ChatSkill/ChatGPT"]
= "Sample demonstrating how to create a chat skill interfacing with ChatGPT",
Expand Down
13 changes: 7 additions & 6 deletions python/DEV_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ AZURE_OPENAI_API_KEY=""
We suggest adding a copy of the `.env` file under these folders:

- [python/tests](tests)
- [samples/notebooks/python](../samples/notebooks/python).
- [./notebooks](./notebooks).

# System setup

Expand Down Expand Up @@ -112,7 +112,9 @@ You can also run all the tests together under the [tests](tests/) folder.
# Tools and scripts

## Pydantic and Serialization

[Pydantic Documentation](https://docs.pydantic.dev/1.10/)

### Overview

This section describes how one can enable serialization for their class using Pydantic.
Expand Down Expand Up @@ -167,16 +169,16 @@ class B(ABC, PydanticField): ... # ERROR: Python cannot find a valid super class
class C(PydanticField): ... # No other changes needed
```

The classes B and C can now be used as valid Pydantic Field annotations.
The classes B and C can now be used as valid Pydantic Field annotations.

```python
````python
from pydantic import BaseModel

class MyModel(BaseModel):
b: B
c: C

Class A can only be used as a Pydantic Field annotation for a Pydantic BaseModel subclass
Class A can only be used as a Pydantic Field annotation for a Pydantic BaseModel subclass
which is configured to allow arbitrary field types like so:

```python
Expand All @@ -188,7 +190,7 @@ class CorrectModel(BaseModel):
a: A # Okay
class Config: # Configuration that tells Pydantic to allow field types that it can't serialize
arbitrary_types_allowed = True
```
````

#### Classes with data, but no Generic types that need to be serialized

Expand Down Expand Up @@ -256,7 +258,6 @@ class A(SKGenericModel, Generic[T1, T2]):
b: T1
c: T2
```


## Pipeline checks

Expand Down
25 changes: 12 additions & 13 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Install the latest package:

python -m pip install --upgrade semantic-kernel


# AI Services

## OpenAI / Azure OpenAI API keys
Expand Down Expand Up @@ -92,18 +91,18 @@ get started with the Semantic Kernel.

Python notebooks:

* [Getting started with Semantic Kernel](../samples/notebooks/python/00-getting-started.ipynb)
* [Loading and configuring Semantic Kernel](../samples/notebooks/python/01-basic-loading-the-kernel.ipynb)
* [Running AI prompts from file](../samples/notebooks/python/02-running-prompts-from-file.ipynb)
* [Creating Semantic Functions at runtime (i.e. inline functions)](../samples/notebooks/python/03-semantic-function-inline.ipynb)
* [Using Context Variables to Build a Chat Experience](../samples/notebooks/python/04-context-variables-chat.ipynb)
* [Introduction to planners](../samples/notebooks/python/05-using-the-planner.ipynb)
* [Building Memory with Embeddings](../samples/notebooks/python/06-memory-and-embeddings.ipynb)
* [Using Hugging Face for Skills](../samples/notebooks/python/07-hugging-face-for-skills.ipynb)
* [Combining native functions and semantic functions](../samples/notebooks/python/08-native-function-inline.ipynb)
* [Groundedness Checking with Semantic Kernel](../samples/notebooks/python/09-groundedness-checking.ipynb)
* [Returning multiple results per prompt](../samples/notebooks/python/10-multiple-results-per-prompt.ipynb)
* [Streaming completions with Semantic Kernel](../samples/notebooks/python/11-streaming-completions.ipynb)
- [Getting started with Semantic Kernel](./notebooks/00-getting-started.ipynb)
- [Loading and configuring Semantic Kernel](./notebooks/01-basic-loading-the-kernel.ipynb)
- [Running AI prompts from file](./notebooks/02-running-prompts-from-file.ipynb)
- [Creating Semantic Functions at runtime (i.e. inline functions)](./notebooks/03-semantic-function-inline.ipynb)
- [Using Context Variables to Build a Chat Experience](./notebooks/04-context-variables-chat.ipynb)
- [Introduction to planners](./notebooks/05-using-the-planner.ipynb)
- [Building Memory with Embeddings](./notebooks/06-memory-and-embeddings.ipynb)
- [Using Hugging Face for Skills](./notebooks/07-hugging-face-for-skills.ipynb)
- [Combining native functions and semantic functions](./notebooks/08-native-function-inline.ipynb)
- [Groundedness Checking with Semantic Kernel](./notebooks/09-groundedness-checking.ipynb)
- [Returning multiple results per prompt](./notebooks/10-multiple-results-per-prompt.ipynb)
- [Streaming completions with Semantic Kernel](./notebooks/11-streaming-completions.ipynb)

# SK Frequently Asked Questions

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"metadata": {},
"outputs": [],
"source": [
"skill = kernel.import_semantic_skill_from_directory(\"../../skills\", \"FunSkill\")\n",
"skill = kernel.import_semantic_skill_from_directory(\"../../samples/skills\", \"FunSkill\")\n",
"joke_function = skill[\"Joke\"]\n",
"\n",
"print(joke_function(\"time travel to dinosaur age\"))"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
"outputs": [],
"source": [
"# note: using skills from the samples folder\n",
"skills_directory = \"../../skills\"\n",
"skills_directory = \"../../samples/skills\"\n",
"\n",
"funFunctions = kernel.import_semantic_skill_from_directory(skills_directory, \"FunSkill\")\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"source": [
"from semantic_kernel.core_skills.text_skill import TextSkill\n",
"\n",
"skills_directory = \"../../skills/\"\n",
"skills_directory = \"../../samples/skills/\"\n",
"summarize_skill = kernel.import_semantic_skill_from_directory(skills_directory, \"SummarizeSkill\")\n",
"writer_skill = kernel.import_semantic_skill_from_directory(skills_directory, \"WriterSkill\")\n",
"text_skill = kernel.import_skill(TextSkill(), \"TextSkill\")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@
"github_files ={}\n",
"github_files[\"https://github.com/microsoft/semantic-kernel/blob/main/README.md\"] = \\\n",
" \"README: Installation, getting started, and how to contribute\"\n",
"github_files[\"https://github.com/microsoft/semantic-kernel/blob/main/samples/notebooks/dotnet/02-running-prompts-from-file.ipynb\"] = \\\n",
"github_files[\"https://github.com/microsoft/semantic-kernel/blob/main/dotnet/notebooks/02-running-prompts-from-file.ipynb\"] = \\\n",
" \"Jupyter notebook describing how to pass prompts from a file to a semantic skill or function\"\n",
"github_files[\"https://github.com/microsoft/semantic-kernel/blob/main/samples/notebooks/dotnet/00-getting-started.ipynb\"] = \\\n",
"github_files[\"https://github.com/microsoft/semantic-kernel/blob/main/dotnet/notebooks/00-getting-started.ipynb\"] = \\\n",
" \"Jupyter notebook describing how to get started with the Semantic Kernel\"\n",
"github_files[\"https://github.com/microsoft/semantic-kernel/tree/main/samples/skills/ChatSkill/ChatGPT\"] = \\\n",
" \"Sample demonstrating how to create a chat skill interfacing with ChatGPT\"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"from semantic_kernel.core_skills.text_skill import TextSkill\n",
"\n",
"# note: using skills from the samples folder\n",
"skills_directory = \"../../skills\"\n",
"skills_directory = \"../../samples/skills\"\n",
"\n",
"groundingSemanticFunctions = kernel.import_semantic_skill_from_directory(skills_directory, \"GroundingSkill\")"
]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -548,10 +548,10 @@
" \"https://github.com/microsoft/semantic-kernel/blob/main/README.md\"\n",
"] = \"README: Installation, getting started, and how to contribute\"\n",
"github_files[\n",
" \"https://github.com/microsoft/semantic-kernel/blob/main/samples/notebooks/dotnet/02-running-prompts-from-file.ipynb\"\n",
" \"https://github.com/microsoft/semantic-kernel/blob/main/dotnet/notebooks/02-running-prompts-from-file.ipynb\"\n",
"] = \"Jupyter notebook describing how to pass prompts from a file to a semantic skill or function\"\n",
"github_files[\n",
" \"https://github.com/microsoft/semantic-kernel/blob/main/samples/notebooks/dotnet/00-getting-started.ipynb\"\n",
" \"https://github.com/microsoft/semantic-kernel/blob/main/dotnet/notebooks/00-getting-started.ipynb\"\n",
"] = \"Jupyter notebook describing how to get started with the Semantic Kernel\"\n",
"github_files[\n",
" \"https://github.com/microsoft/semantic-kernel/tree/main/samples/skills/ChatSkill/ChatGPT\"\n",
Expand Down

0 comments on commit 54ee340

Please sign in to comment.