diff --git a/.gitattributes b/.gitattributes index 5972d644..3c8ff1e0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,6 +3,7 @@ *.yml text eol=lf *.html text eol=lf *.py text eol=lf +*.ipynb linguist-language=Python *.toml text eol=lf .gitattributes text eol=lf .gitignore text eol=lf diff --git a/.github/workflows/ci-ghcr.yml b/.github/workflows/ci-ghcr.yml new file mode 100644 index 00000000..f747847d --- /dev/null +++ b/.github/workflows/ci-ghcr.yml @@ -0,0 +1,30 @@ +name: Python Github Container Registry Deploy +on: + push: + branches: [main] +permissions: + packages: write + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + push: true + tags: | + ghcr.io/microsoft/intelligence-toolkit:latest \ No newline at end of file diff --git a/DEVELOPING.md b/DEVELOPING.md index 2c5703ce..f37f5d0a 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -109,7 +109,7 @@ See the documentation and an example of how to run the code with your data to ob Download, install and then open docker app: https://www.docker.com/products/docker-desktop/ -WThen, open a terminal: +Then, open a terminal: Windows: Search and open the app `Windows Powershell` on Windows start menu Linux and Mac: Open `Terminal` @@ -122,16 +122,19 @@ Use `cd `+ the path to the folder. For example: `cd C:\Users\user01\projects\intelligence-toolkit` +Pull the latest built image: +` docker pull ghcr.io/microsoft/intelligence-toolkit:latest` + +or build it with your own code: + `docker build . -t intelligence-toolkit` -After building, run the docker container: +Once the pull/build ir fininshed, run the docker container: - via shell: `docker run -d -p 80:80 intelligence-toolkit --name intelligence-toolkit` -- via Docker GUI: - Open [localhost:80](http://localhost:80) ## Deploying diff --git a/Dockerfile b/Dockerfile index f036ff64..a545754c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # https://eng.ms/docs/more/containers-secure-supply-chain/approved-images FROM mcr.microsoft.com/oryx/python:3.11 +LABEL org.opencontainers.image.source https://github.com/microsoft/intelligence-toolkit RUN curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg && \ apt update -y && \ diff --git a/README.md b/README.md index b1deabf3..54f14c6b 100644 --- a/README.md +++ b/README.md @@ -162,6 +162,10 @@ Non-profit organizations can apply for an annual Azure credit grant of up to $3, # Find examples in the `example_notebooks` folder. +- To pull the latest docker image with the app interface, pull it with docker. + + docker pull ghcr.io/microsoft/intelligence-toolkit:latest + - To start developing, see [DEVELOPING.md](./DEVELOPING.md). - To learn about our contribution guidelines, see [CONTRIBUTING.md](./CONTRIBUTING.md). diff --git a/app/pages/Settings.py b/app/pages/Settings.py index 8ec7fc7a..c0a988cf 100644 --- a/app/pages/Settings.py +++ b/app/pages/Settings.py @@ -21,7 +21,9 @@ ) from util.secrets_handler import SecretsHandler +from app.util import ui_components from intelligence_toolkit.AI.defaults import DEFAULT_LOCAL_EMBEDDING_MODEL +from intelligence_toolkit.AI.utils import prepare_messages from intelligence_toolkit.AI.vector_store import VectorStore from intelligence_toolkit.helpers.constants import CACHE_PATH @@ -139,12 +141,6 @@ def main(): if secret and len(secret) > 0: st.info("Your key is saved securely.") - clear_btn = st.button("Clear local key") - - if clear_btn: - secrets_handler.delete_secret(key) - time.sleep(0.3) - st.rerun() if secret_input and secret_input != secret: secrets_handler.write_secret(key, secret_input) @@ -166,6 +162,31 @@ def main(): if deployment_name != openai_config.model: on_change(secrets_handler, openai_model_key, deployment_name)() st.rerun() + with col2: + if secret and len(secret) > 0: + if type_input != "OpenAI": + # streamlit alignment + for _ in range(6): + st.write("") + clear_btn = st.button("Clear local key") + + if clear_btn: + secrets_handler.delete_secret(key) + time.sleep(0.3) + st.rerun() + + test_btn = st.button( + "Test connection", + ) + if test_btn: + message = prepare_messages("Answer with OK only", {}) + try: + with st.spinner("Sending ping..."): + ui_components.generate_text(message) + st.success(f"Connection with {type_input} successful.") + except Exception as e: + st.error(f"Error: {e}") + return st.divider() st.subheader("Embeddings")