Skip to content

Commit

Permalink
Merge pull request #239 from microsoft/dependabotchanges
Browse files Browse the repository at this point in the history
build: Dependabotchanges to Dev branch
  • Loading branch information
Roopan-Microsoft authored Dec 30, 2024
2 parents c572154 + d9a8fa0 commit d76019e
Show file tree
Hide file tree
Showing 19 changed files with 6,979 additions and 17,915 deletions.
5 changes: 5 additions & 0 deletions ClientAdvisor/App/frontend/__mocks__/react-markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ const mockNode = {
const mockProps = { className: 'language-javascript' };

const ReactMarkdown: React.FC<{ children: React.ReactNode , components: any }> = ({ children,components }) => {
if(!components.code){
components.code = ({ ...codeProps }) => {
return <div>Test Code text from markdown </div>
}
}
return <div data-testid="reactMockDown">
{components && components.code({ node: mockNode, ...mockProps })}
{children}</div>; // Simply render the children
Expand Down
18,460 changes: 3,310 additions & 15,150 deletions ClientAdvisor/App/frontend/package-lock.json

Large diffs are not rendered by default.

68 changes: 34 additions & 34 deletions ClientAdvisor/App/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev": "vite",
"build": "tsc && vite build",
"watch": "tsc && vite build --watch",
"test": "jest --coverage --verbose",
"test": "jest --coverage --verbose --runInBand",
"test:coverage": "jest --coverage --verbose --watchAll",
"lint": "npx eslint src",
"lint:fix": "npx eslint --fix",
Expand All @@ -16,66 +16,66 @@
"format": "npm run prettier:fix && npm run lint:fix"
},
"dependencies": {
"@fluentui/font-icons-mdl2": "^8.5.42",
"@fluentui/react": "^8.105.3",
"@fluentui/font-icons-mdl2": "^8.5.57",
"@fluentui/react": "^8.122.2",
"@fluentui/react-hooks": "^8.6.29",
"@fluentui/react-icons": "^2.0.195",
"dompurify": "^3.0.8",
"@fluentui/react-icons": "^2.0.270",
"dompurify": "^3.2.3",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.8.1",
"react-syntax-highlighter": "^15.5.0",
"react-router-dom": "^7.1.0",
"react-syntax-highlighter": "^15.6.1",
"react-uuid": "^2.0.0",
"rehype-raw": "^6.1.1",
"remark-gfm": "^3.0.1",
"remark-supersub": "^1.0.0",
"undici": "^5.0.0"
"rehype-raw": "^7.0.0",
"remark-gfm": "^4.0.0",
"remark-supersub": "^1.0.0"
},
"devDependencies": {
"@eslint/eslintrc": "^3.0.2",
"@eslint/js": "^9.1.1",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.17.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.1.0",
"@testing-library/user-event": "^14.5.2",
"@types/dompurify": "^3.0.5",
"@types/dompurify": "^3.2.0",
"@types/eslint-config-prettier": "^6.11.3",
"@types/jest": "^29.5.12",
"@types/lodash-es": "^4.17.12",
"@types/mocha": "^10.0.6",
"@types/node": "^20.14.1",
"@types/mocha": "^10.0.10",
"@types/node": "^22.10.2",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@types/react-syntax-highlighter": "^15.5.11",
"@types/react-syntax-highlighter": "^15.5.13",
"@types/testing-library__user-event": "^4.2.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vitejs/plugin-react": "^3.1.0",
"@typescript-eslint/eslint-plugin": "^6.4.0",
"@typescript-eslint/parser": "^6.4.0",
"@vitejs/plugin-react": "^4.3.4",
"dotenv": "^16.4.5",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard-with-typescript": "^43.0.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^12.1.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-n": "^16.0.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-promise": "^6.6.0",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-simple-import-sort": "^12.1.1",
"globals": "^15.0.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^15.2.2",
"lint-staged": "^15.2.11",
"msw": "2.2.2",
"prettier": "^3.2.5",
"react-markdown": "^8.0.0",
"react-markdown": "^9.0.1",
"react-test-renderer": "^18.2.0",
"string.prototype.replaceall": "^1.0.10",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"typescript": "^4.9.5",
"vite": "^4.1.5"
"typescript": "^5.3.3",
"vite": "^4.1.5",
"undici": "^5.0.0"
}
}
}
68 changes: 43 additions & 25 deletions ClientAdvisor/App/frontend/src/components/Answer/Answer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FormEvent, useContext, useEffect, useMemo, useState } from 'react'
import ReactMarkdown from 'react-markdown'
import ReactMarkdown, { Components, Options } from 'react-markdown'
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'
import { nord } from 'react-syntax-highlighter/dist/esm/styles/prism'
import { Checkbox, DefaultButton, Dialog, FontIcon, Stack, Text } from '@fluentui/react'
Expand Down Expand Up @@ -228,19 +228,38 @@ export const Answer = ({ answer, onCitationClicked }: Props) => {
)
}

const components = {
code({ node, ...props }: { node: any;[key: string]: any }) {
let language
if (props.className) {
const match = props.className.match(/language-(\w+)/)
language = match ? match[1] : undefined
const components: Components = {
a: ({ href, children, ...props }) => (
<a href={href} target="_blank" rel="noopener noreferrer" {...props}>
{children}
</a>
),
code({ inline, className, children, ...props }: {
inline?: boolean;
className?: string;
children?: React.ReactNode;
[key: string]: any
}) {
const match = /language-(\w+)/.exec(className || '');
// Handle inline and block code rendering
if (inline) {
return (
<code className={className} {...props}>
{children}
</code>
);
} else if (match) {
return (
<SyntaxHighlighter
style={nord}
language={match[1]}
PreTag="div"
{...props}
>
{String(children).replace(/\n$/, '')}
</SyntaxHighlighter>
);
}
const codeString = node.children[0].value ?? ''
return (
<SyntaxHighlighter style={nord} language={language} PreTag="div" {...props}>
{codeString}
</SyntaxHighlighter>
)
}
}
return (
Expand All @@ -249,18 +268,17 @@ export const Answer = ({ answer, onCitationClicked }: Props) => {
<Stack.Item>
<Stack horizontal grow>
<Stack.Item grow>
<ReactMarkdown
linkTarget="_blank"
remarkPlugins={[remarkGfm, supersub]}
rehypePlugins={[rehypeRaw]}
children={
SANITIZE_ANSWER
? DOMPurify.sanitize(parsedAnswer.markdownFormatText, { ALLOWED_TAGS: XSSAllowTags })
: parsedAnswer.markdownFormatText
}
className={styles.answerText}
components={components}
/>
<ReactMarkdown
remarkPlugins={[remarkGfm, supersub]}
rehypePlugins={[rehypeRaw]}
children={
SANITIZE_ANSWER
? DOMPurify.sanitize(parsedAnswer.markdownFormatText, { ALLOWED_TAGS: XSSAllowTags, ALLOWED_ATTR: ['href', 'target', 'rel'] })
: parsedAnswer.markdownFormatText
}
className={styles.answerText}
components={components}
/>
</Stack.Item>
<Stack.Item className={styles.answerHeader}>
{FEEDBACK_ENABLED && answer.message_id !== undefined && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,38 +121,40 @@ describe('ChatHistoryPanel Component', () => {
})

it('hides the dialog when cancel or close is clicked', async () => {
userEvent.setup()

const user = userEvent.setup();
const compState = {
chatHistory: [{ id: 1, message: 'Test Message' }],
chatHistoryLoadingState: ChatHistoryLoadingState.Success,
isCosmosDBAvailable: { cosmosDB: true, status: CosmosDBStatus.Working }
}

renderWithContext(<ChatHistoryPanel isLoading={false} />, compState)

const moreButton = screen.getByRole('button', { name: /clear all chat history/i })
fireEvent.click(moreButton)

const clearAllItem = await screen.findByRole('menuitem')
isCosmosDBAvailable: { cosmosDB: true, status: CosmosDBStatus.Working },
};
renderWithContext(<ChatHistoryPanel isLoading={false} />, compState);
const moreButton = screen.getByRole('button', { name: /clear all chat history/i });
fireEvent.click(moreButton);
const clearAllItem = await screen.findByRole('menuitem');
await act(() => {
userEvent.click(clearAllItem)
})

user.click(clearAllItem);
});
await waitFor(() =>
expect(screen.getByText(/are you sure you want to clear all chat history/i)).toBeInTheDocument()
)

const cancelButton = screen.getByRole('button', { name: /cancel/i })

await act(() => {
userEvent.click(cancelButton)
})

);

const cancelButton = screen.getByRole('button', { name: /cancel/i });
act(() => {
user.click(cancelButton);
});

await waitFor(() =>
expect(screen.queryByText(/are you sure you want to clear all chat history/i)).not.toBeInTheDocument()
)
})
{
expect(screen.queryByText(/are you sure you want to clear all chat history/i)).not.toBeInTheDocument()
}
);
});


test('handles API failure correctly', async () => {
// Mock historyDeleteAll to return a failed response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ interface CitationPanelProps {
onViewSource: (citation: Citation) => void;
}

const renderLink = (props: any) => {
return <a {...props} target="_blank" rel="noopener noreferrer" />;
};

export const CitationPanel: React.FC<CitationPanelProps> = ({ activeCitation, IsCitationPanelOpen, onViewSource }) => {


return (
<Stack.Item className={styles.citationPanel} tabIndex={0} role="tabpanel" aria-label="Citations Panel">
<Stack
Expand All @@ -41,11 +47,13 @@ export const CitationPanel: React.FC<CitationPanelProps> = ({ activeCitation, Is
</h5>
<div tabIndex={0}>
<ReactMarkdown
linkTarget="_blank"
className={styles.citationPanelContent}
children={DOMPurify.sanitize(activeCitation.content, { ALLOWED_TAGS: XSSAllowTags })}
remarkPlugins={[remarkGfm]}
rehypePlugins={[rehypeRaw]}
components={{
a: renderLink,
}}
/>
</div>
</Stack.Item>
Expand Down
4 changes: 2 additions & 2 deletions ClientAdvisor/App/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ python-dotenv==1.0.0
azure-cosmos==4.5.0
quart==0.19.9
uvicorn==0.24.0
aiohttp==3.9.2
gunicorn==20.1.0
gunicorn==22.0.0
aiohttp==3.10.2
quart-session==3.0.0
pymssql==2.3.0
httpx==0.28.0
Expand Down
4 changes: 2 additions & 2 deletions ClientAdvisor/App/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ python-dotenv==1.0.0
azure-cosmos==4.5.0
quart==0.19.9
uvicorn==0.24.0
aiohttp==3.9.2
gunicorn==20.1.0
gunicorn==22.0.0
aiohttp==3.10.2
quart-session==3.0.0
pymssql==2.3.0
httpx==0.28.0
Expand Down
8 changes: 4 additions & 4 deletions ClientAdvisor/AzureFunction/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

azure-functions
azurefunctions-extensions-http-fastapi==1.0.0b1
openai==1.55.3
semantic_kernel==1.0.4
pymssql==2.3.0
azure-search-documents==11.6.0b3
openai==1.58.1
semantic_kernel==1.17.1
pymssql==2.3.2
azure-search-documents==11.6.0b8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
msal==1.24.0b1
msal==1.31.1
azure-identity
pandas
azure-storage-file-datalake
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ openai
pypdf
# pyodbc
# tiktoken
msal[broker]==1.24.0b1
msal[broker]==1.31.1
azure-identity
azure-ai-textanalytics
azure-search-documents==11.6.0b3
azure-search-documents==11.6.0b8
azure-keyvault-secrets
pandas
pymssql
Expand Down
Loading

0 comments on commit d76019e

Please sign in to comment.