-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from raffertyuy/main
New sk-python-azure-functions-chatgpt-plugin and other minor updates
- Loading branch information
Showing
27 changed files
with
698 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Net; | ||
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.Azure.Functions.Worker.Http; | ||
|
||
public class Logo | ||
{ | ||
[Function("GetLogo")] | ||
public HttpResponseData Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "logo.png")] HttpRequestData req) | ||
{ | ||
// Return logo.png that's in the root of the project | ||
var response = req.CreateResponse(HttpStatusCode.OK); | ||
response.Headers.Add("Content-Type", "image/png"); | ||
|
||
var logo = System.IO.File.ReadAllBytes("logo.png"); | ||
response.Body.Write(logo); | ||
|
||
return response; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
OPENAI_API_KEY="" | ||
OPENAI_ORG_ID="" | ||
AZURE_OPENAI_DEPLOYMENT_NAME="" | ||
AZURE_OPENAI_ENDPOINT="" | ||
AZURE_OPENAI_API_KEY="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.git* | ||
.vscode | ||
__azurite_db*__.json | ||
__blobstorage__ | ||
__queuestorage__ | ||
local.settings.json | ||
test | ||
.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don’t work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# Azure Functions artifacts | ||
bin | ||
obj | ||
appsettings.json | ||
|
||
# Azurite artifacts | ||
__blobstorage__ | ||
__queuestorage__ | ||
__azurite_db*__.json | ||
.python_packages |
8 changes: 8 additions & 0 deletions
8
sk-python-azure-functions-chatgpt-plugin/.vscode/extensions.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"recommendations": [ | ||
"ms-azuretools.vscode-azurefunctions", | ||
"ms-python.python", | ||
"azurite.azurite", | ||
"ms-semantic-kernel.semantic-kernel", | ||
] | ||
} |
12 changes: 12 additions & 0 deletions
12
sk-python-azure-functions-chatgpt-plugin/.vscode/launch.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Attach to Python Functions", | ||
"type": "python", | ||
"request": "attach", | ||
"port": 9091, | ||
"preLaunchTask": "func: host start" | ||
} | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
sk-python-azure-functions-chatgpt-plugin/.vscode/settings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"azureFunctions.deploySubpath": ".", | ||
"azureFunctions.scmDoBuildDuringDeployment": true, | ||
"azureFunctions.pythonVenv": ".venv", | ||
"azureFunctions.projectLanguage": "Python", | ||
"azureFunctions.projectRuntime": "~4", | ||
"debug.internalConsoleOptions": "neverOpen", | ||
"azureFunctions.projectLanguageModel": 2 | ||
} |
37 changes: 37 additions & 0 deletions
37
sk-python-azure-functions-chatgpt-plugin/.vscode/tasks.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "func", | ||
"label": "func: host start", | ||
"command": "host start", | ||
"problemMatcher": "$func-python-watch", | ||
"isBackground": true, | ||
"dependsOn": "pip install (functions)" | ||
}, | ||
{ | ||
"label": "create venv", | ||
"type": "shell", | ||
"command": "python -m venv .venv || echo 0", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
}, | ||
{ | ||
"label": "pip install (functions)", | ||
"type": "shell", | ||
"osx": { | ||
"command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt" | ||
}, | ||
"windows": { | ||
"command": "${config:azureFunctions.pythonVenv}\\Scripts\\python -m pip install -r requirements.txt" | ||
}, | ||
"linux": { | ||
"command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt" | ||
}, | ||
"problemMatcher": [], | ||
"dependsOn": "create venv" | ||
} | ||
] | ||
} |
17 changes: 17 additions & 0 deletions
17
sk-python-azure-functions-chatgpt-plugin/.well-known/ai-plugin.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"schema_version": "v1", | ||
"name_for_human": "Fun Plugin", | ||
"name_for_model": "FunPlugin", | ||
"description_for_human": "Execute fun skills such as jokes, excuses and limericks.", | ||
"description_for_model": "A plugin for using semantic kernel fun skills.", | ||
"auth": { | ||
"type": "none" | ||
}, | ||
"api": { | ||
"type": "openapi", | ||
"url": "http://localhost:7071/openapi.yaml" | ||
}, | ||
"logo_url": "http://localhost:7071/logo.png", | ||
"contact_email": "legal@example.com", | ||
"legal_info_url": "http://example.com/legal" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Semantic Kernel Python Azure Functions Starter | ||
|
||
The `sk-python-azure-functions` application demonstrates how to execute a semantic function within an Azure Function. | ||
|
||
## Prerequisites | ||
|
||
- [Python](https://www.python.org/downloads/) >=3.8 and <3.11 | ||
- [Azure Functions](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions) | ||
- [Azurite](https://marketplace.visualstudio.com/items?itemName=Azurite.azurite). Run the services from the VS Code status bar. | ||
- [Semantic Kernel Tools](https://marketplace.visualstudio.com/items?itemName=ms-semantic-kernel.semantic-kernel) | ||
|
||
## Configuring the starter | ||
|
||
The starter can be configured with a `.env` file in the project which holds api keys and other secrets and configurations. | ||
|
||
Make sure you have an | ||
[Open AI API Key](https://openai.com/api/) or | ||
[Azure Open AI service key](https://learn.microsoft.com/azure/cognitive-services/openai/quickstart?pivots=rest-api) | ||
|
||
Copy the `.env.example` file to a new file named `.env`. Then, copy those keys into the `.env` file: | ||
|
||
``` | ||
OPENAI_API_KEY="" | ||
OPENAI_ORG_ID="" | ||
AZURE_OPENAI_DEPLOYMENT_NAME="" | ||
AZURE_OPENAI_ENDPOINT="" | ||
AZURE_OPENAI_API_KEY="" | ||
``` | ||
|
||
## Running the starter | ||
|
||
To run the console application within Visual Studio Code, run Azurite from the status bar or command pallette, then just hit `F5`. | ||
As configured in `launch.json` and `tasks.json`, Visual Studio Code will create a virtual environment at `.venv` and run `pip install requirements.txt`. | ||
|
||
To run from command line, run the following: | ||
|
||
``` | ||
python -m venv .venv | ||
.venv\Scripts\python -m pip install -r requirements.txt # Location of python within venv depends on OS | ||
.venv\Scripts\activate | ||
func host start | ||
``` | ||
|
||
## Using the starter | ||
|
||
In your browser, visit `http://localhost:7071/api/skills/{skill_name/functions/{function_name}` to execute a skill. | ||
For example, `http://localhost:7071/api/skills/FunSkill/functions/Joke` will execute the example Joke function in the FunSkill skill. | ||
|
||
To provide input, send a POST request with a JSON body, e.g. provide this as input to the Joke function: | ||
`{"input": "time traveling to dinosaur age", "style": "deadpan"}` |
Oops, something went wrong.