diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index bbaf9543a..ed0bd230c 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -4,4 +4,10 @@ RUN apt-get update && apt-get install -y xz-utils nodejs npm RUN curl -fsSL https://aka.ms/install-azd.sh | bash +RUN curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | \ + sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && \ + echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | \ + sudo tee /etc/apt/sources.list.d/ngrok.list && \ + sudo apt update && sudo apt install ngrok + RUN npm i -g azure-functions-core-tools@4 --unsafe-perm true \ No newline at end of file diff --git a/.dockerignore b/.dockerignore index 7347a7fbb..a7cab3bfb 100644 --- a/.dockerignore +++ b/.dockerignore @@ -11,6 +11,7 @@ **/*.*proj.user **/*.dbmdl **/*.jfm +**/azds.yaml **/bin **/charts **/docker-compose* @@ -22,4 +23,4 @@ **/secrets.dev.yaml **/values.dev.yaml LICENSE -README.md +README.md \ No newline at end of file diff --git a/azure.yaml b/azure.yaml index f56fac572..53ccfef57 100644 --- a/azure.yaml +++ b/azure.yaml @@ -1,8 +1,10 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json -name: sk-dev-team +name: ai-dev-team services: - sk-func: - project: ./src/apps/gh-flow-df - language: dotnet - host: function \ No newline at end of file + gh-flow: + project: ./src/apps/gh-flow + language: csharp + host: containerapp + docker: + context: ../../../ \ No newline at end of file diff --git a/infra/abbreviations.json b/infra/abbreviations.json index 9ee376cd5..fba689e2f 100644 --- a/infra/abbreviations.json +++ b/infra/abbreviations.json @@ -7,5 +7,8 @@ "resourcesResourceGroups": "rg-", "storageStorageAccounts": "st", "webServerFarms": "plan-", - "webSitesFunctions": "func-" + "webSitesFunctions": "func-", + "appContainerApps": "ca-", + "managedIdentityUserAssignedIdentities": "id-", + "documentDBDatabaseAccounts":"cosmos-" } \ No newline at end of file diff --git a/infra/app/db.bicep b/infra/app/db.bicep new file mode 100644 index 000000000..077bb7212 --- /dev/null +++ b/infra/app/db.bicep @@ -0,0 +1,46 @@ +param accountName string +param location string = resourceGroup().location +param tags object = {} + +param containers array = [ + { + name: 'reminders' + id: 'reminders' + partitionKey: '/id' + } + { + name: 'persistence' + id: 'persistence' + partitionKey: '/id' + } + { + name: 'clustering' + id: 'clustering' + partitionKey: '/id' + } +] + +param databaseName string = '' +param principalIds array = [] + +// Because databaseName is optional in main.bicep, we make sure the database name is set here. +var defaultDatabaseName = 'Todo' +var actualDatabaseName = !empty(databaseName) ? databaseName : defaultDatabaseName + +module cosmos '../core/database/cosmos/sql/cosmos-sql-db.bicep' = { + name: 'cosmos-sql' + params: { + accountName: accountName + location: location + tags: tags + containers: containers + databaseName: actualDatabaseName + principalIds: principalIds + } +} + +output accountName string = cosmos.outputs.accountName +output connectionStringKey string = cosmos.outputs.connectionStringKey +output databaseName string = cosmos.outputs.databaseName +output endpoint string = cosmos.outputs.endpoint +output roleDefinitionId string = cosmos.outputs.roleDefinitionId diff --git a/infra/app/gh-flow.bicep b/infra/app/gh-flow.bicep new file mode 100644 index 000000000..ee5ca3265 --- /dev/null +++ b/infra/app/gh-flow.bicep @@ -0,0 +1,164 @@ +param name string +param location string = resourceGroup().location +param tags object = {} + +param applicationInsightsName string +param identityName string +param serviceName string = 'gh-flow' +param sandboxImage string = 'mcr.microsoft.com/dotnet/sdk:7.0' + + +param containerAppsEnvironmentName string +param containerRegistryName string +param storageAccountName string +param cosmosAccountName string + +@secure() +param githubAppKey string +param githubAppId string +param githubAppInstallationId string +param rgName string +param aciShare string +param openAIServiceType string +param openAIServiceId string +param openAIDeploymentId string +param openAIEmbeddingId string +param openAIEndpoint string +@secure() +param openAIKey string +param qdrantEndpoint string + +resource ghFlowIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = { + name: identityName + location: location +} + +resource applicationInsights 'Microsoft.Insights/components@2020-02-02' existing = { + name: applicationInsightsName +} + +resource storage 'Microsoft.Storage/storageAccounts@2021-09-01' existing = { + name: storageAccountName +} + +resource cosmos 'Microsoft.DocumentDB/databaseAccounts@2022-08-15' existing = { + name: cosmosAccountName +} + +var contributorRole = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c') + +resource rgContributor 'Microsoft.Authorization/roleAssignments@2022-04-01' = { + name: guid(subscription().id, resourceGroup().id, contributorRole) + properties: { + roleDefinitionId: contributorRole + principalType: 'ServicePrincipal' + principalId: app.outputs.identityPrincipalId + } +} + +module app '../core/host/container-app.bicep' = { + name: '${serviceName}-ghflow' + params: { + name: name + location: location + tags: union(tags, { 'azd-service-name': serviceName }) + identityType: 'UserAssigned' + identityName: ghFlowIdentity.name + containerAppsEnvironmentName: containerAppsEnvironmentName + containerRegistryName: containerRegistryName + containerCpuCoreCount: '2.0' + containerMemory: '4.0Gi' + env: [ + { + name: 'APPLICATIONINSIGHTS_CONNECTION_STRING' + value: applicationInsights.properties.ConnectionString + } + { + name: 'SANDBOX_IMAGE' + value: sandboxImage + } + { + name: 'GithubOptions__AppKey' + value: githubAppKey + } + { + name: 'GithubOptions__AppId' + value: githubAppId + } + { + name: 'GithubOptions__InstallationId' + value: githubAppInstallationId + } + { + name: 'AzureOptions__SubscriptionId' + value: subscription().subscriptionId + } + { + name: 'AzureOptions__Location' + value: location + } + { + name: 'AzureOptions__ManagedIdentity' + value: ghFlowIdentity.properties.clientId + } + { + name: 'AzureOptions__ContainerInstancesResourceGroup' + value: rgName + } + { + name: 'AzureOptions__FilesAccountKey' + value: storage.listKeys().keys[0].value + } + { + name: 'AzureOptions__FilesShareName' + value: aciShare + } + { + name: 'AzureOptions__FilesAccountName' + value: storageAccountName + } + { + name: 'AzureOptions__CosmosConnectionString' + value: cosmos.listConnectionStrings().connectionStrings[0].connectionString + } + { + name: 'OpenAIOptions__ServiceType' + value: openAIServiceType + } + { + name: 'OpenAIOptions__ServiceId' + value: openAIServiceId + } + { + name: 'OpenAIOptions__DeploymentOrModelId' + value: openAIDeploymentId + } + { + name: 'OpenAIOptions__EmbeddingDeploymentOrModelId' + value: openAIEmbeddingId + } + { + name: 'OpenAIOptions__Endpoint' + value: openAIEndpoint + } + { + name: 'OpenAIOptions__ApiKey' + value: openAIKey + } + { + name: 'QdrantOptions__Endpoint' + value: qdrantEndpoint + } + { + name: 'QdrantOptions__VectorSize' + value: '1536' + } + ] + targetPort: 5274 + } +} + + +output SERVICE_TRANSLATE_API_IDENTITY_PRINCIPAL_ID string = app.outputs.identityPrincipalId +output SERVICE_TRANSLATE_API_NAME string = app.outputs.name +output SERVICE_TRANSLATE_API_URI string = app.outputs.uri diff --git a/infra/core/database/cosmos/cosmos-account.bicep b/infra/core/database/cosmos/cosmos-account.bicep new file mode 100644 index 000000000..4c129b0f7 --- /dev/null +++ b/infra/core/database/cosmos/cosmos-account.bicep @@ -0,0 +1,37 @@ +metadata description = 'Creates an Azure Cosmos DB account.' +param name string +param location string = resourceGroup().location +param tags object = {} + +param connectionStringKey string = 'AZURE-COSMOS-CONNECTION-STRING' + +@allowed([ 'GlobalDocumentDB', 'MongoDB', 'Parse' ]) +param kind string + +resource cosmos 'Microsoft.DocumentDB/databaseAccounts@2022-08-15' = { + name: name + kind: kind + location: location + tags: tags + properties: { + consistencyPolicy: { defaultConsistencyLevel: 'Session' } + locations: [ + { + locationName: location + failoverPriority: 0 + isZoneRedundant: false + } + ] + databaseAccountOfferType: 'Standard' + enableAutomaticFailover: false + enableMultipleWriteLocations: false + apiProperties: (kind == 'MongoDB') ? { serverVersion: '4.0' } : {} + capabilities: [ { name: 'EnableServerless' } ] + } +} + + +output connectionStringKey string = connectionStringKey +output endpoint string = cosmos.properties.documentEndpoint +output id string = cosmos.id +output name string = cosmos.name diff --git a/infra/core/database/cosmos/sql/cosmos-sql-account.bicep b/infra/core/database/cosmos/sql/cosmos-sql-account.bicep new file mode 100644 index 000000000..fee0f679e --- /dev/null +++ b/infra/core/database/cosmos/sql/cosmos-sql-account.bicep @@ -0,0 +1,19 @@ +metadata description = 'Creates an Azure Cosmos DB for NoSQL account.' +param name string +param location string = resourceGroup().location +param tags object = {} + +module cosmos '../../cosmos/cosmos-account.bicep' = { + name: 'cosmos-account' + params: { + name: name + location: location + tags: tags + kind: 'GlobalDocumentDB' + } +} + +output connectionStringKey string = cosmos.outputs.connectionStringKey +output endpoint string = cosmos.outputs.endpoint +output id string = cosmos.outputs.id +output name string = cosmos.outputs.name diff --git a/infra/core/database/cosmos/sql/cosmos-sql-db.bicep b/infra/core/database/cosmos/sql/cosmos-sql-db.bicep new file mode 100644 index 000000000..3c79064ec --- /dev/null +++ b/infra/core/database/cosmos/sql/cosmos-sql-db.bicep @@ -0,0 +1,72 @@ +metadata description = 'Creates an Azure Cosmos DB for NoSQL account with a database.' +param accountName string +param databaseName string +param location string = resourceGroup().location +param tags object = {} + +param containers array = [] +param principalIds array = [] + +module cosmos 'cosmos-sql-account.bicep' = { + name: 'cosmos-sql-account' + params: { + name: accountName + location: location + tags: tags + } +} + +resource database 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2022-05-15' = { + name: '${accountName}/${databaseName}' + properties: { + resource: { id: databaseName } + } + + resource list 'containers' = [for container in containers: { + name: container.name + properties: { + resource: { + id: container.id + partitionKey: { paths: [ container.partitionKey ] } + } + options: {} + } + }] + + dependsOn: [ + cosmos + ] +} + +module roleDefinition 'cosmos-sql-role-def.bicep' = { + name: 'cosmos-sql-role-definition' + params: { + accountName: accountName + } + dependsOn: [ + cosmos + database + ] +} + +// We need batchSize(1) here because sql role assignments have to be done sequentially +@batchSize(1) +module userRole 'cosmos-sql-role-assign.bicep' = [for principalId in principalIds: if (!empty(principalId)) { + name: 'cosmos-sql-user-role-${uniqueString(principalId)}' + params: { + accountName: accountName + roleDefinitionId: roleDefinition.outputs.id + principalId: principalId + } + dependsOn: [ + cosmos + database + ] +}] + +output accountId string = cosmos.outputs.id +output accountName string = cosmos.outputs.name +output connectionStringKey string = cosmos.outputs.connectionStringKey +output databaseName string = databaseName +output endpoint string = cosmos.outputs.endpoint +output roleDefinitionId string = roleDefinition.outputs.id diff --git a/infra/core/database/cosmos/sql/cosmos-sql-role-assign.bicep b/infra/core/database/cosmos/sql/cosmos-sql-role-assign.bicep new file mode 100644 index 000000000..3949efef0 --- /dev/null +++ b/infra/core/database/cosmos/sql/cosmos-sql-role-assign.bicep @@ -0,0 +1,19 @@ +metadata description = 'Creates a SQL role assignment under an Azure Cosmos DB account.' +param accountName string + +param roleDefinitionId string +param principalId string = '' + +resource role 'Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments@2022-05-15' = { + parent: cosmos + name: guid(roleDefinitionId, principalId, cosmos.id) + properties: { + principalId: principalId + roleDefinitionId: roleDefinitionId + scope: cosmos.id + } +} + +resource cosmos 'Microsoft.DocumentDB/databaseAccounts@2022-08-15' existing = { + name: accountName +} diff --git a/infra/core/database/cosmos/sql/cosmos-sql-role-def.bicep b/infra/core/database/cosmos/sql/cosmos-sql-role-def.bicep new file mode 100644 index 000000000..778d6dc47 --- /dev/null +++ b/infra/core/database/cosmos/sql/cosmos-sql-role-def.bicep @@ -0,0 +1,30 @@ +metadata description = 'Creates a SQL role definition under an Azure Cosmos DB account.' +param accountName string + +resource roleDefinition 'Microsoft.DocumentDB/databaseAccounts/sqlRoleDefinitions@2022-08-15' = { + parent: cosmos + name: guid(cosmos.id, accountName, 'sql-role') + properties: { + assignableScopes: [ + cosmos.id + ] + permissions: [ + { + dataActions: [ + 'Microsoft.DocumentDB/databaseAccounts/readMetadata' + 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/items/*' + 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/*' + ] + notDataActions: [] + } + ] + roleName: 'Reader Writer' + type: 'CustomRole' + } +} + +resource cosmos 'Microsoft.DocumentDB/databaseAccounts@2022-08-15' existing = { + name: accountName +} + +output id string = roleDefinition.id diff --git a/infra/core/security/registry-access.bicep b/infra/core/security/registry-access.bicep new file mode 100644 index 000000000..5335efabc --- /dev/null +++ b/infra/core/security/registry-access.bicep @@ -0,0 +1,19 @@ +metadata description = 'Assigns ACR Pull permissions to access an Azure Container Registry.' +param containerRegistryName string +param principalId string + +var acrPullRole = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d') + +resource aksAcrPull 'Microsoft.Authorization/roleAssignments@2022-04-01' = { + scope: containerRegistry // Use when specifying a scope that is different than the deployment scope + name: guid(subscription().id, resourceGroup().id, principalId, acrPullRole) + properties: { + roleDefinitionId: acrPullRole + principalType: 'ServicePrincipal' + principalId: principalId + } +} + +resource containerRegistry 'Microsoft.ContainerRegistry/registries@2022-02-01-preview' existing = { + name: containerRegistryName +} diff --git a/infra/main.bicep b/infra/main.bicep index 5e88f44f9..e7af7b64f 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -30,6 +30,8 @@ param resourceGroupName string = '' param storageAccountName string = '' param containerAppsEnvironmentName string = '' param containerRegistryName string = '' +param ghFlowServiceName string = '' +param cosmosAccountName string = '' var aciShare = 'acishare' @@ -107,62 +109,110 @@ module qdrant './core/database/qdrant/qdrant-aca.bicep' = { } // Create an App Service Plan to group applications under the same payment plan and SKU -module appServicePlan './core/host/appserviceplan.bicep' = { - name: 'appserviceplan' - scope: rg - params: { - name: !empty(appServicePlanName) ? appServicePlanName : '${abbrs.webServerFarms}${resourceToken}' - location: location - tags: tags - sku: { - name: 'EP1' - tier: 'ElasticPremium' - family: 'EP' - } - kind: 'elastic' - reserved: false - } -} +// module appServicePlan './core/host/appserviceplan.bicep' = { +// name: 'appserviceplan' +// scope: rg +// params: { +// name: !empty(appServicePlanName) ? appServicePlanName : '${abbrs.webServerFarms}${resourceToken}' +// location: location +// tags: tags +// sku: { +// name: 'EP1' +// tier: 'ElasticPremium' +// family: 'EP' +// } +// kind: 'elastic' +// reserved: false +// } +// } -var appName = !empty(apiServiceName) ? apiServiceName : '${abbrs.webSitesFunctions}api-${resourceToken}' +// var appName = !empty(apiServiceName) ? apiServiceName : '${abbrs.webSitesFunctions}api-${resourceToken}' // The application backend -module skfunc './app/sk-func.bicep' = { - name: 'skfunc' +// module skfunc './app/sk-func.bicep' = { +// name: 'skfunc' +// scope: rg +// params: { +// name: appName +// location: location +// tags: tags +// applicationInsightsName: monitoring.outputs.applicationInsightsName +// appServicePlanId: appServicePlan.outputs.id +// storageAccountName: storage.outputs.name +// appSettings: { +// SANDBOX_IMAGE: 'mcr.microsoft.com/dotnet/sdk:7.0' +// AzureWebJobsFeatureFlags: 'EnableHttpProxying' +// FUNCTIONS_FQDN: 'https://${appName}.azurewebsites.net' +// 'GithubOptions__AppKey': githubAppKey +// 'GithubOptions__AppId': githubAppId +// 'GithubOptions__InstallationId': githubAppInstallationId +// 'AzureOptions__SubscriptionId': subscription().subscriptionId +// 'AzureOptions__Location': location +// 'AzureOptions__ContainerInstancesResourceGroup': rg.name +// 'AzureOptions__FilesShareName': aciShare +// 'AzureOptions__FilesAccountName': storage.outputs.name +// 'OpenAIOptions__ServiceType': openAIServiceType +// 'OpenAIOptions__ServiceId': openAIServiceId +// 'OpenAIOptions__DeploymentOrModelId': openAIDeploymentId +// 'OpenAIOptions__EmbeddingDeploymentOrModelId': openAIEmbeddingId +// 'OpenAIOptions__Endpoint': openAIEndpoint +// 'OpenAIOptions__ApiKey': openAIKey +// 'QdrantOptions__Endpoint':'https://${qdrant.outputs.fqdn}' +// 'QdrantOptions__VectorSize':'1536' +// } +// } +// } + + +// The application database +module cosmos './app/db.bicep' = { + name: 'cosmos' scope: rg params: { - name: appName + accountName: !empty(cosmosAccountName) ? cosmosAccountName : '${abbrs.documentDBDatabaseAccounts}${resourceToken}' + databaseName: 'devteam' location: location tags: tags - applicationInsightsName: monitoring.outputs.applicationInsightsName - appServicePlanId: appServicePlan.outputs.id - storageAccountName: storage.outputs.name - appSettings: { - SANDBOX_IMAGE: 'mcr.microsoft.com/dotnet/sdk:7.0' - AzureWebJobsFeatureFlags: 'EnableHttpProxying' - FUNCTIONS_FQDN: 'https://${appName}.azurewebsites.net' - 'GithubOptions__AppKey': githubAppKey - 'GithubOptions__AppId': githubAppId - 'GithubOptions__InstallationId': githubAppInstallationId - 'AzureOptions__SubscriptionId': subscription().subscriptionId - 'AzureOptions__Location': location - 'AzureOptions__ContainerInstancesResourceGroup': rg.name - 'AzureOptions__FilesShareName': aciShare - 'AzureOptions__FilesAccountName': storage.outputs.name - 'OpenAIOptions__ServiceType': openAIServiceType - 'OpenAIOptions__ServiceId': openAIServiceId - 'OpenAIOptions__DeploymentOrModelId': openAIDeploymentId - 'OpenAIOptions__EmbeddingDeploymentOrModelId': openAIEmbeddingId - 'OpenAIOptions__Endpoint': openAIEndpoint - 'OpenAIOptions__ApiKey': openAIKey - 'QdrantOptions__Endpoint':'https://${qdrant.outputs.fqdn}' - 'QdrantOptions__VectorSize':'1536' - } } } +module ghFlow './app/gh-flow.bicep' = { + name: 'gh-flow' + scope: rg + params: { + name: !empty(ghFlowServiceName) ? ghFlowServiceName : '${abbrs.appContainerApps}ghflow-${resourceToken}' + location: location + tags: tags + identityName: '${abbrs.managedIdentityUserAssignedIdentities}ghflow-${resourceToken}' + applicationInsightsName: monitoring.outputs.applicationInsightsName + containerAppsEnvironmentName: containerApps.outputs.environmentName + containerRegistryName:containerApps.outputs.registryName + storageAccountName: storage.outputs.name + aciShare: aciShare + githubAppId: githubAppId + githubAppInstallationId: githubAppInstallationId + githubAppKey: githubAppKey + openAIDeploymentId: openAIDeploymentId + openAIEmbeddingId: openAIEmbeddingId + openAIEndpoint: openAIEndpoint + openAIKey: openAIKey + openAIServiceId: openAIServiceId + openAIServiceType: openAIServiceType + qdrantEndpoint: 'https://${qdrant.outputs.fqdn}' + rgName: rg.name + cosmosAccountName: cosmos.outputs.accountName + } +} + +// Data outputs +output AZURE_COSMOS_ENDPOINT string = cosmos.outputs.endpoint +output AZURE_COSMOS_CONNECTION_STRING_KEY string = cosmos.outputs.connectionStringKey +output AZURE_COSMOS_DATABASE_NAME string = cosmos.outputs.databaseName + // App outputs output APPLICATIONINSIGHTS_CONNECTION_STRING string = monitoring.outputs.applicationInsightsConnectionString +output AZURE_CONTAINER_ENVIRONMENT_NAME string = containerApps.outputs.environmentName +output AZURE_CONTAINER_REGISTRY_ENDPOINT string = containerApps.outputs.registryLoginServer +output AZURE_CONTAINER_REGISTRY_NAME string = containerApps.outputs.registryName output AZURE_LOCATION string = location output AZURE_TENANT_ID string = tenant().tenantId - diff --git a/sk-dev-team.sln b/sk-dev-team.sln index 42943545f..2f3edd9f0 100644 --- a/sk-dev-team.sln +++ b/sk-dev-team.sln @@ -21,9 +21,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libs", "libs", "{24EB6E3A-C EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.SemanticKernel", "src\libs\Elsa.SemanticKernel\Elsa.SemanticKernel.csproj", "{1F6EE104-0B3F-49C1-BE3B-B93CAD18BAD0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MS.AI.DevTeam", "src\libs\MS.AI.DevTeam\MS.AI.DevTeam.csproj", "{A064E523-718C-4464-B8AD-BC00BF2E358A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AI.DevTeam", "src\libs\Microsoft.AI.DevTeam\Microsoft.AI.DevTeam.csproj", "{9FA8DCFB-1726-42FB-B6CD-8AAC027810A1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "skills", "src\libs\skills\skills.csproj", "{3EAFB48F-FBF5-4362-8696-976D7E1EA309}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AI.DevTeam.Skills", "src\libs\Microsoft.AI.DevTeam.Skills\Microsoft.AI.DevTeam.Skills.csproj", "{FF3D28B0-9344-44AF-BEEA-260187BE435E}" EndProject Global GlobalSection(SolutionProperties) = preSolution @@ -41,8 +41,8 @@ Global {F288CF45-81EF-4F57-ABAC-D7ABE894E7A0} = {4D8667EC-09BE-4CB1-A278-E1CCD83B62B0} {24EB6E3A-C080-4B27-8EA7-F6C91446B840} = {088E1138-FF7B-4179-AD37-4E3819C56D7E} {1F6EE104-0B3F-49C1-BE3B-B93CAD18BAD0} = {24EB6E3A-C080-4B27-8EA7-F6C91446B840} - {A064E523-718C-4464-B8AD-BC00BF2E358A} = {24EB6E3A-C080-4B27-8EA7-F6C91446B840} - {3EAFB48F-FBF5-4362-8696-976D7E1EA309} = {088E1138-FF7B-4179-AD37-4E3819C56D7E} + {9FA8DCFB-1726-42FB-B6CD-8AAC027810A1} = {24EB6E3A-C080-4B27-8EA7-F6C91446B840} + {FF3D28B0-9344-44AF-BEEA-260187BE435E} = {24EB6E3A-C080-4B27-8EA7-F6C91446B840} EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -125,29 +125,29 @@ Global {1F6EE104-0B3F-49C1-BE3B-B93CAD18BAD0}.Release|x64.Build.0 = Release|Any CPU {1F6EE104-0B3F-49C1-BE3B-B93CAD18BAD0}.Release|x86.ActiveCfg = Release|Any CPU {1F6EE104-0B3F-49C1-BE3B-B93CAD18BAD0}.Release|x86.Build.0 = Release|Any CPU - {A064E523-718C-4464-B8AD-BC00BF2E358A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A064E523-718C-4464-B8AD-BC00BF2E358A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A064E523-718C-4464-B8AD-BC00BF2E358A}.Debug|x64.ActiveCfg = Debug|Any CPU - {A064E523-718C-4464-B8AD-BC00BF2E358A}.Debug|x64.Build.0 = Debug|Any CPU - {A064E523-718C-4464-B8AD-BC00BF2E358A}.Debug|x86.ActiveCfg = Debug|Any CPU - {A064E523-718C-4464-B8AD-BC00BF2E358A}.Debug|x86.Build.0 = Debug|Any CPU - {A064E523-718C-4464-B8AD-BC00BF2E358A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A064E523-718C-4464-B8AD-BC00BF2E358A}.Release|Any CPU.Build.0 = Release|Any CPU - {A064E523-718C-4464-B8AD-BC00BF2E358A}.Release|x64.ActiveCfg = Release|Any CPU - {A064E523-718C-4464-B8AD-BC00BF2E358A}.Release|x64.Build.0 = Release|Any CPU - {A064E523-718C-4464-B8AD-BC00BF2E358A}.Release|x86.ActiveCfg = Release|Any CPU - {A064E523-718C-4464-B8AD-BC00BF2E358A}.Release|x86.Build.0 = Release|Any CPU - {3EAFB48F-FBF5-4362-8696-976D7E1EA309}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3EAFB48F-FBF5-4362-8696-976D7E1EA309}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3EAFB48F-FBF5-4362-8696-976D7E1EA309}.Debug|x64.ActiveCfg = Debug|Any CPU - {3EAFB48F-FBF5-4362-8696-976D7E1EA309}.Debug|x64.Build.0 = Debug|Any CPU - {3EAFB48F-FBF5-4362-8696-976D7E1EA309}.Debug|x86.ActiveCfg = Debug|Any CPU - {3EAFB48F-FBF5-4362-8696-976D7E1EA309}.Debug|x86.Build.0 = Debug|Any CPU - {3EAFB48F-FBF5-4362-8696-976D7E1EA309}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3EAFB48F-FBF5-4362-8696-976D7E1EA309}.Release|Any CPU.Build.0 = Release|Any CPU - {3EAFB48F-FBF5-4362-8696-976D7E1EA309}.Release|x64.ActiveCfg = Release|Any CPU - {3EAFB48F-FBF5-4362-8696-976D7E1EA309}.Release|x64.Build.0 = Release|Any CPU - {3EAFB48F-FBF5-4362-8696-976D7E1EA309}.Release|x86.ActiveCfg = Release|Any CPU - {3EAFB48F-FBF5-4362-8696-976D7E1EA309}.Release|x86.Build.0 = Release|Any CPU + {9FA8DCFB-1726-42FB-B6CD-8AAC027810A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9FA8DCFB-1726-42FB-B6CD-8AAC027810A1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9FA8DCFB-1726-42FB-B6CD-8AAC027810A1}.Debug|x64.ActiveCfg = Debug|Any CPU + {9FA8DCFB-1726-42FB-B6CD-8AAC027810A1}.Debug|x64.Build.0 = Debug|Any CPU + {9FA8DCFB-1726-42FB-B6CD-8AAC027810A1}.Debug|x86.ActiveCfg = Debug|Any CPU + {9FA8DCFB-1726-42FB-B6CD-8AAC027810A1}.Debug|x86.Build.0 = Debug|Any CPU + {9FA8DCFB-1726-42FB-B6CD-8AAC027810A1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9FA8DCFB-1726-42FB-B6CD-8AAC027810A1}.Release|Any CPU.Build.0 = Release|Any CPU + {9FA8DCFB-1726-42FB-B6CD-8AAC027810A1}.Release|x64.ActiveCfg = Release|Any CPU + {9FA8DCFB-1726-42FB-B6CD-8AAC027810A1}.Release|x64.Build.0 = Release|Any CPU + {9FA8DCFB-1726-42FB-B6CD-8AAC027810A1}.Release|x86.ActiveCfg = Release|Any CPU + {9FA8DCFB-1726-42FB-B6CD-8AAC027810A1}.Release|x86.Build.0 = Release|Any CPU + {FF3D28B0-9344-44AF-BEEA-260187BE435E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FF3D28B0-9344-44AF-BEEA-260187BE435E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FF3D28B0-9344-44AF-BEEA-260187BE435E}.Debug|x64.ActiveCfg = Debug|Any CPU + {FF3D28B0-9344-44AF-BEEA-260187BE435E}.Debug|x64.Build.0 = Debug|Any CPU + {FF3D28B0-9344-44AF-BEEA-260187BE435E}.Debug|x86.ActiveCfg = Debug|Any CPU + {FF3D28B0-9344-44AF-BEEA-260187BE435E}.Debug|x86.Build.0 = Debug|Any CPU + {FF3D28B0-9344-44AF-BEEA-260187BE435E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FF3D28B0-9344-44AF-BEEA-260187BE435E}.Release|Any CPU.Build.0 = Release|Any CPU + {FF3D28B0-9344-44AF-BEEA-260187BE435E}.Release|x64.ActiveCfg = Release|Any CPU + {FF3D28B0-9344-44AF-BEEA-260187BE435E}.Release|x64.Build.0 = Release|Any CPU + {FF3D28B0-9344-44AF-BEEA-260187BE435E}.Release|x86.ActiveCfg = Release|Any CPU + {FF3D28B0-9344-44AF-BEEA-260187BE435E}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/src/apps/cli/Program.cs b/src/apps/cli/Program.cs index 5b04b8cc6..5d18ee5b1 100644 --- a/src/apps/cli/Program.cs +++ b/src/apps/cli/Program.cs @@ -1,13 +1,12 @@ using System.CommandLine; using System.Text.Json; +using Microsoft.AI.DevTeam.Skills; using Microsoft.Extensions.Logging; using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.Connectors.AI.OpenAI.TextEmbedding; using Microsoft.SemanticKernel.Connectors.Memory.Qdrant; using Microsoft.SemanticKernel.Memory; using Microsoft.SemanticKernel.Orchestration; -using Microsoft.SemanticKernel.Reliability; -using Microsoft.SKDevTeam; class Program diff --git a/src/apps/cli/cli.csproj b/src/apps/cli/cli.csproj index 9e17d7eae..d1bfcd0ad 100644 --- a/src/apps/cli/cli.csproj +++ b/src/apps/cli/cli.csproj @@ -16,7 +16,7 @@ - + diff --git a/src/apps/gh-flow-df/Orchestrators/SubIssueOrchestration.cs b/src/apps/gh-flow-df/Orchestrators/SubIssueOrchestration.cs index ebacb2210..5028a972a 100644 --- a/src/apps/gh-flow-df/Orchestrators/SubIssueOrchestration.cs +++ b/src/apps/gh-flow-df/Orchestrators/SubIssueOrchestration.cs @@ -1,6 +1,6 @@ +using Microsoft.AI.DevTeam.Skills; using Microsoft.Azure.Functions.Worker; using Microsoft.DurableTask; -using Microsoft.SKDevTeam; namespace SK.DevTeam { @@ -128,7 +128,7 @@ namespace SK.DevTeam if (request.RunInSandbox) { - var newRequest = new RunInSandboxRequest + var newRequest = new RunInSandboxRequest { PrRequest = request, SanboxOrchestrationId = context.InstanceId diff --git a/src/apps/gh-flow-df/Services/WebHookEventProcessor.cs b/src/apps/gh-flow-df/Services/WebHookEventProcessor.cs index ba35597c1..70168f5dd 100644 --- a/src/apps/gh-flow-df/Services/WebHookEventProcessor.cs +++ b/src/apps/gh-flow-df/Services/WebHookEventProcessor.cs @@ -1,5 +1,6 @@ using System.Net.Http.Json; using System.Text; +using Microsoft.AI.DevTeam.Skills; using Microsoft.Extensions.Logging; using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.Orchestration; @@ -9,7 +10,6 @@ using Octokit.Webhooks.Events; using Octokit.Webhooks.Events.IssueComment; using Octokit.Webhooks.Events.Issues; using Octokit.Webhooks.Models; -using Microsoft.SKDevTeam; [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2007: Do not directly await a Task", Justification = "Durable functions")] public class SKWebHookEventProcessor : WebhookEventProcessor diff --git a/src/apps/gh-flow-df/gh-flow-df.csproj b/src/apps/gh-flow-df/gh-flow-df.csproj index 2f57ec9f5..aba8a20b4 100644 --- a/src/apps/gh-flow-df/gh-flow-df.csproj +++ b/src/apps/gh-flow-df/gh-flow-df.csproj @@ -37,7 +37,7 @@ - + diff --git a/src/apps/gh-flow/Dockerfile b/src/apps/gh-flow/Dockerfile new file mode 100644 index 000000000..94041c3fa --- /dev/null +++ b/src/apps/gh-flow/Dockerfile @@ -0,0 +1,23 @@ +FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +WORKDIR /app +EXPOSE 5274 +EXPOSE 11111 +EXPOSE 30000 + +ENV ASPNETCORE_URLS=http://+:5274 + +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +ARG configuration=Release +COPY . . +RUN dotnet restore "src/apps/gh-flow/gh-flow.csproj" +WORKDIR "/src/apps/gh-flow" +RUN dotnet build "gh-flow.csproj" -c $configuration -o /app/build + +FROM build AS publish +ARG configuration=Release +RUN dotnet publish "gh-flow.csproj" -c $configuration -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "gh-flow.dll"] \ No newline at end of file diff --git a/src/apps/gh-flow/Program.cs b/src/apps/gh-flow/Program.cs index 2976f4d93..c8a7da568 100644 --- a/src/apps/gh-flow/Program.cs +++ b/src/apps/gh-flow/Program.cs @@ -1,12 +1,13 @@ using System.Text.Json; +using Microsoft.AI.DevTeam; using Microsoft.Extensions.Options; using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.Connectors.AI.OpenAI.TextEmbedding; using Microsoft.SemanticKernel.Connectors.Memory.Qdrant; using Microsoft.SemanticKernel.Memory; -using MS.AI.DevTeam; using Octokit.Webhooks; using Octokit.Webhooks.AspNetCore; +using Orleans.Configuration; var builder = WebApplication.CreateBuilder(args); builder.Services.AddSingleton(); @@ -49,29 +50,73 @@ builder.Services.AddSingleton(); builder.Host.UseOrleans(siloBuilder => { - var connectionString = builder.Configuration.GetValue("AzureOptions:CosmosConnectionString"); - siloBuilder.UseCosmosReminderService( o => + + if (builder.Environment.IsDevelopment()) { - o.ConfigureCosmosClient(connectionString); - o.ContainerName = "devteam"; - o.DatabaseName = "reminders"; - o.IsResourceCreationEnabled = true; - }); - siloBuilder.AddCosmosGrainStorage( - name: "messages", - configureOptions: o => + var connectionString = builder.Configuration.GetValue("AzureOptions:CosmosConnectionString"); + siloBuilder.UseCosmosReminderService( o => { - o.ConfigureCosmosClient(connectionString); - o.ContainerName = "devteam"; - o.DatabaseName = "persistence"; - o.IsResourceCreationEnabled = true; + o.ConfigureCosmosClient(connectionString); + o.ContainerName = "reminders"; + o.DatabaseName = "devteam"; + o.IsResourceCreationEnabled = true; }); - siloBuilder.UseLocalhostClustering(); + siloBuilder.AddCosmosGrainStorage( + name: "messages", + configureOptions: o => + { + o.ConfigureCosmosClient(connectionString); + o.ContainerName = "persistence"; + o.DatabaseName = "devteam"; + o.IsResourceCreationEnabled = true; + }); + siloBuilder.UseLocalhostClustering(); + } + else + { + var cosmosDbconnectionString = builder.Configuration.GetValue("AzureOptions:CosmosConnectionString"); + siloBuilder.Configure(options => + { + options.ClusterId = "ai-dev-cluster"; + options.ServiceId = "ai-dev-cluster"; + }); + siloBuilder.Configure(options => + { + options.ResponseTimeout = TimeSpan.FromMinutes(3); + options.SystemResponseTimeout = TimeSpan.FromMinutes(3); + }); + siloBuilder.Configure(options => + { + options.ResponseTimeout = TimeSpan.FromMinutes(3); + }); + siloBuilder.UseCosmosClustering( o => + { + o.ConfigureCosmosClient(cosmosDbconnectionString); + o.ContainerName = "devteam"; + o.DatabaseName = "clustering"; + o.IsResourceCreationEnabled = true; + }); + + siloBuilder.UseCosmosReminderService( o => + { + o.ConfigureCosmosClient(cosmosDbconnectionString); + o.ContainerName = "devteam"; + o.DatabaseName = "reminders"; + o.IsResourceCreationEnabled = true; + }); + siloBuilder.AddCosmosGrainStorage( + name: "messages", + configureOptions: o => + { + o.ConfigureCosmosClient(cosmosDbconnectionString); + o.ContainerName = "devteam"; + o.DatabaseName = "persistence"; + o.IsResourceCreationEnabled = true; + }); + } + }); - - - builder.Services.Configure(options => { options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; diff --git a/src/apps/gh-flow/Services/GithubWebHookProcessor.cs b/src/apps/gh-flow/Services/GithubWebHookProcessor.cs index c9fb7a703..f873b73c7 100644 --- a/src/apps/gh-flow/Services/GithubWebHookProcessor.cs +++ b/src/apps/gh-flow/Services/GithubWebHookProcessor.cs @@ -1,4 +1,5 @@ -using MS.AI.DevTeam; +using Microsoft.AI.DevTeam; +using Microsoft.AI.DevTeam.Skills; using Octokit.Webhooks; using Octokit.Webhooks.Events; using Octokit.Webhooks.Events.IssueComment; @@ -71,7 +72,7 @@ public sealed class GithubWebHookProcessor : WebhookEventProcessor { await HandleClosingDevPlan(issueNumber, suffix, org, repo); } - else if (skillName == nameof(Dev) && functionName == nameof(Dev.Implement)) + else if (skillName == nameof(Developer) && functionName == nameof(Developer.Implement)) { await HandleClosingDevImplement(issueNumber, suffix, org, repo); } @@ -206,7 +207,7 @@ public sealed class GithubWebHookProcessor : WebhookEventProcessor Content = plan }); } - else if (skillName == nameof(Dev) && functionName == nameof(Dev.Implement)) + else if (skillName == nameof(Developer) && functionName == nameof(Developer.Implement)) { var dev = _grains.GetGrain(issueNumber, suffix); var code = await dev.GenerateCode(input); diff --git a/src/apps/gh-flow/appsettings.template.json b/src/apps/gh-flow/appsettings.template.json new file mode 100644 index 000000000..78d23c1f2 --- /dev/null +++ b/src/apps/gh-flow/appsettings.template.json @@ -0,0 +1,41 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "ApplicationInsights": { + "ConnectionString": "" + }, + "AllowedHosts": "*", + "SANDBOX_IMAGE" : "mcr.microsoft.com/dotnet/sdk:7.0", + "GithubOptions" : { + "AppKey": "", + "AppId": "", + "InstallationId": "" + }, + "AzureOptions" : { + "SubscriptionId":"", + "Location":"", + "ContainerInstancesResourceGroup":"", + "FilesShareName":"", + "FilesAccountName":"", + "FilesAccountKey":"", + "CosmosConnectionString":"", + "SandboxImage" : "mcr.microsoft.com/dotnet/sdk:7.0", + "ManagedIdentity": "" + }, + "OpenAIOptions" : { + "ServiceType":"AzureOpenAI", + "ServiceId":"", + "DeploymentOrModelId":"", + "EmbeddingDeploymentOrModelId":"", + "Endpoint":"", + "ApiKey":"" + }, + "QdrantOptions" : { + "Endpoint" : "http://qdrant:6333", + "VectorSize" : "1536" + } +} diff --git a/src/apps/gh-flow/gh-flow.csproj b/src/apps/gh-flow/gh-flow.csproj index b81c957d3..f9716304a 100644 --- a/src/apps/gh-flow/gh-flow.csproj +++ b/src/apps/gh-flow/gh-flow.csproj @@ -1,23 +1,27 @@ - - - - - - - - net7.0 - enable - enable - - - - - - - - - - - - - + + + + + + + + net7.0 + enable + enable + true + true + c073c86e-8483-4956-942f-331fd09172d4 + + + + + + + + + + + + + + diff --git a/src/libs/Elsa.SemanticKernel/Activities/ActivityProviders/SemanticKernelSkillActivityProvider.cs b/src/libs/Elsa.SemanticKernel/Activities/ActivityProviders/SemanticKernelSkillActivityProvider.cs index c065dd7b0..a6d1ced74 100644 --- a/src/libs/Elsa.SemanticKernel/Activities/ActivityProviders/SemanticKernelSkillActivityProvider.cs +++ b/src/libs/Elsa.SemanticKernel/Activities/ActivityProviders/SemanticKernelSkillActivityProvider.cs @@ -1,32 +1,18 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; using System.Threading; using System.Threading.Tasks; -using Elsa; -using Elsa.Expressions.Models; using Elsa.Extensions; using Elsa.Workflows.Core; using Elsa.Workflows.Core.Contracts; using Elsa.Workflows.Core.Models; -using Elsa.Workflows.Management.Extensions; -using Elsa.Workflows.Core.Attributes; -using Elsa.Workflows.Core.Models; -using Elsa.Expressions.Models; -using Elsa.Extensions; -using Elsa.Http; +using Microsoft.AI.DevTeam.Skills; using Microsoft.Extensions.Logging; using Microsoft.SemanticKernel; -using Microsoft.SemanticKernel.Connectors.Memory.Qdrant; -using Microsoft.SemanticKernel.Connectors.AI.OpenAI.TextEmbedding; -using Microsoft.SemanticKernel.Memory; using Microsoft.SemanticKernel.Orchestration; -using Microsoft.SemanticKernel.Reliability; using Microsoft.SemanticKernel.SkillDefinition; -using Microsoft.SKDevTeam; namespace Elsa.SemanticKernel; diff --git a/src/libs/Elsa.SemanticKernel/Activities/SemanticKernel.cs b/src/libs/Elsa.SemanticKernel/Activities/SemanticKernel.cs index 1a9d0d387..4ba5f8cbc 100644 --- a/src/libs/Elsa.SemanticKernel/Activities/SemanticKernel.cs +++ b/src/libs/Elsa.SemanticKernel/Activities/SemanticKernel.cs @@ -5,23 +5,16 @@ using Elsa.Workflows.Core.Models; using JetBrains.Annotations; using Microsoft.Extensions.Logging; using Microsoft.SemanticKernel; -using Microsoft.SemanticKernel.Connectors.Memory.Qdrant; -using Microsoft.SemanticKernel.Connectors.AI.OpenAI.TextEmbedding; -using Microsoft.SemanticKernel.Memory; using Microsoft.SemanticKernel.Orchestration; -using Microsoft.SemanticKernel.Reliability; using Microsoft.SemanticKernel.SkillDefinition; -using Microsoft.SKDevTeam; using System; using System.Text; -using System.Collections; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; -using System.Threading; using System.Threading.Tasks; +using Microsoft.AI.DevTeam.Skills; namespace Elsa.SemanticKernel; diff --git a/src/libs/Elsa.SemanticKernel/Elsa.SemanticKernel.csproj b/src/libs/Elsa.SemanticKernel/Elsa.SemanticKernel.csproj index a5e6f77ef..c6f821073 100644 --- a/src/libs/Elsa.SemanticKernel/Elsa.SemanticKernel.csproj +++ b/src/libs/Elsa.SemanticKernel/Elsa.SemanticKernel.csproj @@ -23,7 +23,7 @@ - + diff --git a/src/libs/MS.AI.DevTeam/Actors/DevLead/DevLead.cs b/src/libs/MS.AI.DevTeam/Actors/DevLead/DevLead.cs deleted file mode 100644 index 8563a21b8..000000000 --- a/src/libs/MS.AI.DevTeam/Actors/DevLead/DevLead.cs +++ /dev/null @@ -1,47 +0,0 @@ -namespace MS.AI.DevTeam; - -public static class DevLead { - public static SemanticFunctionConfig Plan = new SemanticFunctionConfig - { - PromptTemplate = """ - You are a Dev Lead for an application team, building the application described below. - Please break down the steps and modules required to develop the complete application, describe each step in detail. - Make prescriptive architecture, language, and frameowrk choices, do not provide a range of choices. - For each step or module then break down the steps or subtasks required to complete that step or module. - For each subtask write an LLM prompt that would be used to tell a model to write the coee that will accomplish that subtask. If the subtask involves taking action/running commands tell the model to write the script that will run those commands. - In each LLM prompt restrict the model from outputting other text that is not in the form of code or code comments. - Please output a JSON array data structure, in the precise schema shown below, with a list of steps and a description of each step, and the steps or subtasks that each requires, and the LLM prompts for each subtask. - Example: - { - "steps": [ - { - "step": "1", - "description": "This is the first step", - "subtasks": [ - { - "subtask": "Subtask 1", - "description": "This is the first subtask", - "prompt": "Write the code to do the first subtask" - }, - { - "subtask": "Subtask 2", - "description": "This is the second subtask", - "prompt": "Write the code to do the second subtask" - } - ] - } - ] - } - Do not output any other text. - Input: {{$input}} - """, - Name = nameof(Plan), - SkillName = nameof(DevLead), - Description = "From a simple description of an application output a development plan for building the application.", - MaxTokens = 6500, - Temperature = 0.0, - TopP = 0.0, - PPenalty = 0.0, - FPenalty = 0.0 - }; -} \ No newline at end of file diff --git a/src/libs/MS.AI.DevTeam/Actors/Developer/Dev.cs b/src/libs/MS.AI.DevTeam/Actors/Developer/Dev.cs deleted file mode 100644 index 607d7842d..000000000 --- a/src/libs/MS.AI.DevTeam/Actors/Developer/Dev.cs +++ /dev/null @@ -1,45 +0,0 @@ -namespace MS.AI.DevTeam; - -public static class Dev { - public static SemanticFunctionConfig Implement = new SemanticFunctionConfig - { - PromptTemplate = """ - You are a Developer for an application. - Please output the code required to accomplish the task assigned to you below and wrap it in a bash script that creates the files. - Do not use any IDE commands and do not build and run the code. - Make specific choices about implementation. Do not offer a range of options. - Use comments in the code to describe the intent. Do not include other text other than code and code comments. - Input: {{$input}} - """, - Name = nameof(Implement), - SkillName = nameof(Developer), - Description = "From a description of a coding task out put the code or scripts necessary to complete the task.", - MaxTokens = 6500, - Temperature = 0.0, - TopP = 0.0, - PPenalty = 0.0, - FPenalty = 0.0 - }; - - public static SemanticFunctionConfig Improve = new SemanticFunctionConfig - { - PromptTemplate = """ - You are a Developer for an application. Your job is to imrove the code that you are given in the input below. - Please output a new version of code that fixes any problems with this version. - If there is an error message in the input you should fix that error in the code. - Wrap the code output up in a bash script that creates the necessary files by overwriting any previous files. - Do not use any IDE commands and do not build and run the code. - Make specific choices about implementation. Do not offer a range of options. - Use comments in the code to describe the intent. Do not include other text other than code and code comments. - Input: {{$input}} - """, - Name = nameof(Improve), - SkillName = nameof(Developer), - Description = "From a description of a coding task out put the code or scripts necessary to complete the task.", - MaxTokens = 6500, - Temperature = 0.0, - TopP = 0.0, - PPenalty = 0.0, - FPenalty = 0.0 - }; -} diff --git a/src/libs/MS.AI.DevTeam/Actors/ProductManager/PM.cs b/src/libs/MS.AI.DevTeam/Actors/ProductManager/PM.cs deleted file mode 100644 index 5eac53072..000000000 --- a/src/libs/MS.AI.DevTeam/Actors/ProductManager/PM.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace MS.AI.DevTeam; - -public static class PM -{ - public static SemanticFunctionConfig Readme = new SemanticFunctionConfig - { - PromptTemplate = """ - You are a program manager on a software development team. You are working on an app described below. - Based on the input below, and any dialog or other context, please output a raw README.MD markdown file documenting the main features of the app and the architecture or code organization. - Do not describe how to create the application. - Write the README as if it were documenting the features and architecture of the application. You may include instructions for how to run the application. - Input: {{$input}} - """, - Name = nameof(Readme), - SkillName = nameof(PM), - Description = "From a simple description output a README.md file for a GitHub repository.", - MaxTokens = 6500, - Temperature = 0.0, - TopP = 0.0, - PPenalty = 0.0, - FPenalty = 0.0 - }; -} diff --git a/src/libs/skills/Chat.cs b/src/libs/Microsoft.AI.DevTeam.Skills/Chat.cs similarity index 94% rename from src/libs/skills/Chat.cs rename to src/libs/Microsoft.AI.DevTeam.Skills/Chat.cs index da30e19b2..2f192a723 100644 --- a/src/libs/skills/Chat.cs +++ b/src/libs/Microsoft.AI.DevTeam.Skills/Chat.cs @@ -1,4 +1,4 @@ -namespace Microsoft.SKDevTeam; +namespace Microsoft.AI.DevTeam.Skills; public static class Chat { public static SemanticFunctionConfig ChatCompletion = new SemanticFunctionConfig diff --git a/src/libs/skills/CodeExplainer.cs b/src/libs/Microsoft.AI.DevTeam.Skills/CodeExplainer.cs similarity index 96% rename from src/libs/skills/CodeExplainer.cs rename to src/libs/Microsoft.AI.DevTeam.Skills/CodeExplainer.cs index d7e493c74..ffba6a71e 100644 --- a/src/libs/skills/CodeExplainer.cs +++ b/src/libs/Microsoft.AI.DevTeam.Skills/CodeExplainer.cs @@ -1,5 +1,5 @@ -namespace Microsoft.SKDevTeam; +namespace Microsoft.AI.DevTeam.Skills; public static class CodeExplainer { public static SemanticFunctionConfig Explain = new SemanticFunctionConfig { diff --git a/src/libs/skills/DevLead.cs b/src/libs/Microsoft.AI.DevTeam.Skills/DevLead.cs similarity index 98% rename from src/libs/skills/DevLead.cs rename to src/libs/Microsoft.AI.DevTeam.Skills/DevLead.cs index 86467c6aa..e325af3df 100644 --- a/src/libs/skills/DevLead.cs +++ b/src/libs/Microsoft.AI.DevTeam.Skills/DevLead.cs @@ -1,4 +1,4 @@ -namespace Microsoft.SKDevTeam; +namespace Microsoft.AI.DevTeam.Skills; public static class DevLead { public static SemanticFunctionConfig Plan = new SemanticFunctionConfig { diff --git a/src/libs/skills/Developer.cs b/src/libs/Microsoft.AI.DevTeam.Skills/Developer.cs similarity index 98% rename from src/libs/skills/Developer.cs rename to src/libs/Microsoft.AI.DevTeam.Skills/Developer.cs index 0d072ed56..9a1db00d6 100644 --- a/src/libs/skills/Developer.cs +++ b/src/libs/Microsoft.AI.DevTeam.Skills/Developer.cs @@ -1,5 +1,5 @@ -namespace Microsoft.SKDevTeam; +namespace Microsoft.AI.DevTeam.Skills; public static class Developer { public static SemanticFunctionConfig Implement = new SemanticFunctionConfig { diff --git a/src/libs/skills/skills.csproj b/src/libs/Microsoft.AI.DevTeam.Skills/Microsoft.AI.DevTeam.Skills.csproj similarity index 88% rename from src/libs/skills/skills.csproj rename to src/libs/Microsoft.AI.DevTeam.Skills/Microsoft.AI.DevTeam.Skills.csproj index 2cb017c9f..11eebbb3e 100644 --- a/src/libs/skills/skills.csproj +++ b/src/libs/Microsoft.AI.DevTeam.Skills/Microsoft.AI.DevTeam.Skills.csproj @@ -7,6 +7,6 @@ - + diff --git a/src/libs/skills/PM.cs b/src/libs/Microsoft.AI.DevTeam.Skills/PM.cs similarity index 97% rename from src/libs/skills/PM.cs rename to src/libs/Microsoft.AI.DevTeam.Skills/PM.cs index 2eaca6610..dd4dcb247 100644 --- a/src/libs/skills/PM.cs +++ b/src/libs/Microsoft.AI.DevTeam.Skills/PM.cs @@ -1,4 +1,4 @@ -namespace Microsoft.SKDevTeam; +namespace Microsoft.AI.DevTeam.Skills; public static class PM { public static SemanticFunctionConfig BootstrapProject = new SemanticFunctionConfig diff --git a/src/libs/MS.AI.DevTeam/Config/SemanticFunctionConfig.cs b/src/libs/Microsoft.AI.DevTeam.Skills/SemanticFunctionConfig.cs similarity index 76% rename from src/libs/MS.AI.DevTeam/Config/SemanticFunctionConfig.cs rename to src/libs/Microsoft.AI.DevTeam.Skills/SemanticFunctionConfig.cs index 1c61a8b0f..17a7ec8c3 100644 --- a/src/libs/MS.AI.DevTeam/Config/SemanticFunctionConfig.cs +++ b/src/libs/Microsoft.AI.DevTeam.Skills/SemanticFunctionConfig.cs @@ -1,7 +1,7 @@ using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.SkillDefinition; -namespace MS.AI.DevTeam; +namespace Microsoft.AI.DevTeam.Skills; public class SemanticFunctionConfig { @@ -17,11 +17,13 @@ public class SemanticFunctionConfig public static SemanticFunctionConfig ForSkillAndFunction(string skillName, string functionName) => (skillName, functionName) switch { + (nameof(Chat), nameof(Chat.ChatCompletion)) => Chat.ChatCompletion, + (nameof(PM), nameof(PM.BootstrapProject)) => PM.BootstrapProject, (nameof(PM), nameof(PM.Readme)) => PM.Readme, (nameof(DevLead), nameof(DevLead.Plan)) => DevLead.Plan, - // (nameof(CodeExplainer), nameof(CodeExplainer.Explain)) => CodeExplainer.Explain, - (nameof(Dev), nameof(Dev.Implement)) => Dev.Implement, - // (nameof(Developer), nameof(Developer.Improve)) => Developer.Improve, + (nameof(CodeExplainer), nameof(CodeExplainer.Explain)) => CodeExplainer.Explain, + (nameof(Developer), nameof(Developer.Implement)) => Developer.Implement, + (nameof(Developer), nameof(Developer.Improve)) => Developer.Improve, _ => throw new ArgumentException($"Unable to find {skillName}.{functionName}") }; } diff --git a/src/libs/MS.AI.DevTeam/Actors/Architect/Architect.cs b/src/libs/Microsoft.AI.DevTeam/Actors/Architect/Architect.cs similarity index 95% rename from src/libs/MS.AI.DevTeam/Actors/Architect/Architect.cs rename to src/libs/Microsoft.AI.DevTeam/Actors/Architect/Architect.cs index f12d90fe5..9b91239cf 100644 --- a/src/libs/MS.AI.DevTeam/Actors/Architect/Architect.cs +++ b/src/libs/Microsoft.AI.DevTeam/Actors/Architect/Architect.cs @@ -1,6 +1,6 @@ using Orleans.Runtime; -namespace MS.AI.DevTeam; +namespace Microsoft.AI.DevTeam; public class Architect : SemanticPersona, IArchitectSolutions { diff --git a/src/libs/MS.AI.DevTeam/Actors/Conductor/Conductor.cs b/src/libs/Microsoft.AI.DevTeam/Actors/Conductor/Conductor.cs similarity index 95% rename from src/libs/MS.AI.DevTeam/Actors/Conductor/Conductor.cs rename to src/libs/Microsoft.AI.DevTeam/Actors/Conductor/Conductor.cs index cae93b2ca..664e6b3ab 100644 --- a/src/libs/MS.AI.DevTeam/Actors/Conductor/Conductor.cs +++ b/src/libs/Microsoft.AI.DevTeam/Actors/Conductor/Conductor.cs @@ -1,7 +1,8 @@ +using Microsoft.AI.DevTeam.Skills; using Orleans.Concurrency; using Orleans.Runtime; -namespace MS.AI.DevTeam; +namespace Microsoft.AI.DevTeam; public class Conductor : Grain, IOrchestrateWorkflows { @@ -66,7 +67,7 @@ public class Conductor : Grain, IOrchestrateWorkflows { var issue = await _ghService.CreateIssue(new CreateIssueRequest { - Label = $"{nameof(Dev)}.{nameof(Dev.Implement)}", + Label = $"{nameof(Developer)}.{nameof(Developer.Implement)}", Org = org, Repo = repo, Input = prompt, diff --git a/src/libs/MS.AI.DevTeam/Actors/Conductor/IOrchestrateWorkflows.cs b/src/libs/Microsoft.AI.DevTeam/Actors/Conductor/IOrchestrateWorkflows.cs similarity index 90% rename from src/libs/MS.AI.DevTeam/Actors/Conductor/IOrchestrateWorkflows.cs rename to src/libs/Microsoft.AI.DevTeam/Actors/Conductor/IOrchestrateWorkflows.cs index b23349310..c8dbf8352 100644 --- a/src/libs/MS.AI.DevTeam/Actors/Conductor/IOrchestrateWorkflows.cs +++ b/src/libs/Microsoft.AI.DevTeam/Actors/Conductor/IOrchestrateWorkflows.cs @@ -1,6 +1,6 @@ using Orleans.Concurrency; -namespace MS.AI.DevTeam; +namespace Microsoft.AI.DevTeam; public interface IOrchestrateWorkflows : IGrainWithIntegerCompoundKey { diff --git a/src/libs/MS.AI.DevTeam/Actors/DevLead/DeveloperLead.cs b/src/libs/Microsoft.AI.DevTeam/Actors/DevLead/DeveloperLead.cs similarity index 95% rename from src/libs/MS.AI.DevTeam/Actors/DevLead/DeveloperLead.cs rename to src/libs/Microsoft.AI.DevTeam/Actors/DevLead/DeveloperLead.cs index 033187aa8..d7755d791 100644 --- a/src/libs/MS.AI.DevTeam/Actors/DevLead/DeveloperLead.cs +++ b/src/libs/Microsoft.AI.DevTeam/Actors/DevLead/DeveloperLead.cs @@ -1,9 +1,10 @@ +using Microsoft.AI.DevTeam.Skills; using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.Orchestration; using Orleans.Runtime; using System.Text.Json; -namespace MS.AI.DevTeam; +namespace Microsoft.AI.DevTeam; public class DeveloperLead : SemanticPersona, ILeadDevelopment { private readonly IKernel _kernel; @@ -31,6 +32,7 @@ public class DeveloperLead : SemanticPersona, ILeadDevelopment Order = _state.State.History.Count + 1, UserType = ChatUserType.User }); + await AddWafContext(_kernel, ask, context); context.Set("input", ask); var result = await _kernel.RunAsync(context, function); diff --git a/src/libs/MS.AI.DevTeam/Actors/DevLead/ILeadDevelopment.cs b/src/libs/Microsoft.AI.DevTeam/Actors/DevLead/ILeadDevelopment.cs similarity index 84% rename from src/libs/MS.AI.DevTeam/Actors/DevLead/ILeadDevelopment.cs rename to src/libs/Microsoft.AI.DevTeam/Actors/DevLead/ILeadDevelopment.cs index 18cf4f324..6799956c0 100644 --- a/src/libs/MS.AI.DevTeam/Actors/DevLead/ILeadDevelopment.cs +++ b/src/libs/Microsoft.AI.DevTeam/Actors/DevLead/ILeadDevelopment.cs @@ -1,4 +1,4 @@ -namespace MS.AI.DevTeam; +namespace Microsoft.AI.DevTeam; public interface ILeadDevelopment: IGrainWithIntegerCompoundKey, IChatHistory { diff --git a/src/libs/MS.AI.DevTeam/Actors/Developer/Developer.cs b/src/libs/Microsoft.AI.DevTeam/Actors/Developer/Developer.cs similarity index 60% rename from src/libs/MS.AI.DevTeam/Actors/Developer/Developer.cs rename to src/libs/Microsoft.AI.DevTeam/Actors/Developer/Developer.cs index c062a6d62..5991196c9 100644 --- a/src/libs/MS.AI.DevTeam/Actors/Developer/Developer.cs +++ b/src/libs/Microsoft.AI.DevTeam/Actors/Developer/Developer.cs @@ -1,43 +1,49 @@ +using Microsoft.AI.DevTeam.Skills; using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.Orchestration; using Orleans.Runtime; -namespace MS.AI.DevTeam; +namespace Microsoft.AI.DevTeam; -public class Developer : SemanticPersona, IDevelopCode +public class Dev : SemanticPersona, IDevelopCode { private readonly IKernel _kernel; protected override string MemorySegment => "dev-memory"; - public Developer(IKernel kernel, [PersistentState("state", "messages")]IPersistentState state) : base(state) + public Dev(IKernel kernel, [PersistentState("state", "messages")]IPersistentState state) : base(state) { _kernel = kernel; } public async Task GenerateCode(string ask) { - var function = _kernel.LoadFunction(nameof(Dev), nameof(Dev.Implement)); + var function = _kernel.LoadFunction(nameof(Developer), nameof(Developer.Implement)); var context = new ContextVariables(); if (_state.State.History == null) _state.State.History = new List(); - _state.State.History.Add(new ChatHistoryItem{ + _state.State.History.Add(new ChatHistoryItem + { Message = ask, - Order = _state.State.History.Count+1, + Order = _state.State.History.Count + 1, UserType = ChatUserType.User }); + await AddWafContext(_kernel, ask, context); context.Set("input", ask); var result = await _kernel.RunAsync(context, function); var resultMessage = result.ToString(); - _state.State.History.Add(new ChatHistoryItem{ + _state.State.History.Add(new ChatHistoryItem + { Message = resultMessage, - Order = _state.State.History.Count+1, + Order = _state.State.History.Count + 1, UserType = ChatUserType.Agent }); await _state.WriteStateAsync(); - + return resultMessage; } + + public Task ReviewPlan(string plan) { throw new NotImplementedException(); diff --git a/src/libs/MS.AI.DevTeam/Actors/Developer/IDevelopCode.cs b/src/libs/Microsoft.AI.DevTeam/Actors/Developer/IDevelopCode.cs similarity index 83% rename from src/libs/MS.AI.DevTeam/Actors/Developer/IDevelopCode.cs rename to src/libs/Microsoft.AI.DevTeam/Actors/Developer/IDevelopCode.cs index bafb81ac9..027fa0878 100644 --- a/src/libs/MS.AI.DevTeam/Actors/Developer/IDevelopCode.cs +++ b/src/libs/Microsoft.AI.DevTeam/Actors/Developer/IDevelopCode.cs @@ -1,4 +1,4 @@ -namespace MS.AI.DevTeam; +namespace Microsoft.AI.DevTeam; public interface IDevelopCode : IGrainWithIntegerCompoundKey, IChatHistory { diff --git a/src/libs/MS.AI.DevTeam/Actors/Lookup/ILookupMetadata.cs b/src/libs/Microsoft.AI.DevTeam/Actors/Lookup/ILookupMetadata.cs similarity index 83% rename from src/libs/MS.AI.DevTeam/Actors/Lookup/ILookupMetadata.cs rename to src/libs/Microsoft.AI.DevTeam/Actors/Lookup/ILookupMetadata.cs index 4bd1ba23c..e745035ae 100644 --- a/src/libs/MS.AI.DevTeam/Actors/Lookup/ILookupMetadata.cs +++ b/src/libs/Microsoft.AI.DevTeam/Actors/Lookup/ILookupMetadata.cs @@ -1,4 +1,4 @@ -namespace MS.AI.DevTeam; +namespace Microsoft.AI.DevTeam; public interface ILookupMetadata : IGrainWithStringKey { diff --git a/src/libs/MS.AI.DevTeam/Actors/Lookup/Lookup.cs b/src/libs/Microsoft.AI.DevTeam/Actors/Lookup/Lookup.cs similarity index 93% rename from src/libs/MS.AI.DevTeam/Actors/Lookup/Lookup.cs rename to src/libs/Microsoft.AI.DevTeam/Actors/Lookup/Lookup.cs index d4c19da43..09973b151 100644 --- a/src/libs/MS.AI.DevTeam/Actors/Lookup/Lookup.cs +++ b/src/libs/Microsoft.AI.DevTeam/Actors/Lookup/Lookup.cs @@ -1,6 +1,6 @@ using Orleans.Runtime; -namespace MS.AI.DevTeam; +namespace Microsoft.AI.DevTeam; public class Lookup : Grain, ILookupMetadata { diff --git a/src/libs/MS.AI.DevTeam/Actors/ProductManager/IManageProduct.cs b/src/libs/Microsoft.AI.DevTeam/Actors/ProductManager/IManageProduct.cs similarity index 79% rename from src/libs/MS.AI.DevTeam/Actors/ProductManager/IManageProduct.cs rename to src/libs/Microsoft.AI.DevTeam/Actors/ProductManager/IManageProduct.cs index 9cc36ac6e..e9ca51f83 100644 --- a/src/libs/MS.AI.DevTeam/Actors/ProductManager/IManageProduct.cs +++ b/src/libs/Microsoft.AI.DevTeam/Actors/ProductManager/IManageProduct.cs @@ -1,4 +1,4 @@ -namespace MS.AI.DevTeam; +namespace Microsoft.AI.DevTeam; public interface IManageProduct : IGrainWithIntegerCompoundKey, IChatHistory { diff --git a/src/libs/MS.AI.DevTeam/Actors/ProductManager/ProductManager.cs b/src/libs/Microsoft.AI.DevTeam/Actors/ProductManager/ProductManager.cs similarity index 92% rename from src/libs/MS.AI.DevTeam/Actors/ProductManager/ProductManager.cs rename to src/libs/Microsoft.AI.DevTeam/Actors/ProductManager/ProductManager.cs index e29051bb2..4f4bde3ca 100644 --- a/src/libs/MS.AI.DevTeam/Actors/ProductManager/ProductManager.cs +++ b/src/libs/Microsoft.AI.DevTeam/Actors/ProductManager/ProductManager.cs @@ -1,8 +1,9 @@ +using Microsoft.AI.DevTeam.Skills; using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.Orchestration; using Orleans.Runtime; -namespace MS.AI.DevTeam; +namespace Microsoft.AI.DevTeam; public class ProductManager : SemanticPersona, IManageProduct { private readonly IKernel _kernel; @@ -24,6 +25,7 @@ public class ProductManager : SemanticPersona, IManageProduct Order = _state.State.History.Count + 1, UserType = ChatUserType.User }); + await AddWafContext(_kernel, ask, context); context.Set("input", ask); var result = await _kernel.RunAsync(context, function); diff --git a/src/libs/MS.AI.DevTeam/Actors/Sandbox/IManageSandbox.cs b/src/libs/Microsoft.AI.DevTeam/Actors/Sandbox/IManageSandbox.cs similarity index 86% rename from src/libs/MS.AI.DevTeam/Actors/Sandbox/IManageSandbox.cs rename to src/libs/Microsoft.AI.DevTeam/Actors/Sandbox/IManageSandbox.cs index d874fb952..16614955f 100644 --- a/src/libs/MS.AI.DevTeam/Actors/Sandbox/IManageSandbox.cs +++ b/src/libs/Microsoft.AI.DevTeam/Actors/Sandbox/IManageSandbox.cs @@ -1,4 +1,4 @@ -namespace MS.AI.DevTeam; +namespace Microsoft.AI.DevTeam; public interface IManageSandbox : IGrainWithIntegerCompoundKey { diff --git a/src/libs/MS.AI.DevTeam/Actors/Sandbox/Sandbox.cs b/src/libs/Microsoft.AI.DevTeam/Actors/Sandbox/Sandbox.cs similarity index 95% rename from src/libs/MS.AI.DevTeam/Actors/Sandbox/Sandbox.cs rename to src/libs/Microsoft.AI.DevTeam/Actors/Sandbox/Sandbox.cs index 6a5f28675..68a90701d 100644 --- a/src/libs/MS.AI.DevTeam/Actors/Sandbox/Sandbox.cs +++ b/src/libs/Microsoft.AI.DevTeam/Actors/Sandbox/Sandbox.cs @@ -1,7 +1,7 @@ -namespace MS.AI.DevTeam; -using Orleans.Runtime; +using Orleans.Runtime; using Orleans.Timers; +namespace Microsoft.AI.DevTeam; public class Sandbox : Grain, IManageSandbox, IRemindable { private const string ReminderName = "SandboxRunReminder"; diff --git a/src/libs/MS.AI.DevTeam/Actors/SemanticPersona.cs b/src/libs/Microsoft.AI.DevTeam/Actors/SemanticPersona.cs similarity index 62% rename from src/libs/MS.AI.DevTeam/Actors/SemanticPersona.cs rename to src/libs/Microsoft.AI.DevTeam/Actors/SemanticPersona.cs index 0bfb88adf..1ae539ad8 100644 --- a/src/libs/MS.AI.DevTeam/Actors/SemanticPersona.cs +++ b/src/libs/Microsoft.AI.DevTeam/Actors/SemanticPersona.cs @@ -1,5 +1,9 @@ +using Microsoft.SemanticKernel; +using Microsoft.SemanticKernel.Orchestration; using Orleans.Runtime; +namespace Microsoft.AI.DevTeam; + public abstract class SemanticPersona : Grain, IChatHistory { public SemanticPersona( @@ -15,6 +19,18 @@ public abstract class SemanticPersona : Grain, IChatHistory { return _state.State.History.Last().Message; } + + protected async Task AddWafContext(IKernel kernel, string ask, ContextVariables context) + { + var interestingMemories = kernel.Memory.SearchAsync("waf-pages", ask, 2); + var wafContext = "Consider the following architectural guidelines:"; + await foreach (var memory in interestingMemories) + { + wafContext += $"\n {memory.Metadata.Text}"; + } + + context.Set("wafContext", wafContext); + } } public interface IChatHistory diff --git a/src/libs/MS.AI.DevTeam/Actors/Tester/Tester.cs b/src/libs/Microsoft.AI.DevTeam/Actors/Tester/Tester.cs similarity index 94% rename from src/libs/MS.AI.DevTeam/Actors/Tester/Tester.cs rename to src/libs/Microsoft.AI.DevTeam/Actors/Tester/Tester.cs index 0b7466a60..e44abac9b 100644 --- a/src/libs/MS.AI.DevTeam/Actors/Tester/Tester.cs +++ b/src/libs/Microsoft.AI.DevTeam/Actors/Tester/Tester.cs @@ -1,5 +1,7 @@ using Orleans.Runtime; +namespace Microsoft.AI.DevTeam; + public class Tester : SemanticPersona, ITestCode { public Tester( diff --git a/src/libs/MS.AI.DevTeam/MS.AI.DevTeam.csproj b/src/libs/Microsoft.AI.DevTeam/Microsoft.AI.DevTeam.csproj similarity index 86% rename from src/libs/MS.AI.DevTeam/MS.AI.DevTeam.csproj rename to src/libs/Microsoft.AI.DevTeam/Microsoft.AI.DevTeam.csproj index 1dfa8f6dd..b3c2a1dd6 100644 --- a/src/libs/MS.AI.DevTeam/MS.AI.DevTeam.csproj +++ b/src/libs/Microsoft.AI.DevTeam/Microsoft.AI.DevTeam.csproj @@ -19,4 +19,8 @@ + + + + diff --git a/src/libs/MS.AI.DevTeam/Options/AzureOptions.cs b/src/libs/Microsoft.AI.DevTeam/Options/AzureOptions.cs similarity index 89% rename from src/libs/MS.AI.DevTeam/Options/AzureOptions.cs rename to src/libs/Microsoft.AI.DevTeam/Options/AzureOptions.cs index 362b1f883..437e9a18a 100644 --- a/src/libs/MS.AI.DevTeam/Options/AzureOptions.cs +++ b/src/libs/Microsoft.AI.DevTeam/Options/AzureOptions.cs @@ -8,4 +8,5 @@ public class AzureOptions public string FilesAccountKey { get; set; } public string CosmosConnectionString { get; set; } public string SandboxImage { get; set; } + public string ManagedIdentity { get; set; } } \ No newline at end of file diff --git a/src/libs/MS.AI.DevTeam/Options/GithubOptions.cs b/src/libs/Microsoft.AI.DevTeam/Options/GithubOptions.cs similarity index 100% rename from src/libs/MS.AI.DevTeam/Options/GithubOptions.cs rename to src/libs/Microsoft.AI.DevTeam/Options/GithubOptions.cs diff --git a/src/libs/MS.AI.DevTeam/Options/OpenAIOptions.cs b/src/libs/Microsoft.AI.DevTeam/Options/OpenAIOptions.cs similarity index 100% rename from src/libs/MS.AI.DevTeam/Options/OpenAIOptions.cs rename to src/libs/Microsoft.AI.DevTeam/Options/OpenAIOptions.cs diff --git a/src/libs/MS.AI.DevTeam/Options/QdrantOptions.cs b/src/libs/Microsoft.AI.DevTeam/Options/QdrantOptions.cs similarity index 100% rename from src/libs/MS.AI.DevTeam/Options/QdrantOptions.cs rename to src/libs/Microsoft.AI.DevTeam/Options/QdrantOptions.cs diff --git a/src/libs/MS.AI.DevTeam/Services/AzureService.cs b/src/libs/Microsoft.AI.DevTeam/Services/AzureService.cs similarity index 93% rename from src/libs/MS.AI.DevTeam/Services/AzureService.cs rename to src/libs/Microsoft.AI.DevTeam/Services/AzureService.cs index a23d1e94d..5326c285e 100644 --- a/src/libs/MS.AI.DevTeam/Services/AzureService.cs +++ b/src/libs/Microsoft.AI.DevTeam/Services/AzureService.cs @@ -10,7 +10,7 @@ using Azure.Storage.Files.Shares; using Microsoft.Extensions.Options; -namespace MS.AI.DevTeam; +namespace Microsoft.AI.DevTeam; public class AzureService : IManageAzure { @@ -46,7 +46,10 @@ public class AzureService : IManageAzure public async Task RunInSandbox(SandboxRequest request) { - var client = new ArmClient(new DefaultAzureCredential()); + var client = string.IsNullOrEmpty(_azSettings.ManagedIdentity) ? + new ArmClient(new AzureCliCredential()) + : new ArmClient(new ManagedIdentityCredential(_azSettings.ManagedIdentity)); + var runId = $"sk-sandbox-{request.Org}-{request.Repo}-{request.ParentIssueNumber}-{request.IssueNumber}"; var resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(_azSettings.SubscriptionId, _azSettings.ContainerInstancesResourceGroup); var resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); diff --git a/src/libs/MS.AI.DevTeam/Services/GithubAuthService.cs b/src/libs/Microsoft.AI.DevTeam/Services/GithubAuthService.cs similarity index 97% rename from src/libs/MS.AI.DevTeam/Services/GithubAuthService.cs rename to src/libs/Microsoft.AI.DevTeam/Services/GithubAuthService.cs index 8bc01b88f..8752dcb97 100644 --- a/src/libs/MS.AI.DevTeam/Services/GithubAuthService.cs +++ b/src/libs/Microsoft.AI.DevTeam/Services/GithubAuthService.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Options; using Octokit; +namespace Microsoft.AI.DevTeam; public class GithubAuthService { private readonly GithubOptions _githubSettings; diff --git a/src/libs/MS.AI.DevTeam/Services/GithubService.cs b/src/libs/Microsoft.AI.DevTeam/Services/GithubService.cs similarity index 96% rename from src/libs/MS.AI.DevTeam/Services/GithubService.cs rename to src/libs/Microsoft.AI.DevTeam/Services/GithubService.cs index 5666e12f7..05d313caf 100644 --- a/src/libs/MS.AI.DevTeam/Services/GithubService.cs +++ b/src/libs/Microsoft.AI.DevTeam/Services/GithubService.cs @@ -6,7 +6,7 @@ using Octokit; using Octokit.Helpers; -namespace MS.AI.DevTeam; +namespace Microsoft.AI.DevTeam; public class GithubService : IManageGithub { diff --git a/src/libs/skills/SemanticFunctionConfig.cs b/src/libs/skills/SemanticFunctionConfig.cs deleted file mode 100644 index 300ef3b59..000000000 --- a/src/libs/skills/SemanticFunctionConfig.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace Microsoft.SKDevTeam; - -public class SemanticFunctionConfig -{ - public string PromptTemplate { get; set; } - public string Name { get; set; } - public string SkillName { get; set; } - public string Description { get; set; } - public int MaxTokens { get; set; } - public double Temperature { get; set; } - public double TopP { get; set; } - public double PPenalty { get; set; } - public double FPenalty { get; set; } - public static SemanticFunctionConfig ForSkillAndFunction(string skillName, string functionName) => - (skillName, functionName) switch - { - (nameof(Chat), nameof(Chat.ChatCompletion)) => Chat.ChatCompletion, - (nameof(PM), nameof(PM.BootstrapProject)) => PM.BootstrapProject, - (nameof(PM), nameof(PM.Readme)) => PM.Readme, - (nameof(DevLead), nameof(DevLead.Plan)) => DevLead.Plan, - (nameof(CodeExplainer), nameof(CodeExplainer.Explain)) => CodeExplainer.Explain, - (nameof(Developer), nameof(Developer.Implement)) => Developer.Implement, - (nameof(Developer), nameof(Developer.Improve)) => Developer.Improve, - _ => throw new ArgumentException($"Unable to find {skillName}.{functionName}") - }; -} \ No newline at end of file