From 9f437a51c76b2d22236f486dca0bf6d7697746a9 Mon Sep 17 00:00:00 2001 From: Jason Specland Date: Wed, 25 Oct 2023 10:40:25 -0400 Subject: [PATCH 1/6] made subscriptionId mandatory param --- deploy/infrastructure/cli/deploy.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deploy/infrastructure/cli/deploy.ps1 b/deploy/infrastructure/cli/deploy.ps1 index 13513e09..958eb095 100644 --- a/deploy/infrastructure/cli/deploy.ps1 +++ b/deploy/infrastructure/cli/deploy.ps1 @@ -2,7 +2,8 @@ param ( [string]$resourceGroupPrefix = "miyagi1", [string]$location = "eastus", [string]$resourceGroupCount = 1, - [string]$subscriptionId = "SubscriptionId is required" + [Parameter(Mandatory = $true)] + [string]$subscriptionId ) # print variables From 8230cdcf93da59870749aa55c4166c1a694c522a Mon Sep 17 00:00:00 2001 From: Jason Specland Date: Wed, 25 Oct 2023 10:48:13 -0400 Subject: [PATCH 2/6] made booleans into actual booleans --- deploy/infrastructure/cli/deploy.ps1 | 40 +++++++++++----------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/deploy/infrastructure/cli/deploy.ps1 b/deploy/infrastructure/cli/deploy.ps1 index 958eb095..2d183175 100644 --- a/deploy/infrastructure/cli/deploy.ps1 +++ b/deploy/infrastructure/cli/deploy.ps1 @@ -18,16 +18,16 @@ Write-Host "subscriptionId: $subscriptionId" $rgIndex = $resourceGroupCount # set all these to false the first time you run this script. After that you can set them to true to skip creating resources that already exist -$skipRg = "false" -$skipOpenAI = "false" -$skipEmbeddingModelDeployment = "false" -$skipCompletionModelDeployment = "false" -$skipcognitiveSearch = "false" -$skipCosmosDB = "false" -$skipBlobStorage = "false" -$skipAzureContainerApps = "false" -$skipAzureContainerRegistry = "false" -$skipAPIM = "false" +$skipRg = $false +$skipOpenAI = $false +$skipEmbeddingModelDeployment = $false +$skipCompletionModelDeployment = $false +$skipcognitiveSearch = $false +$skipCosmosDB = $false +$skipBlobStorage = $false +$skipAzureContainerApps = $false +$skipAzureContainerRegistry = $false +$skipAPIM = $false # strip - from resourceGroupPrefix @@ -36,7 +36,7 @@ $resourceGroupPrefix = $resourceGroupPrefix.Replace("-",""); # create resource groups in a loop for rgIndex # if skipRg is true, skip creating resource group -if ($skipRg -eq "true") { +if ($skipRg) { Write-Host "Skipping resource group creation" } else { @@ -90,7 +90,7 @@ for ($i = 1; $i -le $rgIndex; $i++) { # if skipCompletionModelDeployment is true, skip completion model deployment - if ($skipCompletionModelDeployment -eq "true") { + if ($skipCompletionModelDeployment) { Write-Host "Skipping completion model deployment" } else { @@ -111,7 +111,7 @@ for ($i = 1; $i -le $rgIndex; $i++) { # if skipCosmosDB is false, create CosmosDB account called miyagi with a container called recommendations - if ($skipCosmosDB -eq "true") { + if ($skipCosmosDB) { Write-Host "Skipping CosmosDB account creation" } else { @@ -144,7 +144,7 @@ for ($i = 1; $i -le $rgIndex; $i++) { # if skipBlobStorage is false, create blob storage account with a container called miyagi - if ($skipBlobStorage -eq "true") { + if ($skipBlobStorage) { Write-Host "Skipping blob storage account creation" } else { @@ -169,7 +169,7 @@ for ($i = 1; $i -le $rgIndex; $i++) { # if skipAzureContainerRegistry is false, create Azure Container Registry called miyagi - if ($skipAzureContainerRegistry -eq "true") { + if ($skipAzureContainerRegistry) { Write-Host "Skipping Azure Container Registry creation" } else { @@ -211,7 +211,7 @@ for ($i = 1; $i -le $rgIndex; $i++) { # if skipcognitiveSearch is false, create cognitive search service with semantic search capability - if ($skipcognitiveSearch -eq "true") { + if ($skipcognitiveSearch) { Write-Host "Skipping cognitive search service creation" } else { @@ -223,15 +223,7 @@ for ($i = 1; $i -le $rgIndex; $i++) { --template-file "bicep/search-service.bicep" ` --parameters "searchServiceName=$resourceGroupPrefix-acs-$i" - } - - - - - - - } From 446420803ded9504e2d2d843e1aff2cbe6e46d94 Mon Sep 17 00:00:00 2001 From: Jason Specland Date: Wed, 25 Oct 2023 12:28:01 -0400 Subject: [PATCH 3/6] generate unique suffixes for services that need it (blob storage, and container registry) --- deploy/infrastructure/cli/deploy.ps1 | 41 ++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/deploy/infrastructure/cli/deploy.ps1 b/deploy/infrastructure/cli/deploy.ps1 index 2d183175..eb376459 100644 --- a/deploy/infrastructure/cli/deploy.ps1 +++ b/deploy/infrastructure/cli/deploy.ps1 @@ -6,6 +6,22 @@ param ( [string]$subscriptionId ) +# Generate a unique suffix based on a hash of the subscription ID and the resource group, just like uniqueString() would do for ARM templates +# It delivers similar results but is *not* the exact hash that uniqueString() would deliver +function Get-UniqueString { + param($subscriptionId, $resourceGroup) + $hasher = [System.Security.Cryptography.HashAlgorithm]::Create('sha256') + $hash = $hasher.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($subscriptionId + "-" + $resourceGroup)) + $bytes = @() + for ($i = 1; $i -lt $hash.Length; $i++) { + $charByte = (($hash[$i] % 26) + [byte][char]'a') + $bytes = $bytes + $charByte + } + $uniqueSuffix = [System.Text.Encoding]::UTF8.GetString($bytes) + Write-Output $uniqueSuffix.Substring(0, [System.Math]::Min(13, $uniqueSuffix.Length)) +} + + # print variables Write-Host "resourceGroupPrefix: $resourceGroupPrefix" @@ -29,6 +45,7 @@ $skipAzureContainerApps = $false $skipAzureContainerRegistry = $false $skipAPIM = $false + # strip - from resourceGroupPrefix $resourceGroupPrefix = $resourceGroupPrefix.Replace("-",""); @@ -148,18 +165,24 @@ for ($i = 1; $i -le $rgIndex; $i++) { Write-Host "Skipping blob storage account creation" } else { + $resourceGroup = $resourceGroupPrefix + "-rg-" + $i + $uniqueSuffix = Get-UniqueString -subscriptionId $subscriptionId -resourceGroup $resourceGroup + + $storageaccount = -join($resourceGroupPrefix,"blobstorge",$i,$uniqueSuffix) - $storageaccount = -join($resourceGroupPrefix,"blobstorge",$i) - Write-Host "Creating blob storage account $storageaccount in $resourceGroupPrefix-rg-$i" + # Storage accounts can have a max of 24 characters. If the account name is longer than 24 characters, truncate it + $storageaccount = $storageaccount.Substring(0, [System.Math]::Min(24, $storageaccount.Length)) + + Write-Host "Creating blob storage account $storageaccount in $resourceGroup" az storage account create ` --name $storageaccount ` - --resource-group "$resourceGroupPrefix-rg-$i" ` + --resource-group $resourceGroup ` --location $location ` --sku "Standard_LRS" ` --subscription $subscriptionId - Write-Host "Creating blob storage container miyagi in $resourceGroupPrefix-rg-$i" + Write-Host "Creating blob storage container miyagi in $resourceGroup" az storage container create ` --name "miyagi" ` @@ -173,13 +196,15 @@ for ($i = 1; $i -le $rgIndex; $i++) { Write-Host "Skipping Azure Container Registry creation" } else { - - $containerregistry = -join($resourceGroupPrefix,"acr",$i) - Write-Host "Creating Azure Container Registry $containerregistry in $resourceGroupPrefix-rg-$i" + $resourceGroup = $resourceGroupPrefix + "-rg-" + $i + $uniqueSuffix = Get-UniqueString -subscriptionId $subscriptionId -resourceGroup $resourceGroup + + $containerregistry = -join($resourceGroupPrefix,"acr",$i,$uniqueSuffix) + Write-Host "Creating Azure Container Registry $containerregistry in $resourceGroup" az acr create ` --name $containerregistry ` - --resource-group "$resourceGroupPrefix-rg-$i" ` + --resource-group $resourceGroup ` --location $location ` --sku "Basic" ` --subscription $subscriptionId From ce45ad3eff797d41de0e471f29b53ce16cd31fac Mon Sep 17 00:00:00 2001 From: Jason Specland Date: Wed, 25 Oct 2023 12:49:20 -0400 Subject: [PATCH 4/6] container app creation uses the selected region --- deploy/infrastructure/cli/deploy.ps1 | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/deploy/infrastructure/cli/deploy.ps1 b/deploy/infrastructure/cli/deploy.ps1 index eb376459..f10a8296 100644 --- a/deploy/infrastructure/cli/deploy.ps1 +++ b/deploy/infrastructure/cli/deploy.ps1 @@ -222,16 +222,13 @@ for ($i = 1; $i -le $rgIndex; $i++) { az containerapp up --name $containerapp ` --resource-group "$resourceGroupPrefix-rg-$i" ` - --location centralus ` + --location $location ` --environment "$resourceGroupPrefix-env" ` --image mcr.microsoft.com/azuredocs/containerapps-helloworld:latest ` --target-port 80 ` --ingress external ` --query properties.configuration.ingress.fqdn ` - - - } # if skipcognitiveSearch is false, create cognitive search service with semantic search capability From 2eaba826b2f4dbdf2ad81c1ac8391966e53af218 Mon Sep 17 00:00:00 2001 From: Jason Specland Date: Thu, 26 Oct 2023 10:04:59 -0400 Subject: [PATCH 5/6] fixed string pretending to be a bool that I missed --- deploy/infrastructure/cli/deploy.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy/infrastructure/cli/deploy.ps1 b/deploy/infrastructure/cli/deploy.ps1 index f10a8296..58eb67b4 100644 --- a/deploy/infrastructure/cli/deploy.ps1 +++ b/deploy/infrastructure/cli/deploy.ps1 @@ -68,7 +68,7 @@ else { for ($i = 1; $i -le $rgIndex; $i++) { # if skipRg is true, skip creating resource group - if ($skipOpenAI -eq "true") { + if ($skipOpenAI) { Write-Host "Skipping OpenAI resource creation" } else { @@ -85,7 +85,7 @@ for ($i = 1; $i -le $rgIndex; $i++) { # if skipEmbeddingModelDeployment is true, skip embedding model deployment - if ($skipEmbeddingModelDeployment -eq "true") { + if ($skipEmbeddingModelDeployment) { Write-Host "Skipping embedding model deployment" } else { From 51a90d6cf58b79abbd1ca77437766b771ae291dd Mon Sep 17 00:00:00 2001 From: ajai-d <106365942+ajai-d@users.noreply.github.com> Date: Fri, 27 Oct 2023 15:21:47 -0500 Subject: [PATCH 6/6] Revert "Merge pull request #161 from Azure-Samples/main" This reverts commit d819aeefd289992acdc8cde9316d74c0e2fbd24c, reversing changes made to 5820d73712c4dcbb51b0082c113afdf1b7449603. --- sandbox/ais/logic-apps/auto-invest.json | 389 ------------------ .../sk-copilot-chat-api/dotnet/global.json | 7 - .../dotnet/memorypipeline/appsettings.json | 12 +- .../dotnet/webapi/.gitignore | 2 - ui/typescript/app/chat-session/route.ts | 5 +- .../app/chatSession/getAllChats/route.ts | 5 +- ui/typescript/package.json | 1 - .../src/components/chat/chat-session-list.tsx | 14 +- ui/typescript/src/data/static/chats.tsx | 2 +- ui/typescript/src/data/static/user-info.tsx | 1 - .../src/layouts/sidebar/chat-blade.tsx | 21 +- ui/typescript/src/types/index.ts | 2 +- ui/typescript/yarn.lock | 5 - 13 files changed, 32 insertions(+), 434 deletions(-) delete mode 100644 sandbox/ais/logic-apps/auto-invest.json delete mode 100644 services/sk-copilot-chat-api/dotnet/global.json diff --git a/sandbox/ais/logic-apps/auto-invest.json b/sandbox/ais/logic-apps/auto-invest.json deleted file mode 100644 index c99155ab..00000000 --- a/sandbox/ais/logic-apps/auto-invest.json +++ /dev/null @@ -1,389 +0,0 @@ -{ - "definition": { - "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", - "actions": { - "Check_if_NYSE_and_NASDAQ_are_open": { - "type": "Response", - "kind": "Http", - "inputs": { - "statusCode": 200 - }, - "runAfter": {} - }, - "Az_Function_with_Semantic_Kernel_and_Cog_Search_to_invoke_LLM": { - "type": "Function", - "inputs": { - "method": "", - "function": { - "connectionName": "" - } - }, - "runAfter": { - "Populate_prompt_template_with_structured_data": [ - "SUCCEEDED" - ] - } - }, - "Populate_prompt_template_with_structured_data": { - "type": "Join", - "inputs": { - "from": "", - "joinWith": "" - }, - "runAfter": { - "Open_for_trading": [ - "SUCCEEDED" - ] - } - }, - "Validate_LLM_JSON": { - "type": "ParseJson", - "inputs": { - "content": "", - "schema": "" - }, - "runAfter": { - "Az_Function_with_Semantic_Kernel_and_Cog_Search_to_invoke_LLM": [ - "SUCCEEDED" - ] - } - }, - "Fallback_and_retry": { - "type": "If", - "expression": { - "and": [ - { - "equals": [ - "", - "" - ] - } - ] - }, - "actions": { - "Retry_logic": { - "type": "Workflow", - "inputs": { - "host": { - "workflow": { - "id": "" - } - } - } - } - }, - "else": { - "actions": { - "Log": { - "type": "JavaScriptCode", - "inputs": { - "code": "" - } - } - } - }, - "runAfter": { - "Validate_LLM_JSON": [ - "FAILED", - "TIMEDOUT" - ] - } - }, - "Send_user_approval_email": { - "type": "ServiceProvider", - "inputs": { - "parameters": { - "from": "", - "to": "", - "importance": "Normal" - }, - "serviceProviderConfiguration": { - "connectionName": "", - "operationId": "sendEmail", - "serviceProviderId": "/serviceProviders/Smtp" - } - }, - "runAfter": { - "Validate_LLM_JSON": [ - "SUCCEEDED" - ] - } - }, - "When_a_new_email_arrives_(V3)": { - "type": "ApiConnectionNotification", - "inputs": { - "host": { - "connection": { - "referenceName": null - } - }, - "fetch": { - "pathTemplate": { - "template": "/v3/Mail/OnNewEmail" - }, - "method": "get", - "queries": { - "importance": "Any", - "fetchOnlyWithAttachment": false, - "includeAttachments": false, - "folderPath": "Inbox" - } - }, - "subscribe": { - "body": { - "NotificationUrl": "@{listCallbackUrl()}" - }, - "pathTemplate": { - "template": "/GraphMailSubscriptionPoke/$subscriptions" - }, - "method": "post", - "queries": { - "importance": "Any", - "fetchOnlyWithAttachment": false, - "folderPath": "Inbox" - } - } - }, - "runAfter": {} - }, - "Parse_for_approval": { - "type": "InvokeFunction", - "inputs": { - "functionName": "" - }, - "runAfter": { - "When_a_new_email_arrives_(V3)": [ - "SUCCEEDED" - ] - } - }, - "If_approved": { - "type": "Scope", - "actions": { - "Service_Bus_-_start_transaction_to_place_a_trade": { - "type": "ServiceProvider", - "inputs": { - "parameters": { - "entityName": "" - }, - "serviceProviderConfiguration": { - "connectionName": "", - "operationId": "sendMessage", - "serviceProviderId": "/serviceProviders/serviceBus" - } - } - } - }, - "runAfter": { - "Parse_for_approval": [ - "SUCCEEDED" - ] - } - }, - "If_denied_or_replied_with_no": { - "type": "Scope", - "actions": { - "Call_a_local_function_in_this_logic_app_1": { - "type": "InvokeFunction", - "inputs": { - "functionName": "" - } - } - }, - "runAfter": { - "Parse_for_approval": [ - "SUCCEEDED" - ], - "When_a_new_email_arrives_(V3)": [ - "SUCCEEDED" - ] - } - }, - "Open_for_trading": { - "type": "Scope", - "actions": { - "Get_user_preferences_from_existing_API": { - "type": "Response", - "kind": "Http", - "inputs": { - "statusCode": 200 - } - }, - "Transform_request": { - "type": "Xslt", - "kind": "DataMapper", - "inputs": { - "content": "", - "map": { - "source": "LogicApp", - "name": "" - } - }, - "runAfter": { - "Get_user_preferences_from_existing_API": [ - "SUCCEEDED" - ] - } - }, - "Get_stock_investment_thesis": { - "type": "ServiceProvider", - "inputs": { - "parameters": { - "databaseId": "adsf", - "containerId": "asdf", - "queryText": "asdf" - }, - "serviceProviderConfiguration": { - "connectionName": "AzureCosmosDB", - "operationId": "QueryDocuments", - "serviceProviderId": "/serviceProviders/AzureCosmosDB" - } - } - }, - "Current_portfolio_allocation_(SQL)": { - "type": "ApiConnection", - "inputs": { - "host": { - "connection": { - "referenceName": "sql-2" - } - }, - "method": "post", - "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('rty'))},@{encodeURIComponent(encodeURIComponent('rty'))}/query/sql" - } - }, - "Bing_-_Get_company_financial_news": { - "type": "ApiConnection", - "inputs": { - "host": { - "connection": { - "referenceName": "bingsearch" - } - }, - "method": "get", - "path": "/news/search", - "queries": { - "q": "SDF", - "mkt": "en-US", - "safeSearch": "Moderate", - "count": "20" - } - } - }, - "Mainframe_lookup_-_customer_info": { - "type": "ApiConnection", - "inputs": { - "host": { - "connection": { - "referenceName": "kyndrylmainframe" - } - }, - "method": "get", - "path": "/customernumber/custnum/@{encodeURIComponent('34')}" - } - }, - "Transform_XML": { - "type": "Xslt", - "inputs": { - "content": "", - "map": { - "source": "LogicApp", - "name": "" - } - }, - "runAfter": { - "Mainframe_lookup_-_customer_info": [ - "SUCCEEDED" - ] - } - }, - "JSON_to_text": { - "type": "ParseJson", - "inputs": { - "content": "asdf", - "schema": {} - }, - "runAfter": { - "Bing_-_Get_company_financial_news": [ - "SUCCEEDED" - ] - } - } - }, - "runAfter": { - "Check_if_NYSE_and_NASDAQ_are_open": [ - "SUCCEEDED" - ] - } - } - }, - "contentVersion": "1.0.0.0", - "outputs": {}, - "triggers": { - "Every_weekend_2_hours_after_stock_market_opens": { - "type": "Batch", - "inputs": { - "mode": "Inline", - "configurations": { - "auto-invest": { - "releaseCriteria": { - "recurrence": {} - } - } - } - } - } - } - }, - "connectionReferences": { - "AzureCosmosDB": { - "api": { - "id": "/serviceProviders/AzureCosmosDB" - }, - "connection": { - "id": "/serviceProviders/AzureCosmosDB/connections/AzureCosmosDB" - }, - "connectionName": "AzureCosmosDB", - "authentication": { - "type": "ManagedServiceIdentity" - } - }, - "sql-2": { - "api": { - "id": "/subscriptions/a6029ed2-6d00-4f88-a6a1-5fc071aa5ee7/providers/Microsoft.Web/locations/southcentralus/managedApis/sql" - }, - "connection": { - "id": "/subscriptions/a6029ed2-6d00-4f88-a6a1-5fc071aa5ee7/resourceGroups/miyagi/providers/Microsoft.Web/connections/sql" - }, - "connectionName": "sql", - "authentication": { - "type": "ManagedServiceIdentity" - } - }, - "bingsearch": { - "api": { - "id": "/subscriptions/a6029ed2-6d00-4f88-a6a1-5fc071aa5ee7/providers/Microsoft.Web/locations/southcentralus/managedApis/bingsearch" - }, - "connection": { - "id": "/subscriptions/a6029ed2-6d00-4f88-a6a1-5fc071aa5ee7/resourceGroups/miyagi/providers/Microsoft.Web/connections/bingsearch" - }, - "connectionName": "bingsearch", - "authentication": { - "type": "ManagedServiceIdentity" - } - }, - "kyndrylmainframe": { - "api": { - "id": "/subscriptions/a6029ed2-6d00-4f88-a6a1-5fc071aa5ee7/providers/Microsoft.Web/locations/southcentralus/managedApis/kyndrylmainframe" - }, - "connection": { - "id": "/subscriptions/a6029ed2-6d00-4f88-a6a1-5fc071aa5ee7/resourceGroups/miyagi/providers/Microsoft.Web/connections/kyndrylmainframe" - }, - "connectionName": "kyndrylmainframe", - "authentication": { - "type": "ManagedServiceIdentity" - } - } - }, - "parameters": {} - } \ No newline at end of file diff --git a/services/sk-copilot-chat-api/dotnet/global.json b/services/sk-copilot-chat-api/dotnet/global.json deleted file mode 100644 index dad2db5e..00000000 --- a/services/sk-copilot-chat-api/dotnet/global.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "sdk": { - "version": "8.0.0", - "rollForward": "latestMajor", - "allowPrerelease": true - } -} \ No newline at end of file diff --git a/services/sk-copilot-chat-api/dotnet/memorypipeline/appsettings.json b/services/sk-copilot-chat-api/dotnet/memorypipeline/appsettings.json index d4bc002c..4f14c9ef 100644 --- a/services/sk-copilot-chat-api/dotnet/memorypipeline/appsettings.json +++ b/services/sk-copilot-chat-api/dotnet/memorypipeline/appsettings.json @@ -43,7 +43,7 @@ // - EmbeddingGeneratorType: Embedding generator configuration: "AzureOpenAIEmbedding" or "OpenAI" // "Retrieval": { - "VectorDbType": "AzureCognitiveSearch", + "VectorDbType": "SimpleVectorDb", "EmbeddingGeneratorType": "AzureOpenAIEmbedding" }, // @@ -125,7 +125,7 @@ "AzureCognitiveSearch": { "Auth": "ApiKey", //"APIKey": "", // dotnet user-secrets set "SemanticMemory:Services:AzureCognitiveSearch:APIKey" "MY_ACS_KEY" - "Endpoint": "https://gk-miyagi-acs.search.windows.net" + "Endpoint": "" }, // // Qdrant configuration for semantic services. @@ -148,8 +148,8 @@ "AzureOpenAIText": { "Auth": "ApiKey", //"APIKey": "", // dotnet user-secrets set "SemanticMemory:Services:AzureOpenAIText:APIKey" "MY_AZUREOPENAI_KEY" - "Endpoint": "https://gk-ca-gpt4.openai.azure.com/", - "Deployment": "gk-gpt4-32k", + "Endpoint": "", + "Deployment": "gpt-35-turbo", "APIType": "ChatCompletion", "MaxRetries": 10 }, @@ -163,8 +163,8 @@ "AzureOpenAIEmbedding": { "Auth": "ApiKey", // "APIKey": "", // dotnet user-secrets set "SemanticMemory:Services:AzureOpenAIEmbedding:APIKey" "MY_AZUREOPENAI_KEY" - "Endpoint": "https://gk-ca-gpt4.openai.azure.com/", - "Deployment": "gk-ada" + "Endpoint": ".openai.azure.com/", + "Deployment": "text-embedding-ada-002" }, // // AI completion and embedding configuration for OpenAI services. diff --git a/services/sk-copilot-chat-api/dotnet/webapi/.gitignore b/services/sk-copilot-chat-api/dotnet/webapi/.gitignore index 317906e3..14a711e8 100644 --- a/services/sk-copilot-chat-api/dotnet/webapi/.gitignore +++ b/services/sk-copilot-chat-api/dotnet/webapi/.gitignore @@ -23,8 +23,6 @@ bld/ [Bb]in/ [Oo]bj/ [Ll]og/ -tmp-cache/ -tmp-database/ # Visual Studio 2015 cache/options directory .vs/ diff --git a/ui/typescript/app/chat-session/route.ts b/ui/typescript/app/chat-session/route.ts index 9dd9a03f..70b46ecf 100644 --- a/ui/typescript/app/chat-session/route.ts +++ b/ui/typescript/app/chat-session/route.ts @@ -3,13 +3,14 @@ import { NextResponse } from 'next/server'; export async function GET(request: Request) { const { searchParams } = new URL(request.url); const userId = searchParams.get('userId'); - const RECCOMMENDATION_SERVICE_URL = `${process.env.NEXT_PUBLIC_COPILOT_CHAT_BASE_URL}/chats` + const RECCOMMENDATION_SERVICE_URL = `${process.env.NEXT_PUBLIC_COPILOT_CHAT_BASE_URL}/chatSession/getAllChats/${userId}` console.log("Request body: "); console.dir(userId) const res = await fetch(RECCOMMENDATION_SERVICE_URL, { method: 'POST', headers: { - 'Content-type': `application/json` + 'Content-type': `application/json`, + 'x-sk-api-key': `${process.env.NEXT_PUBLIC_SK_API_KEY}` } }); diff --git a/ui/typescript/app/chatSession/getAllChats/route.ts b/ui/typescript/app/chatSession/getAllChats/route.ts index 9dd9a03f..70b46ecf 100644 --- a/ui/typescript/app/chatSession/getAllChats/route.ts +++ b/ui/typescript/app/chatSession/getAllChats/route.ts @@ -3,13 +3,14 @@ import { NextResponse } from 'next/server'; export async function GET(request: Request) { const { searchParams } = new URL(request.url); const userId = searchParams.get('userId'); - const RECCOMMENDATION_SERVICE_URL = `${process.env.NEXT_PUBLIC_COPILOT_CHAT_BASE_URL}/chats` + const RECCOMMENDATION_SERVICE_URL = `${process.env.NEXT_PUBLIC_COPILOT_CHAT_BASE_URL}/chatSession/getAllChats/${userId}` console.log("Request body: "); console.dir(userId) const res = await fetch(RECCOMMENDATION_SERVICE_URL, { method: 'POST', headers: { - 'Content-type': `application/json` + 'Content-type': `application/json`, + 'x-sk-api-key': `${process.env.NEXT_PUBLIC_SK_API_KEY}` } }); diff --git a/ui/typescript/package.json b/ui/typescript/package.json index 296c530f..52007188 100644 --- a/ui/typescript/package.json +++ b/ui/typescript/package.json @@ -27,7 +27,6 @@ "js-cookie": "^3.0.1", "little-state-machine": "^4.8.0", "lodash": "^4.17.21", - "moment": "^2.29.4", "next": "^13.3.0", "next-pwa": "^5.6.0", "next-seo": "^6.0.0", diff --git a/ui/typescript/src/components/chat/chat-session-list.tsx b/ui/typescript/src/components/chat/chat-session-list.tsx index 16598e7b..2b9c626f 100644 --- a/ui/typescript/src/components/chat/chat-session-list.tsx +++ b/ui/typescript/src/components/chat/chat-session-list.tsx @@ -16,12 +16,13 @@ export function ChatSessionList({ className, setSelectedSession: updateSelectedS useEffect(() => { async function fetchChatSessions() { - const chatSessionUrl = `${process.env.NEXT_PUBLIC_COPILOT_CHAT_BASE_URL}/chats/${userInfo.chatId}/messages`; + const chatSessionUrl = `${process.env.NEXT_PUBLIC_COPILOT_CHAT_BASE_URL}/chatSession/getAllChats/${userInfo.userName}`; console.log(chatSessionUrl); const response = await fetch(chatSessionUrl, { method: 'GET', headers: { - 'Content-type': `application/json` + 'Content-type': `application/json`, + 'x-sk-api-key': `${process.env.NEXT_PUBLIC_SK_API_KEY}` } }); const data = await response.json(); @@ -34,11 +35,12 @@ export function ChatSessionList({ className, setSelectedSession: updateSelectedS }, []); async function fetchChatMessages(chatId: string) { - const chatMsgEndpoint = `${process.env.NEXT_PUBLIC_COPILOT_CHAT_BASE_URL}/chats/${chatId}/messages?startIdx=0&count=-1` + const chatMsgEndpoint = `${process.env.NEXT_PUBLIC_COPILOT_CHAT_BASE_URL}/chatSession/getChatMessages/${chatId}?startIdx=0&count=-1` const response = await fetch(chatMsgEndpoint, { method: 'GET', headers: { - 'Content-type': `application/json` + 'Content-type': `application/json`, + 'x-sk-api-key': `${process.env.NEXT_PUBLIC_SK_API_KEY}` } }); const data = await response.json(); @@ -50,11 +52,11 @@ export function ChatSessionList({ className, setSelectedSession: updateSelectedS setSelectedSession(currentSession); console.log("Selected current session"); console.dir(currentSession); - await fetchChatMessages(currentSession.chatId || `${process.env.NEXT_PUBLIC_COPILOT_CHAT_BASE_URL}`); + await fetchChatMessages(currentSession.id || `${process.env.NEXT_PUBLIC_COPILOT_CHAT_BASE_URL}`); setUserInfoAtom((prevUserInfo: UserInfoProps) => ({ // Add type to prevUserInfo ...prevUserInfo, - chatId: currentSession.chatId || `${process.env.NEXT_PUBLIC_COPILOT_CHAT_BASE_URL}`, + chatId: currentSession.id || `${process.env.NEXT_PUBLIC_COPILOT_CHAT_BASE_URL}`, })); } diff --git a/ui/typescript/src/data/static/chats.tsx b/ui/typescript/src/data/static/chats.tsx index 4837e616..e557aa8f 100644 --- a/ui/typescript/src/data/static/chats.tsx +++ b/ui/typescript/src/data/static/chats.tsx @@ -6,6 +6,6 @@ export const Chats = [ userId: 'bot', userName: 'bot', chatId: '', - messageType: "1" + authorRole: 1 } ] \ No newline at end of file diff --git a/ui/typescript/src/data/static/user-info.tsx b/ui/typescript/src/data/static/user-info.tsx index ba9c3dca..f471a074 100644 --- a/ui/typescript/src/data/static/user-info.tsx +++ b/ui/typescript/src/data/static/user-info.tsx @@ -6,7 +6,6 @@ export const UserInfo = { "firstName": "Govind", "lastName": "Kamtamneni", "age": 50, - "messageType": "0", "riskLevel": "aggressive", "annualHouseholdIncome": 80000, "favoriteBook": "intelligent-investor", diff --git a/ui/typescript/src/layouts/sidebar/chat-blade.tsx b/ui/typescript/src/layouts/sidebar/chat-blade.tsx index 0c36ccb7..36a6984b 100644 --- a/ui/typescript/src/layouts/sidebar/chat-blade.tsx +++ b/ui/typescript/src/layouts/sidebar/chat-blade.tsx @@ -7,9 +7,7 @@ import { useAtom } from "jotai"; import { chatsAtom, userInfoAtom, chatSessionsAtom } from "@/data/personalize/store"; import { ChatSessionList } from "@/components/chat/chat-session-list"; import Button from "@/components/ui/button"; - import React, { useState } from "react"; -import moment from "moment"; type Variable = { key: string; @@ -65,7 +63,7 @@ export default function Sidebar({ className, setSelectedSession, setUserInfoAtom userId: userInfo.userId, userName: userInfo.userName, chatId: userInfo.chatId, - messageType: "0", + authorRole: 0, }; // Update chatsAtom with the user's message first @@ -81,15 +79,17 @@ export default function Sidebar({ className, setSelectedSession, setUserInfoAtom }); - const response = await fetch(`${process.env.NEXT_PUBLIC_COPILOT_CHAT_BASE_URL}/chats/${userInfo.chatId}/messages`, { + const response = await fetch(`${process.env.NEXT_PUBLIC_COPILOT_CHAT_BASE_URL}/skills/ChatSkill/functions/Chat/invoke`, { method: 'POST', headers: { - 'Content-type': `application/json` + 'Content-type': `application/json`, + 'x-sk-api-key': `${process.env.NEXT_PUBLIC_SK_API_KEY}` }, body: JSON.stringify({ input: userInput, variables: [ - { key: 'messageType', value: userInfo.messageType }, + { key: 'userId', value: userInfo.userId }, + { key: 'userName', value: userInfo.userName }, { key: 'chatId', value: userInfo.chatId }, ], }), @@ -111,27 +111,26 @@ export default function Sidebar({ className, setSelectedSession, setUserInfoAtom userId: "bot", userName: "bot", chatId: userInfo.chatId, - messageType: "1", + authorRole: 1, }, ]; }); } - const currentTimestamp = moment().format('MM/DD/YYYY, h:mm:ss A'); - const titleWithTimestamp = `Miyagi chat @ ${currentTimestamp}`; async function createNewChatSession() { setLoading(true); const response = await fetch( - `${process.env.NEXT_PUBLIC_COPILOT_CHAT_BASE_URL}/chats`, + "${process.env.COPILOT_CHAT_BASE_URL}/chatSession/create", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ - title: titleWithTimestamp, + userId: userInfo.userId, + title: "New Chat Session", }), } ); diff --git a/ui/typescript/src/types/index.ts b/ui/typescript/src/types/index.ts index 0009a7ce..c13a488b 100644 --- a/ui/typescript/src/types/index.ts +++ b/ui/typescript/src/types/index.ts @@ -3,7 +3,7 @@ import type { ReactElement, ReactNode } from 'react'; export type ChatProps = { id: string; - messageType: string; + authorRole: number; content: string; timestamp: string; userId: string; diff --git a/ui/typescript/yarn.lock b/ui/typescript/yarn.lock index 2c4a5199..49b0550e 100644 --- a/ui/typescript/yarn.lock +++ b/ui/typescript/yarn.lock @@ -3986,11 +3986,6 @@ minipass@^5.0.0: resolved "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz" integrity sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ== -moment@^2.29.4: - version "2.29.4" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108" - integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w== - ms@2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz"