Skip to content

Commit b2ac98b

Browse files
committed
new sk-python-azure-functions-chatgpt-plugin starter
1 parent 14f4f4f commit b2ac98b

23 files changed

+667
-0
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ Alternatively, you can use the [Semantic Kernel Tools](https://marketplace.visua
1414
- [C# Hello World](sk-csharp-hello-world): The Hello World C# console application starter for the Semantic Kernel.
1515
- [C# Console Chat](sk-csharp-console-chat): A console application based chat starter for the Semantic Kernel.
1616
- [C# Azure Functions](sk-csharp-azure-functions): The Hello World C# Azure Functions starter for the Semantic Kernel.
17+
- [C# Azure ChatGPT Plugin](sk-csharp-chatgpt-plugin): The Joke ChatGPT Plugin starter using C# Azure Functions for the Semantic Kernel.
1718
- [Python Hello World](sk-python-hello-world): The Hello World Python console application starter for the Semantic Kernel.
1819
- [Python Azure Functions](sk-python-azure-functions): The Hello World Python Azure Functions starter for the Semantic Kernel.
20+
- [Python Azure Functions ChatGPT Plugin](sk-python-azure-functions-chatgpt-plugin): The Joke ChatGPT Plugin starter using Python Azure Functions for the Semantic Kernel.
21+
- [Python Flask ChatGPT Plugin](sk-python-flask-chatgpt-plugin): The Joke ChatGPT Plugin starter using Python Flask for the Semantic Kernel.
1922
- [Typescript Console Chat](sk-typescript-console-chat): A console application based chat starter for the Semantic Kernel.
2023

2124
## Contributing
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
OPENAI_API_KEY=""
2+
OPENAI_ORG_ID=""
3+
AZURE_OPENAI_DEPLOYMENT_NAME=""
4+
AZURE_OPENAI_ENDPOINT=""
5+
AZURE_OPENAI_API_KEY=""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.git*
2+
.vscode
3+
__azurite_db*__.json
4+
__blobstorage__
5+
__queuestorage__
6+
local.settings.json
7+
test
8+
.venv
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
.hypothesis/
51+
.pytest_cache/
52+
53+
# Translations
54+
*.mo
55+
*.pot
56+
57+
# Django stuff:
58+
*.log
59+
local_settings.py
60+
db.sqlite3
61+
62+
# Flask stuff:
63+
instance/
64+
.webassets-cache
65+
66+
# Scrapy stuff:
67+
.scrapy
68+
69+
# Sphinx documentation
70+
docs/_build/
71+
72+
# PyBuilder
73+
target/
74+
75+
# Jupyter Notebook
76+
.ipynb_checkpoints
77+
78+
# IPython
79+
profile_default/
80+
ipython_config.py
81+
82+
# pyenv
83+
.python-version
84+
85+
# pipenv
86+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
87+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
88+
# having no cross-platform support, pipenv may install dependencies that don’t work, or not
89+
# install all needed dependencies.
90+
#Pipfile.lock
91+
92+
# celery beat schedule file
93+
celerybeat-schedule
94+
95+
# SageMath parsed files
96+
*.sage.py
97+
98+
# Environments
99+
.env
100+
.venv
101+
env/
102+
venv/
103+
ENV/
104+
env.bak/
105+
venv.bak/
106+
107+
# Spyder project settings
108+
.spyderproject
109+
.spyproject
110+
111+
# Rope project settings
112+
.ropeproject
113+
114+
# mkdocs documentation
115+
/site
116+
117+
# mypy
118+
.mypy_cache/
119+
.dmypy.json
120+
dmypy.json
121+
122+
# Pyre type checker
123+
.pyre/
124+
125+
# Azure Functions artifacts
126+
bin
127+
obj
128+
appsettings.json
129+
130+
# Azurite artifacts
131+
__blobstorage__
132+
__queuestorage__
133+
__azurite_db*__.json
134+
.python_packages
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"ms-azuretools.vscode-azurefunctions",
4+
"ms-python.python",
5+
"azurite.azurite",
6+
"ms-semantic-kernel.semantic-kernel",
7+
]
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Attach to Python Functions",
6+
"type": "python",
7+
"request": "attach",
8+
"port": 9091,
9+
"preLaunchTask": "func: host start"
10+
}
11+
]
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"azureFunctions.deploySubpath": ".",
3+
"azureFunctions.scmDoBuildDuringDeployment": true,
4+
"azureFunctions.pythonVenv": ".venv",
5+
"azureFunctions.projectLanguage": "Python",
6+
"azureFunctions.projectRuntime": "~4",
7+
"debug.internalConsoleOptions": "neverOpen",
8+
"azureFunctions.projectLanguageModel": 2
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "func",
6+
"label": "func: host start",
7+
"command": "host start",
8+
"problemMatcher": "$func-python-watch",
9+
"isBackground": true,
10+
"dependsOn": "pip install (functions)"
11+
},
12+
{
13+
"label": "create venv",
14+
"type": "shell",
15+
"command": "python -m venv .venv || echo 0",
16+
"group": {
17+
"kind": "build",
18+
"isDefault": true
19+
}
20+
},
21+
{
22+
"label": "pip install (functions)",
23+
"type": "shell",
24+
"osx": {
25+
"command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
26+
},
27+
"windows": {
28+
"command": "${config:azureFunctions.pythonVenv}\\Scripts\\python -m pip install -r requirements.txt"
29+
},
30+
"linux": {
31+
"command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
32+
},
33+
"problemMatcher": [],
34+
"dependsOn": "create venv"
35+
}
36+
]
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"schema_version": "v1",
3+
"name_for_human": "Fun Plugin",
4+
"name_for_model": "FunPlugin",
5+
"description_for_human": "Execute fun skills such as jokes, excuses and limericks.",
6+
"description_for_model": "A plugin for using semantic kernel fun skills.",
7+
"auth": {
8+
"type": "none"
9+
},
10+
"api": {
11+
"type": "openapi",
12+
"url": "http://localhost:7071/openapi.yaml"
13+
},
14+
"logo_url": "http://localhost:7071/logo.png",
15+
"contact_email": "[email protected]",
16+
"legal_info_url": "http://example.com/legal"
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Semantic Kernel Python Azure Functions Starter
2+
3+
The `sk-python-azure-functions` application demonstrates how to execute a semantic function within an Azure Function.
4+
5+
## Prerequisites
6+
7+
- [Python](https://www.python.org/downloads/) >=3.8 and <3.11
8+
- [Azure Functions](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions)
9+
- [Azurite](https://marketplace.visualstudio.com/items?itemName=Azurite.azurite). Run the services from the VS Code status bar.
10+
- [Semantic Kernel Tools](https://marketplace.visualstudio.com/items?itemName=ms-semantic-kernel.semantic-kernel)
11+
12+
## Configuring the starter
13+
14+
The starter can be configured with a `.env` file in the project which holds api keys and other secrets and configurations.
15+
16+
Make sure you have an
17+
[Open AI API Key](https://openai.com/api/) or
18+
[Azure Open AI service key](https://learn.microsoft.com/azure/cognitive-services/openai/quickstart?pivots=rest-api)
19+
20+
Copy the `.env.example` file to a new file named `.env`. Then, copy those keys into the `.env` file:
21+
22+
```
23+
OPENAI_API_KEY=""
24+
OPENAI_ORG_ID=""
25+
AZURE_OPENAI_DEPLOYMENT_NAME=""
26+
AZURE_OPENAI_ENDPOINT=""
27+
AZURE_OPENAI_API_KEY=""
28+
```
29+
30+
## Running the starter
31+
32+
To run the console application within Visual Studio Code, run Azurite from the status bar or command pallette, then just hit `F5`.
33+
As configured in `launch.json` and `tasks.json`, Visual Studio Code will create a virtual environment at `.venv` and run `pip install requirements.txt`.
34+
35+
To run from command line, run the following:
36+
37+
```
38+
python -m venv .venv
39+
.venv\Scripts\python -m pip install -r requirements.txt # Location of python within venv depends on OS
40+
.venv\Scripts\activate
41+
func host start
42+
```
43+
44+
## Using the starter
45+
46+
In your browser, visit `http://localhost:7071/api/skills/{skill_name/functions/{function_name}` to execute a skill.
47+
For example, `http://localhost:7071/api/skills/FunSkill/functions/Joke` will execute the example Joke function in the FunSkill skill.
48+
49+
To provide input, send a POST request with a JSON body, e.g. provide this as input to the Joke function:
50+
`{"input": "time traveling to dinosaur age", "style": "deadpan"}`

0 commit comments

Comments
 (0)