Skip to content

Commit d59b6f9

Browse files
committed
update model
1 parent e1ceef2 commit d59b6f9

10 files changed

Lines changed: 85 additions & 31 deletions

File tree

‎radius/README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,13 @@ rad group delete trading
324324
│ │ │───────▶┌──────────┐ │ Mosquitto │ │
325325
│ │ │/mqtt │ ai-agent │ │ :1883 / :9001 │ │
326326
│ │ │──ws──▶ │ :7000 │ └────────────────┘ │
327-
│ └──────────┘ └──────────┘ ◀── Radius.Resources/aiAgents │
327+
│ └──────────┘ └──────────┘ ◀── Radius.Resources/aiModels │
328328
│ (only :3000 │ recipe │
329329
│ exposed) │ CONNECTION_AI_* (auto-injected) │
330330
│ ┌───▼────────────────────┐ │
331331
│ │ trading-ai │ │
332332
│ │ Radius.Resources/ │ │
333-
│ │ aiAgents │ │
333+
│ │ aiModels │ │
334334
│ └────────────────────────┘ │
335335
└──────────────────────────────────────────────────────────────────────┘
336336
```
@@ -341,8 +341,8 @@ rad group delete trading
341341
|---------------|--------|-------------|
342342
| `Radius.Resources/postgreSqlDatabases` | `kubernetes-trading-postgres.bicep` | PostgreSQL 16-alpine with custom init SQL that creates the trading schema and seeds a demo account |
343343
| `Radius.Resources/mqttBrokers` | `kubernetes-mosquitto.bicep` | Eclipse Mosquitto 2 with both a plain TCP listener (1883) and a WebSocket listener (9001) |
344-
| `Radius.Resources/aiAgents` | `kubernetes-kaito.bicep` | Open-source LLM served in-cluster via the Kaito operator (AKS + GPU). Outputs `provider=local`. |
345-
| `Radius.Resources/aiAgents` | `azure-openai.bicep` | Azure OpenAI account + model deployment. Outputs `provider=openai` and an API key. |
344+
| `Radius.Resources/aiModels` | `kubernetes-kaito.bicep` | Open-source LLM served in-cluster via the Kaito operator (AKS + GPU). Outputs `provider=local`. |
345+
| `Radius.Resources/aiModels` | `azure-openai.bicep` | Azure OpenAI account + model deployment. Outputs `provider=openai` and an API key. |
346346

347347
---
348348

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
// app-with-ai.bicep — Radius application model for portable-apps
1+
// ai-with-local-model.bicep — Radius application model for portable-apps with in-cluster AI
22
//
33
// Deploys the full stock-trading simulator on Kubernetes via Radius:
44
// • Radius.Resources/postgreSqlDatabases → PostgreSQL 16 (with trading schema)
55
// • Radius.Resources/mqttBrokers → Eclipse Mosquitto 2 (MQTT + WS)
66
// • Radius.Resources/idProviders → OIDC identity provider (Keycloak by default)
7-
// • Radius.Resources/aiAgents → AI inference endpoint (provider chosen by Recipe)
8-
// • Applications.Core/containers → backend (.NET 8), ai-agent (.NET 8), frontend (Node)
7+
// • Radius.Resources/aiModels → AI inference endpoint provisioned by a Recipe
8+
// • Applications.Core/containers → backend (.NET 8), ai-agent (.NET 8), frontend (Node)
9+
//
10+
// The ai-agent container's LLM connection values (provider, endpoint, model, apiKey) are
11+
// auto-injected by Radius from the aiModels resource connection. Use app.bicep instead
12+
// when you want to supply LLM settings directly as parameters (no Recipe required).
913
//
1014
// BEFORE DEPLOYING this file you must:
1115
// 1. Generate & register the Bicep extension (see README.md)
@@ -153,7 +157,7 @@ resource tradingMqtt 'Radius.Resources/mqttBrokers@2025-08-01-preview' = {
153157
}
154158
}
155159

156-
resource tradingAI 'Radius.Resources/aiAgents@2025-08-01-preview' = {
160+
resource tradingAI 'Radius.Resources/aiModels@2025-08-01-preview' = {
157161
name: 'trading-ai'
158162
properties: {
159163
environment: environment
@@ -241,7 +245,7 @@ resource aiAgent 'Applications.Core/containers@2023-10-01-preview' = {
241245
OTEL_EXPORTER_OTLP_ENDPOINT: { value: 'http://otel-collector:4318' }
242246
OTEL_EXPORTER_OTLP_PROTOCOL: { value: 'http/protobuf' }
243247
// Radius auto-injects CONNECTION_AI_PROVIDER, CONNECTION_AI_ENDPOINT,
244-
// and CONNECTION_AI_MODEL from the aiAgents connection below.
248+
// and CONNECTION_AI_MODEL from the aiModels connection below.
245249
// Only the secret requires explicit wiring (secrets are not auto-injected).
246250
CONNECTION_AI_SECRETS_APIKEY: { value: tradingAI.properties.secrets.apiKey }
247251
}
@@ -324,7 +328,7 @@ resource frontend 'Applications.Core/containers@2023-10-01-preview' = {
324328
}
325329
connections: {
326330
backend: { source: backend.id }
327-
aiAgent: { source: tradingAI.id }
331+
aiModel: { source: tradingAI.id }
328332
mqtt: { source: tradingMqtt.id }
329333
otel: { source: otelCollector.id }
330334
}

‎radius/aks-env.bicep‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ resource aksEnv 'Applications.Core/environments@2023-10-01-preview' = {
6262
templatePath: '${recipeRegistry}/mqtt:latest'
6363
}
6464
}
65-
// ── AI agent — Azure OpenAI ─────────────────────────────────────────
66-
'Radius.Resources/aiAgents': {
65+
// ── AI model — Azure OpenAI ─────────────────────────────────────────
66+
'Radius.Resources/aiModels': {
6767
default: {
6868
templateKind: 'bicep'
6969
templatePath: '${recipeRegistry}/ai-agent-azure-openai:latest'

‎radius/app.bicep‎

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
// app.bicep — Radius application model for portable-apps (no AI agent)
1+
// app.bicep — Radius application model for portable-apps
22
//
3-
// Deploys the stock-trading simulator on Kubernetes via Radius:
3+
// Deploys the full stock-trading simulator on Kubernetes via Radius:
44
// • Radius.Resources/postgreSqlDatabases → PostgreSQL 16 (with trading schema)
55
// • Radius.Resources/mqttBrokers → Eclipse Mosquitto 2 (MQTT + WS)
66
// • Radius.Resources/idProviders → OIDC identity provider (Keycloak by default)
7-
// • Applications.Core/containers → backend (.NET 8), frontend (Node)
7+
// • Applications.Core/containers → backend (.NET 8), ai-agent (.NET 8), frontend (Node)
8+
//
9+
// AI inference settings are supplied as optional parameters and injected directly
10+
// into the ai-agent container. Use ai-with-local-model.bicep instead when you want
11+
// Radius to provision the AI backend automatically via a Recipe.
812
//
913
// BEFORE DEPLOYING this file you must:
1014
// 1. Generate & register the Bicep extension (see README.md)
@@ -66,6 +70,19 @@ param oidcUserInfoEndpoint string = ''
6670
@description('OIDC issuer URL (e.g., https://keycloak.example.com/realms/master). Used if oidcIssuerOverride is not set.')
6771
param oidcIssuer string = ''
6872

73+
@description('AI provider mode understood by the ai-agent container ("openai", "azure", or "local"). Leave empty when AI is not used.')
74+
param aiProvider string = ''
75+
76+
@description('Base URL for the AI inference API (e.g. https://<account>.openai.azure.com/ or http://kaito-svc/v1). Leave empty when AI is not used.')
77+
param aiEndpoint string = ''
78+
79+
@description('Model or deployment name for the AI inference API (e.g. gpt-4o, llama-3.1-8b-instruct). Leave empty when AI is not used.')
80+
param aiModelName string = ''
81+
82+
@description('API key for the AI inference endpoint. Leave empty for local/unauthenticated endpoints.')
83+
@secure()
84+
param aiApiKey string = ''
85+
6986
var effectiveOidcIssuer = oidcIssuerOverride != '' ? oidcIssuerOverride : oidcIssuer
7087
var issuerBaseForDerivedEndpoints = endsWith(effectiveOidcIssuer, '/')
7188
? substring(effectiveOidcIssuer, 0, max(length(effectiveOidcIssuer) - 1, 0))
@@ -205,6 +222,37 @@ resource otelCollector 'Applications.Core/containers@2023-10-01-preview' = {
205222
}
206223
}
207224

225+
resource aiAgent 'Applications.Core/containers@2023-10-01-preview' = {
226+
name: 'ai-agent'
227+
properties: {
228+
application: tradingApp.id
229+
container: {
230+
image: '${imageRegistry}/ai-agent:${imageTag}'
231+
ports: {
232+
http: {
233+
containerPort: 7000
234+
}
235+
}
236+
env: {
237+
ASPNETCORE_URLS: { value: 'http://+:7000' }
238+
OTEL_SERVICE_NAME: { value: 'trading-ai-agent' }
239+
OTEL_RESOURCE_ATTRIBUTES: { value: 'service.namespace=portable-apps,service.version=1.0.0,deployment.environment=radius' }
240+
OTEL_EXPORTER_OTLP_ENDPOINT: { value: 'http://otel-collector:4318' }
241+
OTEL_EXPORTER_OTLP_PROTOCOL: { value: 'http/protobuf' }
242+
// LLM connection values supplied as parameters and injected directly.
243+
// Use ai-with-local-model.bicep to have Radius provision the AI backend via a Recipe.
244+
CONNECTION_AI_PROVIDER: { value: aiProvider }
245+
CONNECTION_AI_ENDPOINT: { value: aiEndpoint }
246+
CONNECTION_AI_MODEL: { value: aiModelName }
247+
CONNECTION_AI_SECRETS_APIKEY: { value: aiApiKey }
248+
}
249+
}
250+
connections: {
251+
otel: { source: otelCollector.id }
252+
}
253+
}
254+
}
255+
208256
resource backend 'Applications.Core/containers@2023-10-01-preview' = {
209257
name: 'backend'
210258
properties: {
@@ -258,6 +306,7 @@ resource frontend 'Applications.Core/containers@2023-10-01-preview' = {
258306
// In-cluster service URLs — the frontend server proxies all
259307
// browser traffic to these endpoints, so only port 3000 is exposed.
260308
BACKEND_URL: { value: 'http://backend:8080' }
309+
AI_AGENT_URL: { value: 'http://ai-agent:7000' }
261310
MQTT_WS_URL: { value: 'ws://${tradingMqtt.properties.host}:${tradingMqtt.properties.wsPort}' }
262311
// OIDC values provided as parameters (from helm-deployed portfolio or external provider).
263312
OIDC_ISSUER: { value: effectiveOidcIssuer }
@@ -275,6 +324,7 @@ resource frontend 'Applications.Core/containers@2023-10-01-preview' = {
275324
}
276325
connections: {
277326
backend: { source: backend.id }
327+
aiAgent: { source: aiAgent.id }
278328
mqtt: { source: tradingMqtt.id }
279329
otel: { source: otelCollector.id }
280330
}

‎radius/local-env.bicep‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ resource tradingEnv 'Applications.Core/environments@2023-10-01-preview' = {
5858
templatePath: '${recipeRegistry}/idp-keycloak:latest'
5959
}
6060
}
61-
// ── AI agent — Kaito (in-cluster LLM) ──────────────────────────────
62-
'Radius.Resources/aiAgents': {
61+
// ── AI model — Kaito (in-cluster LLM) ──────────────────────────────
62+
'Radius.Resources/aiModels': {
6363
default: {
6464
templateKind: 'bicep'
6565
templatePath: '${recipeRegistry}/ai-agent-kaito:latest'

‎radius/recipes/ai-agent/azure-openai.bicep‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// azure-openai.bicep
2-
// Radius Recipe: Radius.Resources/aiAgents (environment: Azure)
2+
// Radius Recipe: Radius.Resources/aiModels (environment: Azure)
33
//
44
// Creates an Azure OpenAI account and a model deployment.
55
// The provisioned endpoint is OpenAI-SDK-compatible when used with an API key,

‎radius/recipes/ai-agent/kubernetes-kaito.bicep‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// kubernetes-kaito.bicep
2-
// Radius Recipe: Radius.Resources/aiAgents (environment: local Kubernetes with Kaito)
2+
// Radius Recipe: Radius.Resources/aiModels (environment: local Kubernetes with Kaito)
33
//
44
// Deploys an open-source LLM inference server on Kubernetes using the Kaito operator
55
// in "bring your own GPU" (BYO) mode — node auto-provisioning is disabled.

‎radius/resource-types/types.yaml‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# types.yaml — All portable-apps Radius Resource Type definitions
22
#
33
# A single namespace is used for all custom resources:
4-
# Radius.Resources → postgreSqlDatabases, mqttBrokers, aiAgents
4+
# Radius.Resources → postgreSqlDatabases, mqttBrokers, aiModels
55
#
66
# Publish a single Bicep extension bundle from this file:
77
#
@@ -199,9 +199,9 @@ types:
199199
required:
200200
- environment
201201
- application
202-
aiAgents:
202+
aiModels:
203203
description: |
204-
The Radius.Resources/aiAgents Resource Type provides an OpenAI-compatible AI inference
204+
The Radius.Resources/aiModels Resource Type provides an OpenAI-compatible AI inference
205205
endpoint to an application. It is provider-agnostic: a Recipe fulfils the type
206206
by provisioning the concrete backend infrastructure and returning a uniform set
207207
of connection values so that the consuming container never needs to know which
@@ -224,13 +224,13 @@ types:
224224
225225
rad recipe register default \
226226
--environment <env> \
227-
--resource-type Radius.Resources/aiAgents \
227+
--resource-type Radius.Resources/aiModels \
228228
--template-kind bicep \
229229
--template-path br:<registry>/ai-agent-recipe:latest
230230
231231
Application model usage:
232232
233-
resource tradingAI 'Radius.Resources/aiAgents@2025-08-01-preview' = {
233+
resource tradingAI 'Radius.Resources/aiModels@2025-08-01-preview' = {
234234
name: 'trading-ai'
235235
properties: {
236236
environment: environment

‎src/ai-agent/Program.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
// --- Build the AI Agent as a singleton service --------------------------------
4949

50-
// Radius injects CONNECTION_AI_* from the aiAgents connection.
50+
// Radius injects CONNECTION_AI_* from the aiModels connection.
5151
// For local dev (docker-compose) the same env vars are set explicitly.
5252
var provider = (Environment.GetEnvironmentVariable("CONNECTION_AI_PROVIDER") ?? "openai").ToLowerInvariant();
5353
var apiKey = Environment.GetEnvironmentVariable("CONNECTION_AI_SECRETS_APIKEY") ?? "";
@@ -181,7 +181,7 @@
181181
}
182182
catch (Exception ex)
183183
{
184-
Console.Error.WriteLine($"Agent error: {ex.Message}");
184+
Console.Error.WriteLine($"Agent error: {ex}");
185185
AiAgentTelemetry.AdviceRequests.Add(1,
186186
new KeyValuePair<string, object?>("status", "error"));
187187
return Results.Json(

‎src/ai-agent/TradingAgent.csproj‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
</PropertyGroup>
77
<ItemGroup>
8-
<PackageReference Include="Microsoft.Agents.AI.OpenAI" Version="*-*" />
9-
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="*-*" />
10-
<PackageReference Include="OpenAI" Version="2.*" />
11-
<PackageReference Include="Azure.AI.OpenAI" Version="2.*-*" />
12-
<PackageReference Include="Azure.Identity" Version="1.*" />
8+
<PackageReference Include="Microsoft.Agents.AI.OpenAI" Version="1.4.0" />
9+
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="10.5.1" />
10+
<PackageReference Include="OpenAI" Version="2.10.0" />
11+
<PackageReference Include="Azure.AI.OpenAI" Version="2.9.0-beta.1" />
12+
<PackageReference Include="Azure.Identity" Version="1.21.0" />
1313
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.12.0" />
1414
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.12.0" />
1515
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.12.0" />

0 commit comments

Comments
 (0)