From 6a4133dfb9bdb504b8dd86fcd816c8557d11479e Mon Sep 17 00:00:00 2001 From: Matthew Harris Date: Sat, 29 Jun 2024 15:24:10 -0400 Subject: [PATCH] Added promptflow connection creates to dockerbuild to make setup easier, less steps, also positions for GH actions --- .env.example | 2 ++ README.md | 5 ++--- docker-compose-dev.yml | 5 ++++- flows/chainlit-ui-evaluation/Dockerfile | 23 ++++++++++++++++++++-- flows/chainlit-ui-evaluation/flow.dag.yaml | 2 +- 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/.env.example b/.env.example index 4ff98975..0a1117e1 100644 --- a/.env.example +++ b/.env.example @@ -82,8 +82,10 @@ HAPI_API_TOKEN= # OPENAI OPENAI_API_KEY= +ASSISTANTS_API_KEY=${OPENAI_API_KEY} ASSISTANTS_API_TYPE=openai ASSISTANTS_ID= +ASSISTANTS_BASE_URL="" ASSISTANTS_MODEL=gpt-4o ASSISTANTS_BOT_NAME="Humanitarian AI Assistant" diff --git a/README.md b/README.md index 3eb7a4bc..8eb4e347 100644 --- a/README.md +++ b/README.md @@ -218,9 +218,8 @@ Then ... 5. Open folder `/app` 6. Click on `flow.dag.yaml` 7. Top left of main pane, click on 'Visual editor' -8. On bottom left under connections, configure an Azure OpenAI connection called 'azure_openai' -9. On the Groundedness node, select your new connection -10. You can no run by clicking the play icon. See Promptflow documentation for more details +8. On the Groundedness node, select your new connection +9. You can no run by clicking the play icon. See Promptflow documentation for more details # Deployment diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index fabd2495..9765e18f 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -6,9 +6,12 @@ services: build: context: . dockerfile: ./flows/chainlit-ui-evaluation//Dockerfile + args: + OPENAI_API_KEY: ${ASSISTANTS_API_KEY} + OPENAI_API_ENDPOINT: ${ASSISTANTS_BASE_URL} container_name: recipes-ai-promptflow env_file: - - .env + - .env volumes: - ./flows:/app - ./utils:/app/chainlit-ui-evaluation/utils diff --git a/flows/chainlit-ui-evaluation/Dockerfile b/flows/chainlit-ui-evaluation/Dockerfile index 42b6b36f..dbeda547 100644 --- a/flows/chainlit-ui-evaluation/Dockerfile +++ b/flows/chainlit-ui-evaluation/Dockerfile @@ -1,6 +1,25 @@ FROM mcr.microsoft.com/azureml/promptflow/promptflow-runtime-stable:latest -# No need to copy the app code, we mount via docker-compose-dev.yml +ARG OPENAI_API_KEY +ENV OPENAI_API_KEY=$OPENAI_API_KEY + +ARG OPENAI_API_ENDPOINT +ENV OPENAI_API_ENDPOINT=$OPENAI_API_ENDPOINT + +COPY ./flows /app +COPY ./utils /app/chainlit-ui-evaluation/utils +COPY ./templates /app/chainlit-ui-evaluation/templates +COPY ./management/skills.py /app/chainlit-ui-evaluation/recipes/skills.py +COPY ./ui/chat-chainlit-assistant/app.py /app/chainlit-ui-evaluation/app.py RUN pip3 install --upgrade pip -RUN pip3 install chainlit==1.1.305 \ No newline at end of file + +# Needed for running chainlit code if using Mock tests +RUN pip3 install chainlit==1.1.305 + +# Needed for promptflow connections +RUN pip install keyrings.alt + +# Set up Connections +RUN cd /app/chainlit-ui-evaluation && pf connection create --file ./openai.yaml --set api_key=$OPENAI_API_KEY --name open_ai_connection +RUN cd /app/chainlit-ui-evaluation && pf connection create --file ./azure_openai.yaml --set api_key=$OPENAI_API_KEY --set api_base=$OPENAI_API_ENDPOINT --name azure_openai \ No newline at end of file diff --git a/flows/chainlit-ui-evaluation/flow.dag.yaml b/flows/chainlit-ui-evaluation/flow.dag.yaml index 92107c0b..2f208385 100644 --- a/flows/chainlit-ui-evaluation/flow.dag.yaml +++ b/flows/chainlit-ui-evaluation/flow.dag.yaml @@ -52,7 +52,7 @@ nodes: context: ${inputs.context} temperature: 1 model: gpt-4-turbo-preview - connection: azure_openai + connection: open_ai_connection api: chat - name: concat_scores type: python