Skip to content

Commit

Permalink
add Initialize app step
Browse files Browse the repository at this point in the history
  • Loading branch information
yoomlam committed Jun 8, 2024
1 parent 4797163 commit 6701975
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,11 @@ jobs:
# The ENV_FILE_CONTENTS contains API keys, like LITERAL_API_KEY and OPENAI_API_KEY
# As such, make sure the built image is not publicly accessible
cd ${{ inputs.dockerfile_folder }}
echo "${{ secrets[env.SECRET_NAME] }}" > .env
wc .env
# TODO: Remove conditional once "Initialize app" step works
if [ "${{ inputs.dockerfile_folder }}" != "05-assistive-chatbot" ]; then
echo "${{ secrets[env.SECRET_NAME] }}" > .env
wc .env
fi
- name: "Build image: ${{ github.sha }}"
if: inputs.build_image
Expand Down Expand Up @@ -184,4 +187,16 @@ jobs:
done
date
- name: "Initialize app"
if: inputs.deploy_image
run: |
# The ENV_FILE_CONTENTS contains API keys, like LITERAL_API_KEY and OPENAI_API_KEY
# As such, make sure the built image is not publicly accessible
echo "${{ secrets[env.SECRET_NAME] }}" > .env_vars
SVC_URL=$(aws lightsail get-container-services --service-name "$SERVICE_NAME" | jq -r '.containerServices[0].url')
echo "Setting API keys at $SVC_URL"
curl -X POST "${SVC_URL}initenvs" --data-binary '@.env_vars'
# TODO: warm up vector DB on startup
1 change: 1 addition & 0 deletions 05-assistive-chatbot/chatbot/llms/groq_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, model_name, settings):
self.model_name = model_name
self.settings = settings
logger.info("Creating LLM client '%s' with %s", model_name, self.settings)
# TODO: remove temperature from settings
self.client = Groq(**self.settings)

def generate_reponse(self, message):
Expand Down
1 change: 1 addition & 0 deletions 05-assistive-chatbot/chatbot_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def healthcheck(request: Request):

@app.post("/initenvs")
def initenvs(env_file_contents: str = Body()):
"Set environment variables for API keys and log level. See usage in push_image.yml"
env_values = dotenv.dotenv_values(stream=StringIO(env_file_contents))
vars_updated = []
for name, value in env_values.items():
Expand Down

0 comments on commit 6701975

Please sign in to comment.