Skip to content

Commit

Permalink
Merge branch 'CambioML:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
llauraa23 authored Dec 30, 2023
2 parents eb4878f + d8daa9e commit 5c9cb03
Show file tree
Hide file tree
Showing 63 changed files with 2,522 additions and 2,159 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Default codeowners/reviewers for all code changes
* @CambioML @goldmermaid
120 changes: 120 additions & 0 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI

on:
push:
tags:
- '*' # push to PyPI and TestPypi on tag pushes

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pykoi
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: >-
Sign the Python 🐍 distribution 📦 with Sigstore
and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs:
- build
runs-on: ubuntu-latest

environment:
name: testpypi
url: https://test.pypi.org/p/pykoi

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
10 changes: 2 additions & 8 deletions docker/pykoi-cpu-custom/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
##########################################################
# Creating an OpenAI model (requires an OpenAI API key) #
##########################################################
# enter openai api key here
api_key = "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"

# Creating an OpenAI model
model = pykoi.ModelFactory.create_model(
model_source="openai",
api_key=api_key)
model = pykoi.ModelFactory.create_model(model_source="openai")

#####################################
# Creating a chatbot with the model #
Expand All @@ -25,9 +21,7 @@
###########################################################
# Create the application
# app = pykoi.Application(debug=False, share=True)
app = pykoi.Application(
debug=False,
share=True)
app = pykoi.Application(debug=False, share=True)
app.add_component(chatbot)
app.add_component(dashboard)
app.run()
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@
""",
"class": "",
},
]
],
}
85 changes: 70 additions & 15 deletions example/chatbot/chatbot_in_jupyter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"id": "61b49dc2",
"metadata": {},
"outputs": [],
Expand All @@ -21,36 +21,74 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"id": "6a907bb3",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from pykoi import Application\n",
"from pykoi.chat import ModelFactory\n",
"from pykoi.chat import QuestionAnswerDatabase\n",
"from pykoi.component import Chatbot"
"from pykoi.component import Chatbot\n",
"from dotenv import load_dotenv\n",
"load_dotenv()"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"id": "15c2004b",
"metadata": {},
"outputs": [],
"source": [
"api_key = \"\"\n",
"\n",
"# Creating an OpenAI model\n",
"model = ModelFactory.create_model(model_source=\"openai\", api_key=api_key)"
"model = ModelFactory.create_model(model_source=\"openai\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Add `nest_asyncio` \n",
"Add `nest_asyncio` to avoid error. Since we're running another interface inside a Jupyter notebook where an asyncio event loop is already running, we'll encounter the error. (since The uvicorn.run() function uses asyncio.run(), which isn't compatible with a running event loop.)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0c07c943",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"import nest_asyncio\n",
"nest_asyncio.apply()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "0c07c943",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Table contents after creating table:\n",
"ID: 1, Question: Who is Sam altman, Answer: He is the president of YC, Vote Status: n/a, Timestamp: 2023-12-20 13:37:43.095750\n"
]
}
],
"source": [
"database = QuestionAnswerDatabase(debug=True)\n",
"chatbot = Chatbot(model=model, feedback=\"vote\")\n",
Expand All @@ -61,14 +99,31 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"id": "ae7bbef3",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO: Started server process [40457]\n",
"INFO: Waiting for application startup.\n",
"INFO: Application startup complete.\n",
"INFO: Uvicorn running on http://0.0.0.0:5000 (Press CTRL+C to quit)\n"
]
}
],
"source": [
"# import nest_asyncio\n",
"app.display()"
"app.run()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -87,7 +142,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.10.13"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 5c9cb03

Please sign in to comment.