Skip to content

Commit

Permalink
Chat with File Preparedness (#121)
Browse files Browse the repository at this point in the history
* Refactor login error message for better user experience

* feat: Update file upload description in ChatFileUI component

Update the file upload description in the ChatFileUI component to provide more information to users. The updated description now mentions that uploaded files will only be available for a guaranteed seven days. This change is made to align with the new file handling process in ${AI_NAME}.

* feat: Update file upload description in ChatFileUI component

* Update file upload description in ChatFileUI component

* feat: Update file upload description in ChatFileUI component

Update the file upload description in the ChatFileUI component to mention that uploaded files will only be available for a guaranteed seven days. This aligns with the new file handling process in ${AI_NAME}.

* save document content to ChatDocumentModel

* feat: Update app version to 1.5.5 and file handling description in ChatFileUI component

Update the app version to 1.5.5 in the app-global.ts file and package.json. Also, update the file upload description in the ChatFileUI component to mention that uploaded files will only be available for a guaranteed seven days. This aligns with the new file handling process in ${AI_NAME}.

---------

Co-authored-by: Bruno Piovan <bruno.piovan@chde.qld.gov.au>
  • Loading branch information
kpqdap and qdap-bp committed Jun 28, 2024
1 parent b63caec commit 5c1dce1
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/app-global.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const APP_VERSION = "1.5.4"
export const APP_VERSION = "1.5.5"
export const signInProvider = "azure-ad"
export const SUPPORT_EMAIL = "help@ai.qld.gov.au"
export const STATUS_ERROR = "ERROR"
Expand Down
2 changes: 1 addition & 1 deletion src/app/login-error/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const ErrorPage: React.FC = () => {
break
case SignInErrorType.SignInFailed:
default:
message = `Currently, access to ${AI_NAME} is only available to onboarded agencies, if you are seeing this warning it usually means your agency has not completed their setup. If you believe your agency has been setup and continue to receive these errors, please contact your agency IT support team.`
message = `It appears we ran into an error while logging you in to ${AI_NAME} if you believe your agency has been setup and continue to receive these errors, please contact our support team.`
setDisplaySupportButton(true)
break
}
Expand Down
13 changes: 11 additions & 2 deletions src/features/chat/chat-services/chat-document-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { xMonthsAgo } from "@/features/common/date-helper"
import { ServerActionResponseAsync } from "@/features/common/server-action-response"
import { HistoryContainer } from "@/features/common/services/cosmos"
import logger from "@/features/insights/app-insights"
import { APP_URL } from "@/features/theme/theme-config"
import { uniqueId } from "@/lib/utils"

import { AzureCogDocumentIndex, indexDocuments } from "./azure-cog-search/azure-cog-vector-store"
Expand Down Expand Up @@ -82,8 +83,9 @@ export const UploadDocument = async (formData: FormData): ServerActionResponseAs
fileContent = [splitDocuments, transcription.text, transcription.vtt]
} else {
const docs = await LoadFile(formData, chatType)
const splitDocuments = chunkDocumentWithOverlap(docs.join("\n"))
fileContent = [splitDocuments, undefined]
const joined = docs.join("\n")
const splitDocuments = chunkDocumentWithOverlap(joined)
fileContent = [splitDocuments, joined]
}
return {
status: "OK",
Expand All @@ -106,6 +108,7 @@ export const IndexDocuments = async (
): ServerActionResponseAsync<AzureCogDocumentIndex[]> => {
try {
const [userId, tenantId] = await Promise.all([userHashedId(), getTenantId()])
const path = `${APP_URL}/chat/${chatThreadId}`
const documentsToIndex: AzureCogDocumentIndex[] = docs.map((docContent, index) => ({
id: uniqueId(),
chatThreadId,
Expand All @@ -116,6 +119,9 @@ export const IndexDocuments = async (
tenantId,
createdDate: new Date().toISOString(),
fileName,
filepath: path,
url: path,
title: fileName,
embedding: [],
}))
await indexDocuments(documentsToIndex)
Expand All @@ -131,6 +137,9 @@ export const IndexDocuments = async (
name: fileName,
contents: contentsToSave,
extraContents: extraContents,
filepath: path,
title: fileName,
url: path,
}
const container = await HistoryContainer()
const { resource } = await container.items.upsert<ChatDocumentModel>(modelToSave)
Expand Down
4 changes: 4 additions & 0 deletions src/features/chat/chat-ui/chat-file/chat-file-ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { FC, useEffect, useRef } from "react"
import Typography from "@/components/typography"
import { useChatContext } from "@/features/chat/chat-ui/chat-context"
import { TranscriptForm } from "@/features/chat/chat-ui/chat-empty-state/chat-transcript-details"
import { AI_NAME } from "@/features/theme/theme-config"
import { Button } from "@/features/ui/button"
import { Input } from "@/features/ui/input"

Expand Down Expand Up @@ -53,6 +54,9 @@ export const ChatFileUI: FC = () => {
</Typography>
</div>
)}
<Typography variant="span" id="file-upload-description" className="text-muted-foreground">
{`From June 28 the way you chat with files in ${AI_NAME} is changing, please note that content from uploaded files will only be available for a gauranteed seven days while we transition.`}
</Typography>
<form onSubmit={onSubmit} className="flex items-center gap-2">
<label htmlFor="file-upload" className="sr-only">
Upload File
Expand Down
3 changes: 3 additions & 0 deletions src/features/chat/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ export interface ChatDocumentModel {
contents?: string
extraContents?: string
type: ChatRecordType.Document
filepath: string
title: string
url: string
}

export interface ChatUtilityModel {
Expand Down
4 changes: 2 additions & 2 deletions src/features/common/date-helper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const xDaysAgo = (length?: number): string => {
const date = new Date()
if (!length) {
date.setFullYear(2020)
date.setFullYear(2024)
return date.toISOString()
}
date.setDate(date.getDate() - length)
Expand All @@ -11,7 +11,7 @@ export const xDaysAgo = (length?: number): string => {
export const xMonthsAgo = (length?: number): string => {
const date = new Date()
if (!length) {
date.setFullYear(2020)
date.setFullYear(2024)
return date.toISOString()
}
date.setMonth(date.getMonth() - length)
Expand Down
4 changes: 2 additions & 2 deletions src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "src",
"version": "1.5.4",
"version": "1.5.5",
"private": true,
"scripts": {
"report": "npx ts-node --project tsconfig.script.json generate-model-report.ts",
Expand Down
14 changes: 14 additions & 0 deletions src/public/whats-new.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ Below are the updates for the Queensland Government QChat Virtual Assistant.

- If you are a technical or business staff member working on AI Projects, you can click [here](https://forms.office.com/r/YZzMFLexPK) to request to join the Queensland Government AI Community of Practice. This platform is designed to facilitate knowledge sharing and collaboration among AI professionals within the government.

## πŸ“š Version 1.5.5 Updates - 28 June 2024

Here's the updated version of the release notes with Australian English spelling and additional styling:

## 🌟 Version 1.5.5 Updates - 28 June 2024

### πŸš€ Exciting changes to File Upload are coming soon

We are preparing to **update the way you upload files** and **revolutionise how you chat with your data in QChat**. To achieve this, we may need to **remove files from older chats**.

We've updated our guidance and implemented additional measures to minimise disruption during this transition.

**Please note:** Both documents more than 30 days old and more recent might be unavailable after the transition. However, we aim to cut over with minimal to no impact on you!

## πŸ“š Version 1.5.4 Updates - 23 June 2024

- **Set your own context prompt:** We've launched our User Context Prompt Feature! Head over to Settings and Your Details to give it a try. This will allow you to provide every conversation with reference information from the get go! Please give the feature a go and reach out to support if you have any concerns or issues.
Expand Down

0 comments on commit 5c1dce1

Please sign in to comment.