Skip to content

Commit 026381a

Browse files
committed
Fix workload identity, bump litellm version
1 parent 9e4addd commit 026381a

File tree

11 files changed

+669
-11
lines changed

11 files changed

+669
-11
lines changed

deploy/helm/tlm/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.1.40
18+
version: 0.1.41
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to

infra/tlm/environments/staging/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ locals {
1818
module "tlm" {
1919
source = "../../modules/tlm"
2020
environment = local.environment
21+
entity = "internal"
2122
location = local.location
2223

2324
create_openai_service = true
@@ -40,6 +41,9 @@ module "tlm" {
4041
}
4142
}
4243

44+
default_completion_model = "gpt-4o-mini"
45+
default_embedding_model = "text-embedding-3-small"
46+
4347
tags = local.tags
4448
}
4549

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1-
# make sure to export the app ID and tenant ID
1+
data "azuread_application_published_app_ids" "well_known" {}
22

3-
# password will be stored in image pull secret in cluster
3+
data "azuread_service_principal" "msgraph" {
4+
client_id = data.azuread_application_published_app_ids.well_known.result["MicrosoftGraph"]
5+
}
46

57
resource azuread_application_registration "this" {
6-
display_name = "TLM Cross-organization ACR Image Pull"
8+
display_name = "${var.entity} - TLM Cross-organization ACR Image Pull"
79
sign_in_audience = "AzureADMultipleOrgs"
810
}
911

12+
resource azuread_application_api_access "this" {
13+
application_id = azuread_application_registration.this.id
14+
api_client_id = data.azuread_application_published_app_ids.well_known.result["MicrosoftGraph"]
15+
16+
role_ids = [
17+
data.azuread_service_principal.msgraph.app_role_ids["Application.Read.All"]
18+
]
19+
}
20+
1021
resource azuread_application_password "this" {
1122
application_id = azuread_application_registration.this.id
1223
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
variable "entity" {
2+
type = string
3+
description = "The name of the entity deploying TLM (used to set display name for the cross-organization ACR image pull app registration)"
4+
}

infra/tlm/modules/tlm/app/main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,14 @@ resource helm_release "this" {
3131
name = "chat_backend.defaults.TLM_DEFAULT_MODEL_API_BASE"
3232
value = data.azurerm_cognitive_account.openai_service.endpoint
3333
}
34+
35+
set {
36+
name = "chat_backend.defaults.TLM_DEFAULT_COMPLETION_MODEL"
37+
value = var.default_completion_model
38+
}
39+
40+
set {
41+
name = "chat_backend.defaults.TLM_DEFAULT_EMBEDDING_MODEL"
42+
value = var.default_embedding_model
43+
}
3444
}

infra/tlm/modules/tlm/app/openai_identity_sa.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ resource kubernetes_service_account "openai_identity_sa" {
2727
namespace = local.namespace
2828
annotations = {
2929
"azure.workload.identity/client-id" = azurerm_user_assigned_identity.openai_identity_sa.client_id
30+
"azure.workload.identity/service-account-token-expiration" = "86400"
31+
}
32+
labels = {
33+
"azure.workload.identity/use" = "true"
3034
}
3135
}
3236

infra/tlm/modules/tlm/app/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,13 @@ variable "image_pull_password" {
5050
description = "The password to pull images from the registry"
5151
sensitive = true
5252
}
53+
54+
variable "default_completion_model" {
55+
type = string
56+
description = "The default completion model to use"
57+
}
58+
59+
variable "default_embedding_model" {
60+
type = string
61+
description = "The default embedding model to use"
62+
}

infra/tlm/modules/tlm/main.tf

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ resource "azurerm_resource_group" "this" {
55
tags = var.tags
66
}
77

8+
module "acr_image_pull" {
9+
source = "./acr_image_pull"
10+
11+
entity = var.entity
12+
}
13+
814
locals {
915
openai_service_resource_group_name = var.create_openai_service ? azurerm_resource_group.this.name : var.openai_service_resource_group_name
1016
}
@@ -49,10 +55,6 @@ provider "helm" {
4955
}
5056
}
5157

52-
module "acr_image_pull" {
53-
source = "./acr_image_pull"
54-
}
55-
5658

5759
module "app" {
5860
source = "./app"
@@ -68,10 +70,19 @@ module "app" {
6870
image_pull_username = module.acr_image_pull.app_reg_client_id
6971
image_pull_password = module.acr_image_pull.app_reg_password
7072

73+
default_completion_model = var.default_completion_model
74+
default_embedding_model = var.default_embedding_model
75+
7176
tags = var.tags
7277

7378
providers = {
7479
kubernetes = kubernetes
7580
helm = helm
7681
}
82+
83+
depends_on = [
84+
module.acr_image_pull,
85+
module.openai_service,
86+
module.cluster
87+
]
7788
}

infra/tlm/modules/tlm/variables.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ variable "environment" {
33
description = "The environment to deploy the TLM to"
44
}
55

6+
variable "entity" {
7+
type = string
8+
description = "The name of the entity deploying TLM (used to set display name for the cross-organization ACR image pull app registration)"
9+
}
10+
611
variable "location" {
712
type = string
813
description = "The location to deploy the TLM to"
@@ -43,3 +48,13 @@ variable "openai_deployments" {
4348
description = "The cognitive deployments to create (only set if create_openai_service is true)"
4449
default = {}
4550
}
51+
52+
variable "default_completion_model" {
53+
type = string
54+
description = "The default completion model to use. Must be deployed in the OpenAI service."
55+
}
56+
57+
variable "default_embedding_model" {
58+
type = string
59+
description = "The default embedding model to use. Must be deployed in the OpenAI service."
60+
}

services/chat-backend/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ dependencies = [
88
"azure-identity>=1.19.0",
99
"fastapi>=0.115.5",
1010
"gunicorn>=23.0.0",
11+
"litellm==1.63.8",
1112
"openai>=1.55.1",
1213
"pydantic-settings>=2.6.1",
1314
"python-json-logger>=3.2.1",

0 commit comments

Comments
 (0)