Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Darren Edge committed Nov 4, 2024
2 parents 46550ab + 7601dc1 commit ff8d3bf
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/ci-ghcr.yml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 7 additions & 4 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 && \
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
33 changes: 27 additions & 6 deletions app/pages/Settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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")
Expand Down

0 comments on commit ff8d3bf

Please sign in to comment.