diff --git a/.github/workflows/azure-dev-validate.yml b/.github/workflows/azure-dev-validate.yml index 7d5cef141..a537b8008 100644 --- a/.github/workflows/azure-dev-validate.yml +++ b/.github/workflows/azure-dev-validate.yml @@ -4,11 +4,11 @@ on: push: branches: - main - - master + - oct-update pull_request: branches: - main - - master + - oct-update jobs: build: @@ -19,9 +19,13 @@ jobs: uses: actions/checkout@v3 - name: Build Bicep for linting - uses: azure/CLI@v1 + uses: azure/cli@v2 with: - inlineScript: az config set bicep.use_binary_from_path=false && az bicep build -f infra/main.bicep --stdout + azcliversion: 2.64.0 + inlineScript: | + tdnf install -y icu + tdnf install -y jq + az config set bicep.use_binary_from_path=false && az bicep build -f infra/main.bicep --stdout - name: Run Microsoft Security DevOps Analysis uses: microsoft/security-devops-action@preview diff --git a/.github/workflows/open-ai-app.yml b/.github/workflows/open-ai-app.yml index 08fdd810a..58500d51b 100644 --- a/.github/workflows/open-ai-app.yml +++ b/.github/workflows/open-ai-app.yml @@ -4,9 +4,9 @@ name: Build & deploy Next.js app to Azure Web App on: # Automatically trigger it when detected changes in repo push: - branches: [main] + branches: + - main - # Allow manual workflow trigger workflow_dispatch: jobs: @@ -59,7 +59,7 @@ jobs: runs-on: ubuntu-latest needs: build environment: - name: Production + name: 'Development' steps: - name: ๐Ÿ Set up Node.js version @@ -77,24 +77,26 @@ jobs: with: creds: ${{ secrets.AZURE_CREDENTIALS }} - # Set the build during deployment setting to false. This setting was added in the templates to all azd to work, but breaks deployment via webapps-deploy - name: Azure CLI script uses: azure/CLI@v1 with: - inlineScript: | - rg=$(az webapp list --query "[?name=='${{ secrets.AZURE_APP_SERVICE_NAME }}'].resourceGroup" --output tsv) - echo Setting SCM_DO_BUILD_DURING_DEPLOYMENT=false on app service ${{ secrets.AZURE_APP_SERVICE_NAME }} - az webapp config appsettings set -n ${{ secrets.AZURE_APP_SERVICE_NAME }} -g $rg --settings SCM_DO_BUILD_DURING_DEPLOYMENT=false -o none - echo Setting --startup-file=\"node server.js\" on app service ${{ secrets.AZURE_APP_SERVICE_NAME }} - az webapp config set --startup-file="node server.js" -n ${{ secrets.AZURE_APP_SERVICE_NAME }} -g $rg -o none - sleep 10 + inlineScript: | + rg=$(az webapp list --query "[?name=='${{ secrets.AZURE_APP_SERVICE_NAME }}'].resourceGroup" --output tsv) + echo Setting SCM_DO_BUILD_DURING_DEPLOYMENT=true on app service ${{ secrets.AZURE_APP_SERVICE_NAME }} slot dev + az webapp config appsettings set -n ${{ secrets.AZURE_APP_SERVICE_NAME }} -g $rg --settings SCM_DO_BUILD_DURING_DEPLOYMENT=false -o none --slot dev + echo Setting --startup-file="node server.js" on app service ${{ secrets.AZURE_APP_SERVICE_NAME }} slot dev + az webapp config set --startup-file="node server.js" -n ${{ secrets.AZURE_APP_SERVICE_NAME }} -g $rg -o none --slot dev + sleep 10 + - name: ๐Ÿš€ Deploy to Azure Web App id: deploy-to-webapp uses: azure/webapps-deploy@v2 with: app-name: ${{ secrets.AZURE_APP_SERVICE_NAME }} + slot-name: 'dev' + publish-profile: ${{ secrets.AZURE_APP_SERVICE_PUBLISH_PROFILE_DEV }} package: ${{ github.workspace }}/Nextjs-site.zip - + - name: ๐Ÿงน Cleanup run: rm ${{ github.workspace }}/Nextjs-site.zip diff --git a/infra/main.bicep b/infra/main.bicep index c6e2f3ad7..f15740ad5 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -9,9 +9,9 @@ param name string @description('Primary location for all resources') param location string -// azure open ai -- only regions supporting gpt-35-turbo v1106 +// azure open ai -- regions currently support gpt-4o global-standard @description('Location for the OpenAI resource group') -@allowed(['australiaeast', 'canadaeast', 'francecentral', 'southindia', 'uksouth', 'swedencentral', 'westus']) +@allowed(['australiaeast', 'brazilsouth', 'canadaeast', 'eastus', 'eastus2', 'francecentral', 'germanywestcentral', 'japaneast', 'koreacentral', 'northcentralus', 'norwayeast', 'polandcentral', 'spaincentral', 'southafricanorth', 'southcentralus', 'southindia', 'swedencentral', 'switzerlandnorth', 'uksouth', 'westeurope', 'westus', 'westus3']) @metadata({ azd: { type: 'location' @@ -20,19 +20,19 @@ param location string param openAILocation string param openAISku string = 'S0' -param openAIApiVersion string = '2023-12-01-preview' +param openAIApiVersion string ='2024-08-01-preview' -param chatGptDeploymentCapacity int = 120 -param chatGptDeploymentName string = 'chat-gpt-35-turbo' -param chatGptModelName string = 'gpt-35-turbo' -param chatGptModelVersion string = '1106' +param chatGptDeploymentCapacity int = 30 +param chatGptDeploymentName string = 'gpt-4o' +param chatGptModelName string = 'gpt-4o' +param chatGptModelVersion string = '2024-05-13' param embeddingDeploymentName string = 'embedding' param embeddingDeploymentCapacity int = 120 param embeddingModelName string = 'text-embedding-ada-002' -// DALL-E v3 only supported in Sweden Central for now +// DALL-E v3 only supported in limited regions for now @description('Location for the OpenAI DALL-E 3 instance resource group') -@allowed(['swedencentral']) +@allowed(['swedencentral', 'eastus', 'australiaeast']) param dalleLocation string param dalleDeploymentCapacity int = 1 @@ -40,17 +40,6 @@ param dalleDeploymentName string = 'dall-e-3' param dalleModelName string = 'dall-e-3' param dalleApiVersion string = '2023-12-01-preview' -// DALL-E v3 only supported in Sweden Central for now -@description('Location for the GPT vision instance resource') -@allowed(['swedencentral','westus',]) -param gptvisionLocation string - -param gptvisionDeploymentCapacity int = 1 -param gptvisionDeploymentName string = 'gpt-4-vision' -param gptvisionModelName string = 'gpt-4' -param gptvisionApiVersion string = '2023-12-01-preview' -param gptvisionModelVersion string = 'vision-preview' - param formRecognizerSkuName string = 'S0' param searchServiceIndexName string = 'azure-chat' param searchServiceSkuName string = 'standard' @@ -93,12 +82,6 @@ module resources 'resources.bicep' = { dalleDeploymentName: dalleDeploymentName dalleModelName: dalleModelName dalleApiVersion: dalleApiVersion - gptvisionLocation: gptvisionLocation - gptvisionApiVersion: gptvisionApiVersion - gptvisionDeploymentCapacity: gptvisionDeploymentCapacity - gptvisionDeploymentName: gptvisionDeploymentName - gptvisionModelName: gptvisionModelName - gptvisionModelVersion: gptvisionModelVersion formRecognizerSkuName: formRecognizerSkuName searchServiceIndexName: searchServiceIndexName searchServiceSkuName: searchServiceSkuName diff --git a/infra/resources.bicep b/infra/resources.bicep index 110672927..13dcc26a3 100644 --- a/infra/resources.bicep +++ b/infra/resources.bicep @@ -4,14 +4,14 @@ param resourceToken string param openai_api_version string param openAiLocation string -param openAiSkuName string = 'S0' -param chatGptDeploymentCapacity int = 30 -param chatGptDeploymentName string = 'chat-gpt-35-turbo' -param chatGptModelName string = 'chat-gpt-35-turbo' -param chatGptModelVersion string = '1106' -param embeddingDeploymentName string = 'text-embedding-ada-002' -param embeddingDeploymentCapacity int = 10 -param embeddingModelName string = 'text-embedding-ada-002' +param openAiSkuName string +param chatGptDeploymentCapacity int +param chatGptDeploymentName string +param chatGptModelName string +param chatGptModelVersion string +param embeddingDeploymentName string +param embeddingDeploymentCapacity int +param embeddingModelName string param dalleLocation string param dalleDeploymentCapacity int @@ -19,13 +19,6 @@ param dalleDeploymentName string param dalleModelName string param dalleApiVersion string -param gptvisionLocation string -param gptvisionDeploymentCapacity int = 30 -param gptvisionDeploymentName string = 'gpt-4-vision' -param gptvisionModelName string = 'gpt-4' -param gptvisionApiVersion string = '2023-12-01-preview' -param gptvisionModelVersion string = 'vision-preview' - param speechServiceSkuName string = 'S0' param formRecognizerSkuName string = 'S0' @@ -45,7 +38,6 @@ param tags object = {} var openai_name = toLower('${name}-aillm-${resourceToken}') var openai_dalle_name = toLower('${name}-aidalle-${resourceToken}') -var openai_gpt_vision_name = toLower('${name}-aivision-${resourceToken}') var form_recognizer_name = toLower('${name}-form-${resourceToken}') var speech_service_name = toLower('${name}-speech-${resourceToken}') @@ -53,8 +45,9 @@ var cosmos_name = toLower('${name}-cosmos-${resourceToken}') var search_name = toLower('${name}search${resourceToken}') var webapp_name = toLower('${name}-webapp-${resourceToken}') var appservice_name = toLower('${name}-app-${resourceToken}') -// storage name must be less than 24 chars, alphanumeric only - token is 13 -var storage_prefix = take(name, 8) +// storage name must be < 24 chars, alphanumeric only. 'sto' is 3 and resourceToken is 13 +var clean_name = replace(replace(name, '-', ''), '_', '') +var storage_prefix = take(clean_name, 8) var storage_name = toLower('${storage_prefix}sto${resourceToken}') // keyvault name must be less than 24 chars - token is 13 var kv_prefix = take(name, 7) @@ -79,7 +72,7 @@ var llmDeployments = [ version: chatGptModelVersion } sku: { - name: 'Standard' + name: 'GlobalStandard' capacity: chatGptDeploymentCapacity } } @@ -133,22 +126,6 @@ resource webApp 'Microsoft.Web/sites@2020-06-01' = { name: 'SCM_DO_BUILD_DURING_DEPLOYMENT' value: 'true' } - { - name: 'AZURE_OPENAI_VISION_API_KEY' - value: '@Microsoft.KeyVault(VaultName=${kv.name};SecretName=${kv::AZURE_OPENAI_VISION_API_KEY.name})' - } - { - name: 'AZURE_OPENAI_VISION_API_INSTANCE_NAME' - value: openai_gpt_vision_name - } - { - name: 'AZURE_OPENAI_VISION_API_DEPLOYMENT_NAME' - value: gptvisionDeploymentName - } - { - name: 'AZURE_OPENAI_VISION_API_VERSION' - value: gptvisionApiVersion - } { name: 'AZURE_OPENAI_API_KEY' value: '@Microsoft.KeyVault(VaultName=${kv.name};SecretName=${kv::AZURE_OPENAI_API_KEY.name})' @@ -298,14 +275,6 @@ resource kv 'Microsoft.KeyVault/vaults@2021-06-01-preview' = { enabledForTemplateDeployment: false } - resource AZURE_OPENAI_VISION_API_KEY 'secrets' = { - name: 'AZURE-OPENAI-VISION-API-KEY' - properties: { - contentType: 'text/plain' - value: azureopenaivision.listKeys().key1 - } - } - resource AZURE_OPENAI_API_KEY 'secrets' = { name: 'AZURE-OPENAI-API-KEY' properties: { @@ -478,14 +447,15 @@ resource llmdeployment 'Microsoft.CognitiveServices/accounts/deployments@2023-05 name: deployment.name properties: { model: deployment.model - raiPolicyName: contains(deployment, 'raiPolicyName') ? deployment.raiPolicyName : null } - sku: contains(deployment, 'sku') ? deployment.sku : { + sku: deployment.sku != null ? deployment.sku : { name: 'Standard' capacity: deployment.capacity } }] + + resource azureopenaidalle 'Microsoft.CognitiveServices/accounts@2023-05-01' = { name: openai_dalle_name location: dalleLocation @@ -516,35 +486,6 @@ resource azureopenaidalle 'Microsoft.CognitiveServices/accounts@2023-05-01' = { -resource azureopenaivision 'Microsoft.CognitiveServices/accounts@2023-05-01' = { - name: openai_gpt_vision_name - location: gptvisionLocation - tags: tags - kind: 'OpenAI' - properties: { - customSubDomainName: openai_gpt_vision_name - publicNetworkAccess: 'Enabled' - } - sku: { - name: openAiSkuName - } - - resource dalleDeployment 'deployments' = { - name: gptvisionDeploymentName - properties: { - model: { - format: 'OpenAI' - name: gptvisionModelName - version:gptvisionModelVersion - } - } - sku: { - name: 'Standard' - capacity: gptvisionDeploymentCapacity - } - } -} - resource speechService 'Microsoft.CognitiveServices/accounts@2023-05-01' = { name: speech_service_name location: location diff --git a/src/.env.example b/src/.env.example deleted file mode 100644 index 915f905e7..000000000 --- a/src/.env.example +++ /dev/null @@ -1,73 +0,0 @@ -# NOTES: -# - Do not use double-quotes and do not delete any of the variables. -# - Make sure that NEXTAUTH_URL=http://localhost:3000 has no comments in the same line. - -# Update your Azure OpenAI details -# AZURE_OPENAI_API_INSTANCE_NAME should be just the name of azure openai resource and not the full url; -# AZURE_OPENAI_API_DEPLOYMENT_NAME should be deployment name from your azure openai studio and not the model name. -# AZURE_OPENAI_API_VERSION should be Supported versions checkout docs https://learn.microsoft.com/en-us/azure/ai-services/openai/reference -AZURE_OPENAI_API_KEY=111111 -AZURE_OPENAI_API_INSTANCE_NAME=azurechat -AZURE_OPENAI_API_DEPLOYMENT_NAME=gpt-4 -AZURE_OPENAI_API_VERSION=2023-12-01-preview -AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME=embedding - -# DALL-E image creation endpoint config -AZURE_OPENAI_DALLE_API_KEY=222222 -AZURE_OPENAI_DALLE_API_INSTANCE_NAME=azurechat-dall-e -AZURE_OPENAI_DALLE_API_DEPLOYMENT_NAME=dall-e -AZURE_OPENAI_DALLE_API_VERSION=2023-12-01-preview - -# GPT4 V OpenaAI details -AZURE_OPENAI_VISION_API_KEY=333333 -AZURE_OPENAI_VISION_API_INSTANCE_NAME=azurechat-vision -AZURE_OPENAI_VISION_API_DEPLOYMENT_NAME=gpt-4-vision -AZURE_OPENAI_VISION_API_VERSION=2023-12-01-preview - -# Update your admin email addresses - comma separated -ADMIN_EMAIL_ADDRESS=you@email.com,you2@email.com - -# Identity provider is optional if you are running in development mode locally (npm run dev) -AUTH_GITHUB_ID= -AUTH_GITHUB_SECRET= - -AZURE_AD_CLIENT_ID= -AZURE_AD_CLIENT_SECRET= -AZURE_AD_TENANT_ID= - -# Update your production URL in NEXTAUTH_URL -NEXTAUTH_SECRET=AZURE-OPENIAI-NEXTAUTH-OWNKEY@1 -# in production, this should be your production URL e.g. https://azurechat.azurewebsites.net -NEXTAUTH_URL=http://localhost:3000 - -# Update your Cosmos Environment details here -AZURE_COSMOSDB_URI=https://.documents.azure.com:443/ -AZURE_COSMOSDB_KEY= - -# Update your Cosmos variables if you want to overwrite the default values -AZURE_COSMOSDB_DB_NAME=chat -AZURE_COSMOSDB_CONTAINER_NAME=history -AZURE_COSMOSDB_CONFIG_CONTAINER_NAME=config - -# Azure AI Search is used for chat over your data -AZURE_SEARCH_API_KEY= -AZURE_SEARCH_NAME= -AZURE_SEARCH_INDEX_NAME= - -# Azure AI Document Intelligence to extract content from your data -AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT=https://NAME.api.cognitive.microsoft.com/ -AZURE_DOCUMENT_INTELLIGENCE_KEY= - -# max upload document size in bytes -MAX_UPLOAD_DOCUMENT_SIZE=20000000 - -# Azure Speech to Text to convert audio to text -AZURE_SPEECH_REGION= -AZURE_SPEECH_KEY= - -# Azure Storage account to store files -AZURE_STORAGE_ACCOUNT_NAME=azurechat -AZURE_STORAGE_ACCOUNT_KEY=123456 - -# Azure Key Vault to store secrets -AZURE_KEY_VAULT_NAME= \ No newline at end of file diff --git a/src/app/favicon.ico b/src/app/favicon.ico index d0f9c71c5..4437f59f2 100644 Binary files a/src/app/favicon.ico and b/src/app/favicon.ico differ diff --git a/src/app/globals.css b/src/app/globals.css index de8270426..05ffb79fd 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -10,7 +10,7 @@ --card-foreground: 222.2 84% 4.9%; --popover: 0 0% 100%; --popover-foreground: 222.2 84% 4.9%; - --primary: 136 80% 42%; + --primary: 222.2 44.4% 29.6%; --primary-foreground: 210 40% 98%; --secondary: 210 40% 96.1%; --secondary-foreground: 222.2 47.4% 11.2%; @@ -27,13 +27,13 @@ } .dark { - --background: 222.2 84% 4.9%; + --background: 0 0% 10.2%; --foreground: 210 40% 98%; --card: 222.2 84% 4.9%; --card-foreground: 210 40% 98%; --popover: 222.2 84% 4.9%; --popover-foreground: 210 40% 98%; - --primary: 136 80% 42%; + --primary: 222.2 44.4% 60%; --primary-foreground: 222.2 47.4% 11.2%; --secondary: 217.2 32.6% 17.5%; --secondary-foreground: 210 40% 98%; diff --git a/src/app/layout.tsx b/src/app/layout.tsx index ec1abff36..6bd54b351 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -4,6 +4,7 @@ import { Toaster } from "@/features/ui/toaster"; import { cn } from "@/ui/lib"; import { Inter } from "next/font/google"; import "./globals.css"; +import ClientTracker from "./lib/clientTracker"; const inter = Inter({ subsets: ["latin"] }); @@ -13,7 +14,6 @@ export const metadata = { }; export const dynamic = "force-dynamic"; - export default function RootLayout({ children, }: { @@ -30,6 +30,7 @@ export default function RootLayout({ enableSystem disableTransitionOnChange > + {children} diff --git a/src/app/lib/appInsights.tsx b/src/app/lib/appInsights.tsx new file mode 100644 index 000000000..2e844e5b0 --- /dev/null +++ b/src/app/lib/appInsights.tsx @@ -0,0 +1,50 @@ +import { tr } from '@markdoc/markdoc/dist/src/schema'; +import {ApplicationInsights} from '@microsoft/applicationinsights-web'; +let appInsights: ApplicationInsights | null = null; + +export function initAppInsights(instrumentationKey: string) { + if (!appInsights) { + appInsights = new ApplicationInsights({ + config: { + instrumentationKey: instrumentationKey, + enableAutoRouteTracking: true, // Automatically track route changes + }, + }); + appInsights.loadAppInsights(); + } + return appInsights; + } + + export function trackPageView(name: string, uri: string) { + if (appInsights) { + appInsights.trackPageView({ name, uri }); + } + } + + export function trackEvent(name: string, properties?: {[key: string]: any}) { + if (appInsights) { + appInsights.trackEvent({ name }, properties); + } + } + + export function trackException(error: Error, severityLevel: number = 3){ + if(appInsights){ + appInsights.trackException({ + exception: error, + severityLevel, + }); + } + } + + export function setUserContext(userId: string, accountId?: string){ + if(appInsights){ + appInsights.setAuthenticatedUserContext(userId, accountId); + } + } + + export function flushTelemetry(){ + if(appInsights){ + appInsights.flush(); + } + } + export default appInsights; \ No newline at end of file diff --git a/src/app/lib/clientTracker.tsx b/src/app/lib/clientTracker.tsx new file mode 100644 index 000000000..05974654f --- /dev/null +++ b/src/app/lib/clientTracker.tsx @@ -0,0 +1,21 @@ +'use client'; // Ensure this runs on the client side +import { useEffect } from 'react'; +import { usePathname } from "next/navigation"; +import { initAppInsights, trackPageView } from './appInsights'; + +export default function ClientTracker() { + const pathname = usePathname(); + + useEffect(() => { + const instrumentationKey = 'ff525cc3-db0d-4416-904f-f10ec055a0d5'; // Replace with your actual key + initAppInsights(instrumentationKey); + + // Track the initial page view + trackPageView(document.title, window.location.href); + + // Track page views on pathname changes + trackPageView(document.title, pathname); + }, [pathname]); + + return null; // No UI needed +} \ No newline at end of file diff --git a/src/features/auth-page/helpers.ts b/src/features/auth-page/helpers.ts index 722308a4a..7f610467c 100644 --- a/src/features/auth-page/helpers.ts +++ b/src/features/auth-page/helpers.ts @@ -20,6 +20,8 @@ export const userSession = async (): Promise => { export const getCurrentUser = async (): Promise => { const user = await userSession(); if (user) { + //console.log(user.email); + //console.log(user.name); return user; } throw new Error("User not found"); diff --git a/src/features/auth-page/login.tsx b/src/features/auth-page/login.tsx index 9c07a05c7..f8f308ac8 100644 --- a/src/features/auth-page/login.tsx +++ b/src/features/auth-page/login.tsx @@ -27,12 +27,11 @@ export const LogIn: FC = (props) => { {AI_NAME} - Login in with your GitHub or Microsoft 365 account + Login in with your Microsoft account - - + {props.isDevMode ? ( ); }; diff --git a/src/features/chat-page/chat-services/chat-document-service.ts b/src/features/chat-page/chat-services/chat-document-service.ts index 58b9defec..49d27b76c 100644 --- a/src/features/chat-page/chat-services/chat-document-service.ts +++ b/src/features/chat-page/chat-services/chat-document-service.ts @@ -13,7 +13,7 @@ import { EnsureIndexIsCreated } from "./azure-ai-search/azure-ai-search"; import { CHAT_DOCUMENT_ATTRIBUTE, ChatDocumentModel } from "./models"; const MAX_UPLOAD_DOCUMENT_SIZE: number = 20000000; -const CHUNK_SIZE = 2300; +const CHUNK_SIZE = 2500; // 25% overlap const CHUNK_OVERLAP = CHUNK_SIZE * 0.25; diff --git a/src/features/chat-page/chat-services/citation-service.ts b/src/features/chat-page/chat-services/citation-service.ts index d6163d24b..03b1c6ac0 100644 --- a/src/features/chat-page/chat-services/citation-service.ts +++ b/src/features/chat-page/chat-services/citation-service.ts @@ -100,14 +100,14 @@ export const FindCitationByID = async ( } }; -export const FormatCitations = (citation: DocumentSearchResponse[]) => { +export const FormatCitations = (citation: any[]) => { const withoutEmbedding: DocumentSearchResponse[] = []; citation.forEach((d) => { withoutEmbedding.push({ score: d.score, document: { - metadata: d.document.metadata, - pageContent: d.document.pageContent, + metadata: d.document.metadata || d.document.title, + pageContent: d.document.pageContent || d.document.content || d.document.chunk, // updated citation text chatThreadId: d.document.chatThreadId, id: "", user: "", diff --git a/src/features/chat-page/message-content.tsx b/src/features/chat-page/message-content.tsx index 757613a4c..9008a10de 100644 --- a/src/features/chat-page/message-content.tsx +++ b/src/features/chat-page/message-content.tsx @@ -32,33 +32,33 @@ const MessageContent: React.FC = ({ message }) => { ); } - if (message.role === "tool" || message.role === "function") { - return ( -
- - - -
- {" "} - Show {message.name}{" "} - {message.name === "tool" ? "output" : "function"} -
-
- - - -
-
-
- ); - } + // if (message.role === "tool" || message.role === "function") { + // return ( + //
+ // + // + // + //
+ // {" "} + // Show {message.name}{" "} + // {message.name === "tool" ? "output" : "function"} + //
+ //
+ // + // + // + //
+ //
+ //
+ // ); + // } return null; }; diff --git a/src/features/main-menu/menu-store.tsx b/src/features/main-menu/menu-store.tsx index 7534f5910..789d11683 100644 --- a/src/features/main-menu/menu-store.tsx +++ b/src/features/main-menu/menu-store.tsx @@ -1,9 +1,9 @@ import { proxy, useSnapshot } from "valtio"; class Menu { - public isMenuOpen: boolean; + public isMenuOpen: boolean = false; constructor() { - this.isMenuOpen = true; + this.isMenuOpen = false; } toggleMenu() { @@ -14,5 +14,6 @@ class Menu { export const menuStore = proxy(new Menu()); // Hook to use the menu state export const useMenuState = () => { + //console.log(menuStore.isMenuOpen); return useSnapshot(menuStore); }; diff --git a/src/features/main-menu/user-profile.tsx b/src/features/main-menu/user-profile.tsx index 94cdfa437..6f0df2b90 100644 --- a/src/features/main-menu/user-profile.tsx +++ b/src/features/main-menu/user-profile.tsx @@ -13,9 +13,13 @@ import { CircleUserRound, LogOut } from "lucide-react"; import { signOut, useSession } from "next-auth/react"; import { Avatar, AvatarImage } from "../ui/avatar"; import { ThemeToggle } from "./theme-toggle"; +import { flushTelemetry, setUserContext, trackEvent } from '../../app/lib/appInsights'; + export const UserProfile = () => { const { data: session } = useSession(); + //console.log(session?.user.email); + setUserContext(session?.user?.email ?? '', session?.user?.email ?? ''); return ( @@ -55,7 +59,7 @@ export const UserProfile = () => { signOut({ callbackUrl: "/" })} + onClick={() => { flushTelemetry(); signOut({ callbackUrl: "/" });}} > Log out diff --git a/src/features/prompt-page/prompt-hero/prompt-hero.tsx b/src/features/prompt-page/prompt-hero/prompt-hero.tsx index 15bea77e5..04123105a 100644 --- a/src/features/prompt-page/prompt-hero/prompt-hero.tsx +++ b/src/features/prompt-page/prompt-hero/prompt-hero.tsx @@ -15,7 +15,7 @@ export const PromptHero = () => { "Prompt templates are statements or questions meant to help users get creative without having to come up with ideas from scratch." } > - } @@ -65,7 +65,7 @@ Generate a response with the following points: userId: "", }) } - /> + /> */} ); }; diff --git a/src/features/theme/theme-config.ts b/src/features/theme/theme-config.ts index 57391f556..adba43e8c 100644 --- a/src/features/theme/theme-config.ts +++ b/src/features/theme/theme-config.ts @@ -1,5 +1,5 @@ -export const AI_NAME = "Azure Chat"; -export const AI_DESCRIPTION = "Azure Chat is a friendly AI assistant."; +export const AI_NAME = "APiChat"; +export const AI_DESCRIPTION = "APiChat is a friendly AI assistant designed to assist team members of APi Group Inc."; export const CHAT_DEFAULT_PERSONA = AI_NAME + " default"; export const CHAT_DEFAULT_SYSTEM_PROMPT = `You are a friendly ${AI_NAME} AI assistant. You must always return in markdown format. diff --git a/src/package-lock.json b/src/package-lock.json index 2fdc29900..5d1f87a2e 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -16,6 +16,7 @@ "@azure/storage-blob": "^12.17.0", "@codemirror/lang-javascript": "^6.2.1", "@markdoc/markdoc": "^0.4.0", + "@microsoft/applicationinsights-web": "^3.3.4", "@radix-ui/react-accordion": "^1.1.2", "@radix-ui/react-avatar": "^1.0.4", "@radix-ui/react-context-menu": "^2.1.5", @@ -1239,6 +1240,174 @@ } } }, + "node_modules/@microsoft/applicationinsights-analytics-js": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-analytics-js/-/applicationinsights-analytics-js-3.3.4.tgz", + "integrity": "sha512-RxxyiIgt3TJ/tvLhg1wth1862wrPmru6dBS7vyThFEUkCZ/AYqEAzdH1JiixgTL/e72NesqmgKcvUUPv9kl9rg==", + "license": "MIT", + "dependencies": { + "@microsoft/applicationinsights-common": "3.3.4", + "@microsoft/applicationinsights-core-js": "3.3.4", + "@microsoft/applicationinsights-shims": "3.0.1", + "@microsoft/dynamicproto-js": "^2.0.3", + "@nevware21/ts-utils": ">= 0.11.3 < 2.x" + }, + "peerDependencies": { + "tslib": ">= 1.0.0" + } + }, + "node_modules/@microsoft/applicationinsights-cfgsync-js": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-cfgsync-js/-/applicationinsights-cfgsync-js-3.3.4.tgz", + "integrity": "sha512-Q5aLy6e6dFf4zr+FJdO46dOfHIvRgt/6QG1lJNC9tiuyjWYOKBkOSTop/5+2vvFK5IY4p3g0mxJOSeoHsr8RQQ==", + "license": "MIT", + "dependencies": { + "@microsoft/applicationinsights-common": "3.3.4", + "@microsoft/applicationinsights-core-js": "3.3.4", + "@microsoft/applicationinsights-shims": "3.0.1", + "@microsoft/dynamicproto-js": "^2.0.3", + "@nevware21/ts-async": ">= 0.5.2 < 2.x", + "@nevware21/ts-utils": ">= 0.11.3 < 2.x" + }, + "peerDependencies": { + "tslib": ">= 1.0.0" + } + }, + "node_modules/@microsoft/applicationinsights-channel-js": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-channel-js/-/applicationinsights-channel-js-3.3.4.tgz", + "integrity": "sha512-Z4nrxYwGKP9iyrYtm7iPQXVOFy4FsEsX0nDKkAi96Qpgw+vEh6NH4ORxMMuES0EollBQ3faJyvYCwckuCVIj0g==", + "license": "MIT", + "dependencies": { + "@microsoft/applicationinsights-common": "3.3.4", + "@microsoft/applicationinsights-core-js": "3.3.4", + "@microsoft/applicationinsights-shims": "3.0.1", + "@microsoft/dynamicproto-js": "^2.0.3", + "@nevware21/ts-async": ">= 0.5.2 < 2.x", + "@nevware21/ts-utils": ">= 0.11.3 < 2.x" + }, + "peerDependencies": { + "tslib": ">= 1.0.0" + } + }, + "node_modules/@microsoft/applicationinsights-common": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-common/-/applicationinsights-common-3.3.4.tgz", + "integrity": "sha512-4ms16MlIvcP4WiUPqopifNxcWCcrXQJ2ADAK/75uok2mNQe6ZNRsqb/P+pvhUxc8A5HRlvoXPP1ptDSN5Girgw==", + "license": "MIT", + "dependencies": { + "@microsoft/applicationinsights-core-js": "3.3.4", + "@microsoft/applicationinsights-shims": "3.0.1", + "@microsoft/dynamicproto-js": "^2.0.3", + "@nevware21/ts-utils": ">= 0.11.3 < 2.x" + }, + "peerDependencies": { + "tslib": ">= 1.0.0" + } + }, + "node_modules/@microsoft/applicationinsights-core-js": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-core-js/-/applicationinsights-core-js-3.3.4.tgz", + "integrity": "sha512-MummANF0mgKIkdvVvfmHQTBliK114IZLRhTL0X0Ep+zjDwWMHqYZgew0nlFKAl6ggu42abPZFK5afpE7qjtYJA==", + "license": "MIT", + "dependencies": { + "@microsoft/applicationinsights-shims": "3.0.1", + "@microsoft/dynamicproto-js": "^2.0.3", + "@nevware21/ts-async": ">= 0.5.2 < 2.x", + "@nevware21/ts-utils": ">= 0.11.3 < 2.x" + }, + "peerDependencies": { + "tslib": ">= 1.0.0" + } + }, + "node_modules/@microsoft/applicationinsights-dependencies-js": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-dependencies-js/-/applicationinsights-dependencies-js-3.3.4.tgz", + "integrity": "sha512-RBEFs78v1Zl+9I85nUyw2KdXUKnjxDvdMC0Ul86v7i9ApFrrPJTJ0AVS8h+ydxtJcO2f2nHUEbtVWCf1ixRHiQ==", + "license": "MIT", + "dependencies": { + "@microsoft/applicationinsights-common": "3.3.4", + "@microsoft/applicationinsights-core-js": "3.3.4", + "@microsoft/applicationinsights-shims": "3.0.1", + "@microsoft/dynamicproto-js": "^2.0.3", + "@nevware21/ts-async": ">= 0.5.2 < 2.x", + "@nevware21/ts-utils": ">= 0.11.3 < 2.x" + }, + "peerDependencies": { + "tslib": ">= 1.0.0" + } + }, + "node_modules/@microsoft/applicationinsights-properties-js": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-properties-js/-/applicationinsights-properties-js-3.3.4.tgz", + "integrity": "sha512-iI26hM34ysqxVmdOxVetBeoinPoBnNxSb0/c3A+zbY9iCelvf7HF4tn1Qf+sS9Jqn1Z1XjzzKvan8k82+cK+XA==", + "license": "MIT", + "dependencies": { + "@microsoft/applicationinsights-common": "3.3.4", + "@microsoft/applicationinsights-core-js": "3.3.4", + "@microsoft/applicationinsights-shims": "3.0.1", + "@microsoft/dynamicproto-js": "^2.0.3", + "@nevware21/ts-utils": ">= 0.11.3 < 2.x" + }, + "peerDependencies": { + "tslib": ">= 1.0.0" + } + }, + "node_modules/@microsoft/applicationinsights-shims": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-shims/-/applicationinsights-shims-3.0.1.tgz", + "integrity": "sha512-DKwboF47H1nb33rSUfjqI6ryX29v+2QWcTrRvcQDA32AZr5Ilkr7whOOSsD1aBzwqX0RJEIP1Z81jfE3NBm/Lg==", + "license": "MIT", + "dependencies": { + "@nevware21/ts-utils": ">= 0.9.4 < 2.x" + } + }, + "node_modules/@microsoft/applicationinsights-web": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-web/-/applicationinsights-web-3.3.4.tgz", + "integrity": "sha512-aZdGnI0fby/OoRNIKkYC9xqNjqFJyb7fKiYtIejCGbE/i2sClnHq7tnwiTk1UKBy9oflwryoFFNs0MM6PDBuMA==", + "license": "MIT", + "dependencies": { + "@microsoft/applicationinsights-analytics-js": "3.3.4", + "@microsoft/applicationinsights-cfgsync-js": "3.3.4", + "@microsoft/applicationinsights-channel-js": "3.3.4", + "@microsoft/applicationinsights-common": "3.3.4", + "@microsoft/applicationinsights-core-js": "3.3.4", + "@microsoft/applicationinsights-dependencies-js": "3.3.4", + "@microsoft/applicationinsights-properties-js": "3.3.4", + "@microsoft/applicationinsights-shims": "3.0.1", + "@microsoft/dynamicproto-js": "^2.0.3", + "@nevware21/ts-async": ">= 0.5.2 < 2.x", + "@nevware21/ts-utils": ">= 0.11.3 < 2.x" + }, + "peerDependencies": { + "tslib": ">= 1.0.0" + } + }, + "node_modules/@microsoft/dynamicproto-js": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@microsoft/dynamicproto-js/-/dynamicproto-js-2.0.3.tgz", + "integrity": "sha512-JTWTU80rMy3mdxOjjpaiDQsTLZ6YSGGqsjURsY6AUQtIj0udlF/jYmhdLZu8693ZIC0T1IwYnFa0+QeiMnziBA==", + "license": "MIT", + "dependencies": { + "@nevware21/ts-utils": ">= 0.10.4 < 2.x" + } + }, + "node_modules/@nevware21/ts-async": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/@nevware21/ts-async/-/ts-async-0.5.4.tgz", + "integrity": "sha512-IBTyj29GwGlxfzXw2NPnzty+w0Adx61Eze1/lknH/XIVdxtF9UnOpk76tnrHXWa6j84a1RR9hsOcHQPFv9qJjA==", + "license": "MIT", + "dependencies": { + "@nevware21/ts-utils": ">= 0.11.6 < 2.x" + } + }, + "node_modules/@nevware21/ts-utils": { + "version": "0.11.6", + "resolved": "https://registry.npmjs.org/@nevware21/ts-utils/-/ts-utils-0.11.6.tgz", + "integrity": "sha512-OUUJTh3fnaUSzg9DEHgv3d7jC+DnPL65mIO7RaR+jWve7+MmcgIvF79gY97DPQ4frH+IpNR78YAYd/dW4gK3kg==", + "license": "MIT" + }, "node_modules/@next/env": { "version": "14.0.4", "resolved": "https://registry.npmjs.org/@next/env/-/env-14.0.4.tgz", @@ -5284,9 +5453,9 @@ } }, "node_modules/jose": { - "version": "4.15.4", - "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.4.tgz", - "integrity": "sha512-W+oqK4H+r5sITxfxpSU+MMdr/YSWGvgZMQDIsNoBDGGy4i7GBPTtvFKibQzW06n3U3TqHjhvBJsirShsEJ6eeQ==", + "version": "4.15.5", + "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.5.tgz", + "integrity": "sha512-jc7BFxgKPKi94uOvEmzlSWFFe2+vASyXaKUpdQKatWAESU2MWjDfFf0fdfc83CDKcA5QecabZeNLyfhe3yKNkg==", "funding": { "url": "https://github.com/sponsors/panva" } diff --git a/src/package.json b/src/package.json index 59375f410..b5b63f0a2 100644 --- a/src/package.json +++ b/src/package.json @@ -17,6 +17,7 @@ "@azure/storage-blob": "^12.17.0", "@codemirror/lang-javascript": "^6.2.1", "@markdoc/markdoc": "^0.4.0", + "@microsoft/applicationinsights-web": "^3.3.4", "@radix-ui/react-accordion": "^1.1.2", "@radix-ui/react-avatar": "^1.0.4", "@radix-ui/react-context-menu": "^2.1.5", diff --git a/src/public/ai-icon.png b/src/public/ai-icon.png index f23a6bd81..4e6910d29 100644 Binary files a/src/public/ai-icon.png and b/src/public/ai-icon.png differ diff --git a/src/public/ai-icon1.png b/src/public/ai-icon1.png new file mode 100644 index 000000000..a397b5625 Binary files /dev/null and b/src/public/ai-icon1.png differ diff --git a/src/public/ai-icon2.png b/src/public/ai-icon2.png new file mode 100644 index 000000000..45a607b13 Binary files /dev/null and b/src/public/ai-icon2.png differ diff --git a/src/public/user-icon.png b/src/public/user-icon.png index af5125206..638307868 100644 Binary files a/src/public/user-icon.png and b/src/public/user-icon.png differ