diff --git a/deploy/infrastructure/cli/deploy.ps1 b/deploy/infrastructure/cli/deploy.ps1 index 13513e09..58eb67b4 100644 --- a/deploy/infrastructure/cli/deploy.ps1 +++ b/deploy/infrastructure/cli/deploy.ps1 @@ -2,9 +2,26 @@ param ( [string]$resourceGroupPrefix = "miyagi1", [string]$location = "eastus", [string]$resourceGroupCount = 1, - [string]$subscriptionId = "SubscriptionId is required" + [Parameter(Mandatory = $true)] + [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" @@ -17,16 +34,17 @@ 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 @@ -35,7 +53,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 { @@ -50,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 { @@ -67,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 { @@ -89,7 +107,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 { @@ -110,7 +128,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 { @@ -143,22 +161,28 @@ 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 { + $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" ` @@ -168,17 +192,19 @@ 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 { - - $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 @@ -196,21 +222,18 @@ 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 - if ($skipcognitiveSearch -eq "true") { + if ($skipcognitiveSearch) { Write-Host "Skipping cognitive search service creation" } else { @@ -222,15 +245,7 @@ for ($i = 1; $i -le $rgIndex; $i++) { --template-file "bicep/search-service.bicep" ` --parameters "searchServiceName=$resourceGroupPrefix-acs-$i" - } - - - - - - - } 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/layouts/sidebar/chat-blade.tsx b/ui/typescript/src/layouts/sidebar/chat-blade.tsx index 4ab710e5..cd94d0f2 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; @@ -81,10 +79,11 @@ 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, @@ -118,20 +117,19 @@ export default function Sidebar({ className, setSelectedSession, setUserInfoAtom } - 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/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"