Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
277 commits
Select commit Hold shift + click to select a range
75a1623
sort results in jira issues
imranq2 Jan 17, 2025
b65e6a6
sort results in jira issues
imranq2 Jan 17, 2025
d7707cd
use new api
imranq2 Jan 17, 2025
fb1954d
add more fields
imranq2 Jan 17, 2025
f637a60
add more fields
imranq2 Jan 17, 2025
6bb002b
get description working
imranq2 Jan 19, 2025
8c26071
get description working
imranq2 Jan 19, 2025
bdff4b8
get description working
imranq2 Jan 19, 2025
dfe3053
return query with jira issues
imranq2 Jan 21, 2025
7e0091a
add add_new_agent.md
imranq2 Jan 21, 2025
8cdf2b2
fix test
imranq2 Jan 21, 2025
1885b74
show url in github_pull_request_helper.py
imranq2 Jan 21, 2025
01c36bb
show url in github_pull_request_helper.py
imranq2 Jan 21, 2025
9fa2d95
show csv as markdown
imranq2 Jan 22, 2025
b279461
show csv as markdown
imranq2 Jan 22, 2025
5ba38f9
show csv as markdown
imranq2 Jan 22, 2025
9ccef7f
fix markdown
imranq2 Jan 22, 2025
e54b9dd
fix markdown
imranq2 Jan 22, 2025
ee31cdc
fix markdown
imranq2 Jan 22, 2025
6c67bd2
use paging
imranq2 Jan 22, 2025
6f72d6a
use paging
imranq2 Jan 22, 2025
ade1b49
fix test
imranq2 Jan 22, 2025
cc2d1fb
fix test
imranq2 Jan 23, 2025
59a9c23
add sorting of GH PRs
imranq2 Jan 23, 2025
65ce6ee
add sorting of GH PRs
imranq2 Jan 23, 2025
9b0f004
add sorting of GH PRs
imranq2 Jan 23, 2025
e9ca4fb
add sorting of GH PRs
imranq2 Jan 23, 2025
a47e9a9
Merge pull request #13 from icanbwell/sort-results-in-jira-issues
imranq2 Jan 23, 2025
5780e59
added separate build stages for Local vs Deployment images and enable…
dcanbwell Jan 23, 2025
476d35a
initial attempt at creating a tool to retrieve a specific Jira issue;…
dcanbwell Jan 24, 2025
a8f4376
rolled back my changes to the existing Development Tools model and in…
dcanbwell Jan 24, 2025
6e857ad
IOP-4114: add CONNECTHUB to provider search datasets
drew-bwell Jan 24, 2025
e71043c
Merge pull request #16 from icanbwell/IOP-4114-update-provider-search…
drew-bwell Jan 24, 2025
5bc51b8
Added health summary generator tool
anuragverma099 Jan 24, 2025
1711849
fixed pre commit error
anuragverma099 Jan 24, 2025
413c26a
added documentation in the code
anuragverma099 Jan 25, 2025
a7f32fe
added env example file
anuragverma099 Jan 25, 2025
60f47a9
added a basic tool for searching Confluence and created a new Conflue…
dcanbwell Jan 25, 2025
12bb0e6
moved extract method to file manager class
anuragverma099 Jan 25, 2025
1db77fd
made the param required to process the file
anuragverma099 Jan 26, 2025
3fa401e
created a new tool for getting a Confluence page by ID
dcanbwell Jan 26, 2025
31f91a3
updated the system prompt for PR Reviewer model to produce readable m…
dcanbwell Jan 26, 2025
5a46bf3
removed the functionality around trying to figure out the proper Conf…
dcanbwell Jan 26, 2025
955e2bd
Merge pull request #17 from icanbwell/health_summary_generator
anuragverma099 Jan 27, 2025
253a75a
Base python code for Graphql Generator Tool
drcate Jan 24, 2025
1722647
Updated FHIR GraphQL query creator
shubhamgoel24 Jan 27, 2025
558c47b
Merge pull request #19 from icanbwell/graphql_query
shubhamgoel24 Jan 27, 2025
c48c145
Updated fhir graphql query creator
shubhamgoel24 Jan 27, 2025
8a0bbb3
Merge pull request #20 from icanbwell/graphql_query_1
shubhamgoel24 Jan 27, 2025
e918656
IOP-4114: switch order of dataSets
drew-bwell Jan 27, 2025
6b58751
IOP-4114: add additional provider endpoint fields to return
drew-bwell Jan 27, 2025
163f372
Merge branch 'main' into IOP-4114-update-provider-search-datasets
drew-bwell Jan 27, 2025
51fe515
Merge pull request #21 from icanbwell/IOP-4114-update-provider-search…
drew-bwell Jan 27, 2025
3f65b8b
Add Databricks SQL Tool
cluffja Jan 27, 2025
f3b4f91
Merge branch 'main' into databricking-ai-hackathon
cluffja Jan 27, 2025
1ef38c8
Clarify adding new agents to the container_factory
cluffja Jan 27, 2025
0440fce
Correct import
cluffja Jan 27, 2025
774b618
output clean up around Jira and Confluence data
dcanbwell Jan 28, 2025
bc84b1e
Merge branch 'main' into hot-reload
dcanbwell Jan 28, 2025
10af106
Merge pull request #24 from icanbwell/update-readme
cluffja Jan 28, 2025
2941799
Correct location of Databricks SDK client
cluffja Jan 28, 2025
49302e3
Merge branch 'refs/heads/main' into databricking-ai-hackathon
cluffja Jan 28, 2025
7ea4f8a
Merge pull request #23 from icanbwell/databricking-ai-hackathon
cluffja Jan 28, 2025
7e0e6c1
Merge branch 'main' into hot-reload
dcanbwell Jan 28, 2025
3db5399
fixed mypy issues
dcanbwell Jan 28, 2025
66ac1ed
fixed jira helper unit test
dcanbwell Jan 28, 2025
1220803
Merge pull request #26 from icanbwell/hot-reload
dcanbwell Jan 28, 2025
95ef018
optimize github analyzer
imranq2 Jan 30, 2025
6327e30
Merge pull request #27 from icanbwell/optimize-git-hub-analyzer
imranq2 Jan 30, 2025
b2be3e5
update packages
imranq2 Jan 30, 2025
65601a5
add runnable config
imranq2 Jan 30, 2025
866e793
switch to create_react_agent
imranq2 Jan 30, 2025
8accba8
pass auth_token to tool
imranq2 Jan 30, 2025
38327c9
refactor code to reuse code to convert input into messages
imranq2 Jan 31, 2025
9d5ea33
refactor code to reuse code to convert input into messages
imranq2 Jan 31, 2025
a94f8f7
pass chat_request
imranq2 Jan 31, 2025
8039f0e
pass headers
imranq2 Jan 31, 2025
27f8796
pass headers
imranq2 Jan 31, 2025
83b3086
hide auth_token from output
imranq2 Jan 31, 2025
b69317b
hide auth_token from output
imranq2 Jan 31, 2025
69dc5e6
hide auth_token from output
imranq2 Jan 31, 2025
8ac04f9
hide auth_token from output
imranq2 Jan 31, 2025
f7a074c
hide auth_token from output
imranq2 Jan 31, 2025
514632d
Merge pull request #28 from icanbwell/pass-auth-token-to-agents
imranq2 Jan 31, 2025
794e855
HS-101 Update runner configuration from [self-hosted, main] to main
loganwedwards Apr 8, 2025
2eab9c0
Improve the readme.md
imranq2 Apr 21, 2025
63cb687
Merge pull request #30 from icanbwell/LE-HS-101
imranq2 Apr 21, 2025
8427250
update precommit
imranq2 Apr 22, 2025
33ddb1e
Merge pull request #31 from icanbwell/imranq2/improve-readme
imranq2 Apr 22, 2025
bb918c2
Merge pull request #33 from icanbwell/update-pre-commit
imranq2 Apr 22, 2025
6272976
Update dockercompose
loganwedwards Jun 10, 2025
13c4d11
Merge pull request #37 from icanbwell/LE-openwebui-0.6.14
loganwedwards Jun 11, 2025
debbc49
set WEBUI_URL environment variable
imranq2 Jun 16, 2025
718b0c5
Merge pull request #38 from icanbwell/set-webui-url-env-var
imranq2 Jun 20, 2025
440a0f4
added calculator tools for simple statistic calculations
sean-can-bwell Jul 11, 2025
f8dfaf9
added test for average
sean-can-bwell Jul 11, 2025
59c9fd7
fixed naming issues
sean-can-bwell Jul 11, 2025
57a4b9f
added to the tools section of the config schema
sean-can-bwell Jul 11, 2025
968c126
I don't know what's left to do
sean-can-bwell Jul 11, 2025
0d6dd9c
converted run to arun and asyncio.run(self.run...) for basic run
sean-can-bwell Jul 11, 2025
8390b6f
made correction of arun
sean-can-bwell Jul 11, 2025
d84f869
fixed error
sean-can-bwell Jul 11, 2025
7e2c38d
pre-commit hooks
sean-can-bwell Jul 15, 2025
fd606fc
precommit hooks
sean-can-bwell Jul 15, 2025
7439f30
precommit hooks
sean-can-bwell Jul 15, 2025
b7b7b29
Update language_model_gateway/gateway/tools/calculator_average_tool.py
sean-can-bwell Jul 15, 2025
48bc6bd
Merge pull request #42 from icanbwell/add-stats
sean-can-bwell Jul 15, 2025
84a4419
add mcp router
imranq2 Jul 15, 2025
fd37ca8
Merge branch 'main' into test-mcp-agent
imranq2 Jul 15, 2025
cbffd8a
fix warnings
imranq2 Jul 15, 2025
d963433
fix warnings
imranq2 Jul 15, 2025
a696f33
update packages
imranq2 Jul 15, 2025
385e56b
add mcp_tool_provider.py
imranq2 Jul 15, 2025
c62885e
load tools from mcp_tool_provider.py
imranq2 Jul 15, 2025
eb8d876
add math_server.py as a docker container
imranq2 Jul 16, 2025
a44d452
add mcp inspector
imranq2 Jul 16, 2025
4a9ddda
get mcp docker container to work
imranq2 Jul 16, 2025
b1d2467
add health check
imranq2 Jul 17, 2025
6f66fb6
fix bandit warning
imranq2 Jul 17, 2025
0227f1e
add mcp package
imranq2 Jul 17, 2025
47d6c43
rename mcp to mcp_servers to avoid conflict with mcp package
imranq2 Jul 17, 2025
eae557b
rename mcp to mcp_servers to avoid conflict with mcp package
imranq2 Jul 17, 2025
4bea642
rename mcp to mcp_servers to avoid conflict with mcp package
imranq2 Jul 18, 2025
36163fa
add provider_search.py
imranq2 Jul 18, 2025
3a19873
add provider_search.py
imranq2 Jul 18, 2025
10a7ef2
add provider_search.py
imranq2 Jul 18, 2025
0190de6
add provider_search.py
imranq2 Jul 18, 2025
cd37de7
add url to AgentConfig
imranq2 Jul 18, 2025
1d6f13b
update mcp_tool_provider.py to load agents by url
imranq2 Jul 18, 2025
8ba8392
update mcp_tool_provider.py to load agents by url
imranq2 Jul 18, 2025
5aa39dc
add test for github mcp
imranq2 Jul 18, 2025
ddefba7
replace environment variables
imranq2 Jul 18, 2025
9f86eeb
get github test working
imranq2 Jul 18, 2025
43a6f3f
get github test working
imranq2 Jul 18, 2025
1230659
add a test for confluence (not working)
imranq2 Jul 18, 2025
0caee25
convert google search into a mcp tool
imranq2 Jul 18, 2025
9bcb9ef
convert google search into a mcp tool
imranq2 Jul 18, 2025
b87f84d
convert url_to_markdown.py to mcp
imranq2 Jul 18, 2025
ef2d19c
add container for mcp_server_gateway
imranq2 Jul 21, 2025
c0ae9b1
update packages
imranq2 Jul 21, 2025
f816674
remove other servers
imranq2 Jul 21, 2025
765d454
fix one test
imranq2 Jul 21, 2025
c24efb6
fix one test
imranq2 Jul 21, 2025
bd717ee
fix one test
imranq2 Jul 21, 2025
7b7914c
add google workspace MCP server
imranq2 Jul 22, 2025
adf8498
add google workspace MCP server
imranq2 Jul 22, 2025
ee1dd5e
add test for google drive agent
imranq2 Jul 25, 2025
90330d8
add test for google drive agent
imranq2 Jul 25, 2025
6ac1af7
add env var for mcp_server_gateway
imranq2 Jul 28, 2025
e872b15
pass headers to MCP tools
imranq2 Jul 28, 2025
4f40d49
update Makefile
imranq2 Jul 28, 2025
0c2ae7f
update version
imranq2 Jul 28, 2025
5daebd1
add pipe for OpenWebUI
imranq2 Jul 28, 2025
c4aa35e
move keycloak to main docker-compose.yml
imranq2 Jul 28, 2025
8dc6263
run without ddtrace to reduce logs
imranq2 Jul 28, 2025
0eef4d1
add authlib
imranq2 Jul 28, 2025
1f567ea
add code to acquire token
imranq2 Jul 28, 2025
4625742
fix code to acquire token
imranq2 Jul 28, 2025
8c0d5c4
improve logging
imranq2 Jul 28, 2025
6092b5c
improve logging
imranq2 Jul 28, 2025
40ec040
minor
imranq2 Jul 28, 2025
4bc7353
update test_google_drive_via_llm
imranq2 Jul 28, 2025
6a8aca0
update test_google_drive_via_llm
imranq2 Jul 28, 2025
5a603f5
make headers lower case
imranq2 Jul 28, 2025
45b348c
make headers lower case
imranq2 Jul 28, 2025
83911a9
remove RUN_TESTS from docker-compose.yml
imranq2 Jul 28, 2025
57c7e3b
add readme.md for pipes
imranq2 Jul 28, 2025
834dc22
allow restricting by tool name
imranq2 Jul 28, 2025
9b3d84a
create a multiserver_mcp_client_with_caching.py
imranq2 Jul 29, 2025
00c4d3a
separate loading metadata from running tool
imranq2 Jul 29, 2025
fef2f48
cache metadata for tools
imranq2 Jul 29, 2025
8c01a25
use an expiring cache
imranq2 Jul 29, 2025
78d9f2e
use an expiring cache
imranq2 Jul 29, 2025
70d20d2
simplify google drive
imranq2 Jul 29, 2025
822ed1f
remove obsolete mcp servers
imranq2 Jul 29, 2025
3ae7fc9
use appuser
imranq2 Jul 29, 2025
f3c7f2d
Update tests/gateway/test_chat_anthropic_image_generation.py
imranq2 Jul 29, 2025
d06baa3
Merge branch 'test-mcp-agent' of https://github.com/icanbwell/languag…
imranq2 Jul 29, 2025
902b142
use appuser
imranq2 Jul 29, 2025
f627c5a
only run tests if RUN_TEST is set
imranq2 Jul 29, 2025
57a4d1a
only run tests if RUN_TEST is set
imranq2 Jul 29, 2025
89cb1fe
only run tests if RUN_TEST is set
imranq2 Jul 30, 2025
856e0aa
only run tests if RUN_TEST is set
imranq2 Jul 30, 2025
58acfdf
Merge pull request #44 from icanbwell/test-mcp-agent
imranq2 Jul 30, 2025
9f26508
added restrict_to_model_ids
imranq2 Jul 30, 2025
8724425
added restrict_to_model_ids
imranq2 Jul 30, 2025
f18652b
added restrict_to_model_ids
imranq2 Jul 30, 2025
e414793
add tool names
imranq2 Jul 30, 2025
fffd3bd
add tool names
imranq2 Jul 30, 2025
28d9c37
add tool names
imranq2 Jul 30, 2025
9d55c36
use async requests
imranq2 Jul 31, 2025
5266630
use async requests
imranq2 Jul 31, 2025
d08e5dd
improve error message
imranq2 Jul 31, 2025
a369ddd
improve error message
imranq2 Jul 31, 2025
b592447
improve error message
imranq2 Jul 31, 2025
f393001
improve error message
imranq2 Jul 31, 2025
beb70f1
improve error message
imranq2 Jul 31, 2025
5715a85
improve error message
imranq2 Jul 31, 2025
3d79fb8
use Bearer instead of token to Github
imranq2 Jul 31, 2025
91c70f1
add test for downloading zip
imranq2 Jul 31, 2025
afba931
separate caches
imranq2 Jul 31, 2025
d507eec
separate caches
imranq2 Jul 31, 2025
fa0d2dc
extract error details
imranq2 Jul 31, 2025
79fbc70
Merge pull request #45 from icanbwell/add-filtering-in-pipe
imranq2 Jul 31, 2025
3ab2450
check health
imranq2 Jul 31, 2025
0a7daff
add CORS settings
imranq2 Jul 31, 2025
3a62841
log more
imranq2 Jul 31, 2025
fb5050a
support both GET and POST on health
imranq2 Jul 31, 2025
2c0da01
Update language_model_gateway/gateway/api.py
imranq2 Jul 31, 2025
b5358d6
support both GET and POST on health
imranq2 Jul 31, 2025
50b1335
get hardcoded message working
imranq2 Aug 1, 2025
2188ef9
get hardcoded message working
imranq2 Aug 1, 2025
16ceba1
get hardcoded message working
imranq2 Aug 1, 2025
dd5b9e9
still working - pass auth token
imranq2 Aug 1, 2025
1ca5372
successfully stream data
imranq2 Aug 1, 2025
a87a40d
success: remove hardcoded url
imranq2 Aug 1, 2025
1fc7def
success: show payload
imranq2 Aug 1, 2025
3a7b890
success: show status
imranq2 Aug 1, 2025
683f96a
success: show status
imranq2 Aug 1, 2025
db1a135
success: pass on headers
imranq2 Aug 1, 2025
a8cbf34
success: add user headers
imranq2 Aug 1, 2025
cb65755
success: add user headers
imranq2 Aug 1, 2025
3ec8027
initialize mcp tool cache if it expires
imranq2 Aug 1, 2025
9c6f9d4
create url
imranq2 Aug 1, 2025
0498bdd
add comments
imranq2 Aug 4, 2025
f67c775
Merge pull request #46 from icanbwell/fix-pipe
imranq2 Aug 4, 2025
67b1c5d
improve reading of header
imranq2 Aug 4, 2025
2a4b7fe
improve reading of header
imranq2 Aug 4, 2025
fa87dc5
improve reading of header
imranq2 Aug 4, 2025
02f7328
improve reading of error
imranq2 Aug 4, 2025
7e43dd9
add test for verifying token
imranq2 Aug 5, 2025
58ffd79
use jwks
imranq2 Aug 5, 2025
e39b05c
use aiocache
imranq2 Aug 5, 2025
1792949
use TokenVerifier
imranq2 Aug 5, 2025
07ad7d3
allow lambda for singletons
imranq2 Aug 5, 2025
0ebcaf9
log url when failure
imranq2 Aug 5, 2025
b01a4cd
log url when failure
imranq2 Aug 5, 2025
359b123
separate out exception_logger.py
imranq2 Aug 5, 2025
7b75ea0
show time in AM/PM
imranq2 Aug 5, 2025
aa8fde6
support well-known-configuration
imranq2 Aug 5, 2025
7d0d5b7
support well-known-configuration
imranq2 Aug 5, 2025
36c8cf2
wait for mcp_server_gateway
imranq2 Aug 5, 2025
515f022
use boto3 types
imranq2 Aug 5, 2025
092a361
fix test
imranq2 Aug 5, 2025
0f474a1
update docker-publish.yml to limit to platforms
imranq2 Aug 5, 2025
f15d69c
Merge pull request #47 from icanbwell/fixes-for-mcp
imranq2 Aug 5, 2025
195ab20
updated two readmes
sean-can-bwell Aug 27, 2025
37a15fc
Update README.md
sean-can-bwell Aug 27, 2025
dac3eff
added further guidance to get users to the correct parts of the README
sean-can-bwell Aug 27, 2025
4e72a13
Merge branch 'update-readme-sh' of https://github.com/icanbwell/langu…
sean-can-bwell Aug 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Deploy Workflow
run-name: Deploy to ${{ inputs.env }} - ${{ inputs.tag }}

on:
workflow_dispatch:
inputs:
tag:
type: string
description: Tag to deploy
required: true
env:
type: choice
description: Environment to be deployed
required: true
options:
- dev
- staging
- perf
- prod
- client-sandbox

env:
SERVICE_NAME: language_model_gateway
SERVICE_NAMESPACE: language_model_gateway-${{ inputs.env }}

jobs:
deploy:
name: Deploy
runs-on: main
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Checkout icanbwell/cie.gha-deploy
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: refs/tags/v0.0.33
repository: icanbwell/cie.gha-deploy
token: ${{ secrets.BWELL_DEV_PAT }}
path: .github/actions/cie.gha-deploy

- name: Deploy
uses: ./.github/actions/cie.gha-deploy
with:
token: ${{ secrets.BWELL_DEV_PAT }}
service-name: $SERVICE_NAME
service-namespace: $SERVICE_NAMESPACE
env: '${{ inputs.env }}-ue1'
helm-chart-version: '1.1.8'
image-tag: ${{ github.event.inputs.tag }}

- name: 'Cleanup build folder'
if: always()
run: |
ls -la ./
sudo rm -rf ${{ github.workspace }}/*
ls -la ./
5 changes: 4 additions & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
IMAGE_NAME: language_model_gateway
REPOSITORY_URL: imranq2
REPOSITORY_URL: icanbwell

jobs:
push:
Expand Down Expand Up @@ -36,6 +36,8 @@ jobs:

- name: Install QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64

- name: Create builder
run: |
Expand All @@ -51,6 +53,7 @@ jobs:
run: |
docker buildx build \
--platform linux/amd64,linux/arm64 \
--target production \
-t $REPOSITORY_URL/$IMAGE_NAME:$TAG \
-t $REPOSITORY_URL/$IMAGE_NAME:latest \
--push \
Expand Down
100 changes: 85 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,106 @@
exclude: (^.idea/|^notebooks/)
exclude: (^.idea/|^docsrc|^docs)

repos:
# Pre-commit hooks for basic checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
# File and formatting checks
- id: end-of-file-fixer
types: [ python ]
- id: trailing-whitespace
types: [ python ]

# Conflict and security checks
- id: check-case-conflict
types: [ python ]
- id: check-docstring-first
types: [ python ]

# Security scans
- id: detect-aws-credentials
types: [ python ]
args: [ '--allow-missing-credentials' ]
- id: detect-private-key
types: [ python ]

# Dependency and import checks
- id: check-ast
- id: check-added-large-files
- id: check-json
- id: check-toml
- id: check-yaml

# Local hooks for Ruff (using local installation)
- repo: local
hooks:
- id: ruff
name: ruff
language: system
types: [ python ]
name: Ruff
entry: ruff
require_serial: true
args: [ 'check', '--fix']
- id: autoflake
name: autoflake
language: system
types: [ python ]
entry: autoflake
args: [ check, --fix, --show-fixes, --target-version=py312 ]
require_serial: true
args: [ '--in-place', '--remove-all-unused-imports', '--ignore-init-module-imports']
- id: black
name: black

- id: ruff-format
name: Ruff Format
entry: ruff
language: system
types: [python]
types: [ python ]
args: [ format ]
require_serial: true
entry: black

# MyPy for type checking
- id: mypy
name: mypy
language: system
types: [ python ]
entry: mypy
require_serial: true
args: [ --strict, --python-version=3.12, --show-error-codes, --allow-untyped-decorators ]
args: [
--strict,
--python-version=3.12,
--show-error-codes,
--allow-untyped-decorators,
--ignore-missing-imports
]

# Bandit for security scanning
- id: bandit
name: bandit
language: system
types: [ python ]
entry: bandit
require_serial: true
args: [
'-q',
'--skip', 'B101,B104,B105,B106',
'-r',
'--severity-level', 'medium'
]

# Pygrep hooks for additional checks
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-use-type-annotations
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-check-mock-methods
- id: python-no-eval
- id: python-no-log-warn

# Optional: Secret scanning
- repo: https://github.com/Yelp/detect-secrets
rev: v1.4.0
hooks:
- id: detect-secrets
args: [ 'scan' ]
exclude: >
(?x)^(
tests/.*|
docker-compose\.yml|
.helm/.*|
docker-compose-openwebui\.yml|
docker-compose-openwebui-auth\.yml
)$
107 changes: 92 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ RUN python -c "import sys; print(sys.platform, sys.version, sys.maxsize > 2**32)
RUN pip debug --verbose
RUN pip list -v

# Stage 2: Final runtime image for the application
# This stage creates a minimal image with only the runtime dependencies and the application code.
FROM public.ecr.aws/docker/library/python:3.12-alpine3.20

# Stage 2: Development image with hot reload
# This stage is optimized for local development with hot reload capability
FROM public.ecr.aws/docker/library/python:3.12-alpine3.20 AS development

# Set terminal width (COLUMNS) and height (LINES)
ENV COLUMNS=300

# Define an argument to control whether to run pipenv lock (not used in this stage)
ARG GITHUB_TOKEN

# Install runtime dependencies required by the application (e.g., for shapely, grpcio, scipy, google-crc32 and numpy)
# You can use auditwheel to check any package and identify the native library dependencies
# Install runtime dependencies required by the application
RUN apk add --no-cache curl libstdc++ libffi git graphviz graphviz-dev

# Install pipenv to manage and run the application
Expand All @@ -76,31 +76,108 @@ RUN mkdir -p ${PROMETHEUS_MULTIPROC_DIR}
# Set the working directory for the project
WORKDIR ${PROJECT_DIR}

# Copy the Pipfile and Pipfile.lock files into the runtime image
# Copy the Pipfile and Pipfile.lock files into the development image
COPY Pipfile* ${PROJECT_DIR}

# Copy installed Python packages from the previous stage
# Copy installed Python packages from the first stage
COPY --from=python_packages /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=python_packages /usr/local/bin /usr/local/bin

# Copy the application code into the runtime image
# Copy the application code into the development image
COPY ./language_model_gateway ${PROJECT_DIR}/language_model_gateway
COPY ./setup.cfg ${PROJECT_DIR}/

# Copy the Pipfile.lock from the previous stage in case it was locked
# Copy the Pipfile.lock from the first stage
COPY --from=python_packages ${PROJECT_DIR}/Pipfile.lock ${PROJECT_DIR}/Pipfile.lock
COPY --from=python_packages ${PROJECT_DIR}/Pipfile.lock /tmp/Pipfile.lock

# Create directories and list their contents (for debugging and verification)
RUN mkdir -p /usr/local/lib/python3.12/site-packages && ls -halt /usr/local/lib/python3.12/site-packages
RUN mkdir -p /usr/local/bin && ls -halt /usr/local/bin

# Create the folder where we will store generated images
RUN mkdir -p ${PROJECT_DIR}/image_generation

# Install the dependencies using pipenv in the development environment
RUN pipenv sync --dev --system --extra-pip-args="--prefer-binary"

# Expose port 5000 for the application
EXPOSE 5000

# Switch to the root user to perform user management tasks
USER root

# verify the installed version of the dot command for graphviz
RUN dot -V

# Create a restricted user (appuser) and group (appgroup) for running the application
RUN addgroup -S appgroup && adduser -S -h /etc/appuser appuser -G appgroup

# Ensure that the appuser owns the application files and directories
RUN chown -R appuser:appgroup ${PROJECT_DIR} /usr/local/lib/python3.12/site-packages /usr/local/bin ${PROMETHEUS_MULTIPROC_DIR}

# Switch to the restricted user to enhance security
USER appuser

# Development CMD with hot reload enabled
CMD ["sh", "-c", "\
ddtrace-run uvicorn language_model_gateway.gateway.api:app \
--host 0.0.0.0 \
--port 5000 \
--reload \
--log-level $(echo ${LOG_LEVEL:-info} | tr '[:upper:]' '[:lower:]') \
"]

# Stage 3: Production deployment image
# This stage is optimized for deployment with multiple workers
FROM public.ecr.aws/docker/library/python:3.12-alpine3.20 AS production

# Set terminal width (COLUMNS) and height (LINES)
ENV COLUMNS=300

# Define an argument to control whether to run pipenv lock (not used in this stage)
ARG GITHUB_TOKEN

# Install runtime dependencies required by the application
RUN apk add --no-cache curl libstdc++ libffi git graphviz graphviz-dev

# Install pipenv to manage and run the application
RUN pip install --no-cache-dir pipenv

# Set environment variables for project configuration
ENV PROJECT_DIR=/usr/src/language_model_gateway
ENV PROMETHEUS_MULTIPROC_DIR=/tmp/prometheus
ENV PIP_ROOT_USER_ACTION=ignore

# Create the directory for Prometheus metrics
RUN mkdir -p ${PROMETHEUS_MULTIPROC_DIR}

# Set the working directory for the project
WORKDIR ${PROJECT_DIR}

# Copy the Pipfile and Pipfile.lock files into the development image
COPY Pipfile* ${PROJECT_DIR}

# Copy Pipfile.lock to a temporary directory so it can be retrieved if needed
# Copy installed Python packages from the first stage
COPY --from=python_packages /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=python_packages /usr/local/bin /usr/local/bin

# Copy the application code into the development image
COPY ./language_model_gateway ${PROJECT_DIR}/language_model_gateway
COPY ./setup.cfg ${PROJECT_DIR}/

# Copy the Pipfile.lock from the first stage
COPY --from=python_packages ${PROJECT_DIR}/Pipfile.lock ${PROJECT_DIR}/Pipfile.lock
COPY --from=python_packages ${PROJECT_DIR}/Pipfile.lock /tmp/Pipfile.lock

# Create directories and list their contents (for debugging and verification)
RUN mkdir -p /usr/local/lib/python3.12/site-packages && ls -halt /usr/local/lib/python3.12/site-packages
RUN mkdir -p /usr/local/bin && ls -halt /usr/local/bin

# create the folder where we will store generated images
# Create the folder where we will store generated images
RUN mkdir -p ${PROJECT_DIR}/image_generation

# Install the dependencies using pipenv in the final runtime environment
# Install the dependencies using pipenv in the development environment
RUN pipenv sync --dev --system --extra-pip-args="--prefer-binary"

# Expose port 5000 for the application
Expand All @@ -124,13 +201,13 @@ USER appuser
# The number of workers can be controlled using the NUM_WORKERS environment variable
# Otherwise the number of workers for uvicorn (using the multiprocessing worker) is chosen based on these guidelines:
# (https://sentry.io/answers/number-of-uvicorn-workers-needed-in-production/)
# basically (cores * threads + 1)
# basically (cores _threads + 1)
CMD ["sh", "-c", "\
# Get CPU info \
CORE_COUNT=$(nproc) && \
THREAD_COUNT=$(nproc --all) && \
\
# Calculate workers using formula: (cores * threads + 1) \
# Calculate workers using formula: (cores_ threads + 1) \
WORKER_COUNT=$((CORE_COUNT * THREAD_COUNT + 1)) && \
FINAL_WORKERS=${NUM_WORKERS:-$WORKER_COUNT} && \
\
Expand All @@ -143,4 +220,4 @@ CMD ["sh", "-c", "\
--port 5000 \
--workers $FINAL_WORKERS \
--log-level $(echo ${LOG_LEVEL:-info} | tr '[:upper:]' '[:lower:]') \
"]
"]
Loading