Skip to content

Commit e2cd39e

Browse files
authored
Merge pull request #75 from Nilanka-MiHCM/main
Adding MiHCM Tool
2 parents 4cd0b87 + 041a652 commit e2cd39e

32 files changed

+6036
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#Environments
2+
.env
156 KB
Loading
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 HR Assist Agent
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# HR Assist Agent
2+
3+
This repository provides a template for deploying and managing an Azure AI Agent for MiHCM. The project leverages Azure Bicep for infrastructure deployment and Python for interacting with Azure AI services and APIs.
4+
5+
## Features
6+
7+
- **Azure AI Agent Deployment**: Automates the deployment of Azure AI resources, including AI Hubs, AI Projects, and dependent resources.
8+
- **Integration with MiHCM HR System**: Provides tools to interact with MiHCM's HR APIs for tasks like leave management, feedback handling, and work activity tracking.
9+
- **OpenAPI Integration**: Uses OpenAPI specifications to define and interact with MiHCM's external APIs.
10+
11+
## Architecture Overview
12+
![Architecture Overview](./ArchitectureOverview.png)
13+
## Project Structure
14+
- `README.md` – Project documentation
15+
- `LICENSE` - Project License
16+
- `.env` – Environment variables for the project
17+
- `deploy.bicep` – Main Bicep file for deploying the AI Agent setup
18+
- `mihcmexternalAPI.json` – OpenAPI specification for MiHCM's external API
19+
- `template.py` – Python script for interacting with Azure AI and MiHCM APIs
20+
- `requirements.txt` – Python dependencies for the project
21+
- `modules-mi-agent/` – Bicep modules for modular resource deployment
22+
- `add-capability-host.bicep` – Adds capability host resource
23+
- `ai-service-role-assignments.bicep` – Sets role assignments for AI services
24+
- `standard-ai-hub.bicep` – Deploys standard AI Hub
25+
- `standard-ai-project.bicep` – Deploys standard AI Project
26+
- `standard-dependent-resources.bicep` – Deploys dependent resources
27+
28+
29+
30+
31+
## Prerequisites
32+
33+
1. **Azure Subscription**: Ensure you have an active Azure subscription.
34+
2. **Azure CLI**: Install the [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli).
35+
3. **Bicep CLI**: Install the [Bicep CLI](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/install).
36+
4. **Python**: Install Python 3.8 or later.
37+
5. **Dependencies**: Install Python dependencies using `pip install -r requirements.txt`.
38+
39+
## Deployment
40+
41+
### Step 1: Configure Environment Variables
42+
43+
Create a `.env` file in the root directory with the following variables:
44+
45+
```properties
46+
PROJECT_CONNECTION_STRING="<Your AI project key>"
47+
PROJECT_OPENAPI_CONNECTION_NAME="<Connection name of your API key>"
48+
```
49+
50+
### Step 2: Deploy Azure Resources
51+
- Deploy the resources using the `deploy.bicep` file.
52+
- Update `PROJECT_CONNECTION_STRING` with the connection string obtained.
53+
54+
### Step 3: Define the API Key
55+
- Navigate to your AI Project and add your API Key as a custom key in the below format:
56+
```
57+
Ocp-Apim-Subscription-Key: <your key>
58+
```
59+
- Update the `PROJECT_OPENAPI_CONNECTION_NAME` with the connection name you created.
60+
61+
### Step 4: Run the python script
62+
- Use the `template.py` script to interact with the deployed Azure AI Agent and MiHCM APIs.
63+
- Update the `agent_request` value with different requests for the agent.
64+
65+
## Use Cases
66+
- What are my leave balances?
67+
- Check my leave balance for 2024. If I have more than 10 days of annual leave, submit an HR request for leave encashment or carry forward.
68+
- Please show me all my HR requests.
69+
- Submit a work activity for 2.5 hours for the meeting with Adventure Works on the Project Kick-off.
70+
- Submit a work activity for yesterday for 2.5 hours for the meeting with Contoso on the Project Kick-off.
71+
- List all my work items for yesterday and today.
72+
73+
## Support
74+
Have a question or need assistance? Get in touch with our team:
75+
76+
- Info on how to setup an account with MiHCM: https://mihcm.com/contact-us/
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
// Execute this main file to deploy Enterprise Standard Agent setup resources
2+
3+
// Parameters
4+
@minLength(2)
5+
@maxLength(12)
6+
@description('Name for the AI resource and used to derive name of dependent resources.')
7+
param aiHubName string = 'mi-agent-hub'
8+
9+
@description('Friendly name for your Hub resource')
10+
param aiHubFriendlyName string = 'Agents Hub resource'
11+
12+
@description('Description of your Azure AI resource displayed in AI studio')
13+
param aiHubDescription string = 'This is an example AI resource for use in Azure AI Studio for MiHCM agents.'
14+
15+
@description('Name for the AI project resources.')
16+
param aiProjectName string = 'mi-agent-project'
17+
18+
@description('Friendly name for your Azure AI resource')
19+
param aiProjectFriendlyName string = 'MiHCM Agents Project resource'
20+
21+
@description('Description of your Azure AI resource displayed in AI studio')
22+
param aiProjectDescription string = 'This is an example AI Project resource for use in Azure AI Studio for MiHCM agents.'
23+
24+
@description('Azure region used for the deployment of all resources.')
25+
param location string = resourceGroup().location
26+
27+
@description('Set of tags to apply to all resources.')
28+
param tags object = {}
29+
30+
@description('Name of the storage account')
31+
param storageName string = 'mi-agent-storage'
32+
33+
@description('Name of the Azure AI Services account')
34+
param aiServicesName string = 'mi-agent-ai-services'
35+
36+
@description('Model name for deployment')
37+
param modelName string = 'gpt-4o-mini'
38+
39+
@description('Model format for deployment')
40+
param modelFormat string = 'OpenAI'
41+
42+
@description('Model version for deployment')
43+
param modelVersion string = '2024-07-18'
44+
45+
@description('Model deployment SKU name')
46+
param modelSkuName string = 'GlobalStandard'
47+
48+
@description('Model deployment capacity')
49+
param modelCapacity int = 200
50+
51+
@description('Model deployment location. If you want to deploy an Azure AI resource/model in different location than the rest of the resources created.')
52+
param modelLocation string = 'eastus2'
53+
54+
@description('AI Service Account kind: either AzureOpenAI or AIServices')
55+
param aiServiceKind string = 'AIServices'
56+
57+
@description('The AI Service Account full ARM Resource ID. This is an optional field, and if not provided, the resource will be created.')
58+
param aiServiceAccountResourceId string = ''
59+
60+
@description('The Ai Storage Account full ARM Resource ID. This is an optional field, and if not provided, the resource will be created.')
61+
param aiStorageAccountResourceId string = ''
62+
63+
// Variables
64+
var name = toLower('${aiHubName}')
65+
var projectName = toLower('${aiProjectName}')
66+
67+
// Create a short, unique suffix, that will be unique to each resource group
68+
// var uniqueSuffix = substring(uniqueString(resourceGroup().id), 0, 4)
69+
param deploymentTimestamp string = utcNow('yyyyMMddHHmmss')
70+
var uniqueSuffix = substring(uniqueString('${resourceGroup().id}-${deploymentTimestamp}'), 0, 4)
71+
72+
var aiServiceExists = aiServiceAccountResourceId != ''
73+
// var acsExists = aiSearchServiceResourceId != ''
74+
75+
var aiServiceParts = split(aiServiceAccountResourceId, '/')
76+
var aiServiceAccountSubscriptionId = aiServiceExists ? aiServiceParts[2] : subscription().subscriptionId
77+
var aiServiceAccountResourceGroupName = aiServiceExists ? aiServiceParts[4] : resourceGroup().name
78+
79+
// Dependent resources for the Azure Machine Learning workspace
80+
module aiDependencies 'modules-mi-agent/standard-dependent-resources.bicep' = {
81+
name: 'dependencies-${name}-${uniqueSuffix}-deployment'
82+
params: {
83+
location: location
84+
storageName: '${storageName}${uniqueSuffix}'
85+
keyvaultName: 'kv-${name}-${uniqueSuffix}'
86+
aiServicesName: '${aiServicesName}${uniqueSuffix}'
87+
tags: tags
88+
89+
// Model deployment parameters
90+
modelName: modelName
91+
modelFormat: modelFormat
92+
modelVersion: modelVersion
93+
modelSkuName: modelSkuName
94+
modelCapacity: modelCapacity
95+
modelLocation: modelLocation
96+
97+
aiServiceAccountResourceId: aiServiceAccountResourceId
98+
aiStorageAccountResourceId: aiStorageAccountResourceId
99+
}
100+
}
101+
102+
module aiHub 'modules-mi-agent/standard-ai-hub.bicep' = {
103+
name: '${name}-${uniqueSuffix}-deployment'
104+
params: {
105+
// workspace organization
106+
aiHubName: '${name}-${uniqueSuffix}'
107+
aiHubFriendlyName: aiHubFriendlyName
108+
aiHubDescription: aiHubDescription
109+
location: location
110+
tags: tags
111+
112+
aiServicesName: aiDependencies.outputs.aiServicesName
113+
aiServiceKind: aiServiceKind
114+
aiServicesId: aiDependencies.outputs.aiservicesID
115+
aiServicesTarget: aiDependencies.outputs.aiservicesTarget
116+
aiServiceAccountResourceGroupName:aiDependencies.outputs.aiServiceAccountResourceGroupName
117+
aiServiceAccountSubscriptionId:aiDependencies.outputs.aiServiceAccountSubscriptionId
118+
119+
keyVaultId: aiDependencies.outputs.keyvaultId
120+
storageAccountId: aiDependencies.outputs.storageId
121+
}
122+
}
123+
124+
125+
module aiProject 'modules-mi-agent/standard-ai-project.bicep' = {
126+
name: '${projectName}-${uniqueSuffix}-deployment'
127+
params: {
128+
// workspace organization
129+
aiProjectName: '${projectName}-${uniqueSuffix}'
130+
aiProjectFriendlyName: aiProjectFriendlyName
131+
aiProjectDescription: aiProjectDescription
132+
location: location
133+
tags: tags
134+
aiHubId: aiHub.outputs.aiHubID
135+
}
136+
}
137+
138+
module aiServiceRoleAssignments 'modules-mi-agent/ai-service-role-assignments.bicep' = {
139+
name: 'ai-service-role-assignments-${projectName}-${uniqueSuffix}-deployment'
140+
scope: resourceGroup(aiServiceAccountSubscriptionId, aiServiceAccountResourceGroupName)
141+
params: {
142+
aiServicesName: aiDependencies.outputs.aiServicesName
143+
aiProjectPrincipalId: aiProject.outputs.aiProjectPrincipalId
144+
aiProjectId: aiProject.outputs.aiProjectResourceId
145+
}
146+
}
147+
148+
output PROJECT_CONNECTION_STRING string = aiProject.outputs.projectConnectionString

0 commit comments

Comments
 (0)