Skip to content

Commit

Permalink
Auto-merge main back to develop post release
Browse files Browse the repository at this point in the history
  • Loading branch information
bedanley committed Jan 31, 2025
2 parents f21e1c2 + 82b8b94 commit 9105184
Show file tree
Hide file tree
Showing 11 changed files with 249 additions and 98 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# v3.5.1

## Bug Fixes

### Chat Session Management

- Resolved url redirect issue that prevented creation of new chat sessions via the New button
- Resolved intermittent loading issues when accessing historical conversations due to LangChain memory object
- Addressed error handling for LLM interactions after multiple prompts

### Document Summarization

- Fixed stability issues with document summarization functionality in existing chat sessions

### UI

-Corrected display scaling issues in Firefox for large screen resolutions

# v3.5.0
## Key Features
### User Interface Modernization
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.5.0
3.5.1
2 changes: 1 addition & 1 deletion lib/user-interface/react/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lisa-web",
"private": true,
"version": "3.5.0",
"version": "3.5.1",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
45 changes: 26 additions & 19 deletions lib/user-interface/react/src/components/chatbot/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,30 @@
limitations under the License.
*/

import { useState, useRef, useCallback, useEffect, useMemo } from 'react';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useAuth } from 'react-oidc-context';
import Form from '@cloudscape-design/components/form';
import Container from '@cloudscape-design/components/container';
import Box from '@cloudscape-design/components/box';
import { v4 as uuidv4 } from 'uuid';
import SpaceBetween from '@cloudscape-design/components/space-between';
import { Grid, TextContent, PromptInput, Autosuggest, ButtonGroup } from '@cloudscape-design/components';
import {
Autosuggest,
ButtonGroup,
ButtonGroupProps,
Grid,
PromptInput,
TextContent,
} from '@cloudscape-design/components';
import StatusIndicator from '@cloudscape-design/components/status-indicator';

import Message from './Message';
import { LisaChatMessage, LisaChatSession, LisaChatMessageMetadata } from '../types';
import { RESTAPI_URI, formatDocumentsAsString, RESTAPI_VERSION } from '../utils';
import { LisaChatMessage, LisaChatMessageMetadata, LisaChatSession } from '../types';
import { formatDocumentsAsString, RESTAPI_URI, RESTAPI_VERSION } from '../utils';
import { LisaChatMessageHistory } from '../adapters/lisa-chat-history';
import { ChatPromptTemplate, MessagesPlaceholder, PromptTemplate } from '@langchain/core/prompts';
import { RunnableSequence } from '@langchain/core/runnables';
import { StringOutputParser } from '@langchain/core/output_parsers';
import { BufferWindowMemory } from 'langchain/memory';
import RagControls, { RagConfig } from './RagOptions';
import { ContextUploadModal, RagUploadModal } from './FileUploadModals';
import { ChatOpenAI } from '@langchain/openai';
Expand All @@ -41,7 +47,7 @@ import { useLazyGetConfigurationQuery } from '../../shared/reducers/configuratio
import {
useGetSessionHealthQuery,
useLazyGetSessionByIdQuery,
useUpdateSessionMutation
useUpdateSessionMutation,
} from '../../shared/reducers/session.reducer';
import { useAppDispatch } from '../../config/store';
import { useNotificationService } from '../../shared/util/hooks';
Expand All @@ -51,6 +57,7 @@ import { baseConfig, GenerateLLMRequestParams, IChatConfiguration } from '../../
import { useLazyGetRelevantDocumentsQuery } from '../../shared/reducers/rag.reducer';
import { IConfiguration } from '../../shared/model/configuration.model';
import { DocumentSummarizationModal } from './DocumentSummarizationModal';
import { ChatMemory } from '../../shared/util/chat-memory';

export default function Chat ({ sessionId }) {
const dispatch = useAppDispatch();
Expand Down Expand Up @@ -94,7 +101,7 @@ export default function Chat ({ sessionId }) {
const [useRag, setUseRag] = useState(false);
const [ragConfig, setRagConfig] = useState<RagConfig>({} as RagConfig);
const [memory, setMemory] = useState(
new BufferWindowMemory({
new ChatMemory({
chatHistory: new LisaChatMessageHistory(session),
returnMessages: false,
memoryKey: 'history',
Expand Down Expand Up @@ -157,12 +164,11 @@ export default function Chat ({ sessionId }) {
const handleRagConfiguration = async (chainSteps: any[]) => {
const ragStep = {
input: ({ input }: { input: string }) => input,
chatHistory: () => memory.loadMemoryVariables({}),
chatHistory: () => memory.loadMemoryVariables(),
context: async (input: { input: string; chatHistory?: LisaChatMessage[] }) => {
const question = await getContextualizedQuestion(input);
const relevantDocs = await fetchRelevantDocuments(question);
const serialized = await updateSessionWithRagContext(relevantDocs);
return serialized;
return await updateSessionWithRagContext(relevantDocs);
},
};

Expand Down Expand Up @@ -218,7 +224,7 @@ export default function Chat ({ sessionId }) {
const handleNonRagConfiguration = (chainSteps: any[]) => {
const nonRagStep = {
input: (initialInput: any) => initialInput.input,
memory: () => memory.loadMemoryVariables({}),
memory: () => memory.loadMemoryVariables(),
context: () => fileContext || '',
humanPrefix: (initialInput: any) => initialInput.humanPrefix,
aiPrefix: (initialInput: any) => initialInput.aiPrefix,
Expand Down Expand Up @@ -376,7 +382,7 @@ export default function Chat ({ sessionId }) {

useEffect(() => {
setMemory(
new BufferWindowMemory({
new ChatMemory({
chatHistory: new LisaChatMessageHistory(session),
returnMessages: false,
memoryKey: 'history',
Expand All @@ -390,7 +396,7 @@ export default function Chat ({ sessionId }) {

useEffect(() => {
if (selectedModel && auth.isAuthenticated) {
memory.loadMemoryVariables({}).then(async (formattedHistory) => {
memory.loadMemoryVariables().then(async (formattedHistory) => {
const promptValues = {
input: userPrompt,
history: formattedHistory.history,
Expand Down Expand Up @@ -543,9 +549,9 @@ export default function Chat ({ sessionId }) {
<div ref={bottomRef} />
</SpaceBetween>
</div>
<div className='fixed bottom-8' style={{width: 'calc(var(--awsui-layout-width-g964ok) - 500px)'}}>
<div className='sticky bottom-8'>
<form onSubmit={(e) => e.preventDefault()}>
<Form variant='embedded'>
<Form>
<Container>
<SpaceBetween size='m' direction='vertical'>
<Grid
Expand All @@ -562,6 +568,7 @@ export default function Chat ({ sessionId }) {
empty={<div className='text-gray-500'>No models available.</div>}
filteringType='auto'
value={selectedModel?.modelId ?? ''}
enteredTextLabel={(text) => `Use: "${text}"`}
onChange={({ detail: { value } }) => {
if (!value || value.length === 0) {
setSelectedModel(undefined);
Expand Down Expand Up @@ -635,20 +642,20 @@ export default function Chat ({ sessionId }) {
id: 'upload-to-rag',
iconName: 'upload',
text: 'Upload to RAG'
}] : []),
}] as ButtonGroupProps.Item[] : []),
...(config?.configuration.enabledComponents.uploadContextDocs ?
[{
type: 'icon-button',
id: 'add-file-to-context',
iconName: 'insert-row',
text: 'Add file to context'
}] : []),
}] as ButtonGroupProps.Item[] : []),
...(config?.configuration.enabledComponents.documentSummarization ? [{
type: 'icon-button',
id: 'summarize-document',
iconName: 'transcript',
text: 'Summarize Document'
}] : []),
}] as ButtonGroupProps.Item[] : []),
...(config?.configuration.enabledComponents.editPromptTemplate ?
[{
type: 'menu-dropdown',
Expand All @@ -661,7 +668,7 @@ export default function Chat ({ sessionId }) {
text: 'Edit Prompt Template'
},
]
}] : [])
}] as ButtonGroupProps.Item[] : [])
]}
variant='icon'
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
*/

import {
Modal,
Autosuggest,
Box,
SpaceBetween,
Button,
FileUpload,
Modal,
SpaceBetween,
Textarea,
TextContent,
FileUpload, Autosuggest, Textarea,
} from '@cloudscape-design/components';
import { FileTypes, LisaChatSession } from '../types';
import { useEffect, useMemo, useState } from 'react';
Expand All @@ -32,9 +34,9 @@ import { handleUpload } from './FileUploadModals';
import { IChatConfiguration } from '../../shared/model/chat.configurations.model';
import { v4 as uuidv4 } from 'uuid';
import FormField from '@cloudscape-design/components/form-field';
import { BufferWindowMemory } from 'langchain/memory';
import { LisaChatMessageHistory } from '../adapters/lisa-chat-history';
import Toggle from '@cloudscape-design/components/toggle';
import { ChatMemory } from '../../shared/util/chat-memory';

export type DocumentSummarizationModalProps = {
showDocumentSummarizationModal: boolean;
Expand All @@ -51,7 +53,7 @@ export type DocumentSummarizationModalProps = {
setSession: (state: LisaChatSession) => void;
userName: string;
handleSendGenerateRequest: () => void;
setMemory: (state: BufferWindowMemory) => void;
setMemory: (state: ChatMemory) => void;
};

export function DocumentSummarizationModal ({
Expand Down Expand Up @@ -163,7 +165,7 @@ export function DocumentSummarizationModal ({
};
setSession(newSession);

setMemory(new BufferWindowMemory({
setMemory(new ChatMemory({
chatHistory: new LisaChatMessageHistory(newSession),
returnMessages: false,
memoryKey: 'history',
Expand Down Expand Up @@ -220,6 +222,7 @@ export function DocumentSummarizationModal ({
empty={<div className='text-gray-500'>No models available.</div>}
filteringType='auto'
value={selectedModel?.modelId ?? ''}
enteredTextLabel={(text) => `Use: "${text}"`}
onChange={({ detail: { value } }) => {
if (!value || value.length === 0) {
setSelectedModel(undefined);
Expand All @@ -243,6 +246,7 @@ export function DocumentSummarizationModal ({
placeholder='Select prompt type'
filteringType='auto'
value={selectedPromptType}
enteredTextLabel={(text) => `Use: "${text}"`}
onChange={({ detail: { value } }) => {
setUserPrompt('');
if (value && value.length !== 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default function RagControls ({isRunning, setUseRag, setRagConfig }: RagC
empty={<div className='text-gray-500'>No repositories available.</div>}
filteringType='auto'
value={selectedRepositoryOption ?? ''}
enteredTextLabel={(text) => `Use: "${text}"`}
onChange={({ detail }) => {
setSelectedRepositoryOption(detail.value);
setRagConfig((config) => ({
Expand All @@ -85,6 +86,7 @@ export default function RagControls ({isRunning, setUseRag, setRagConfig }: RagC
empty={<div className='text-gray-500'>No embedding models available.</div>}
filteringType='auto'
value={selectedEmbeddingOption ?? ''}
enteredTextLabel={(text) => `Use: "${text}"`}
onChange={({ detail }) => {
setSelectedEmbeddingOption(detail.value);

Expand Down
Loading

0 comments on commit 9105184

Please sign in to comment.