-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/answer explainability #96
Open
annalimm
wants to merge
82
commits into
main
Choose a base branch
from
feature/answer_explainability
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,463
−968
Open
Changes from all commits
Commits
Show all changes
82 commits
Select commit
Hold shift + click to select a range
9b0815f
working app version
annalimm 8b63f91
mocked answer
annalimm 441728b
working app version with added modules and Displayed in app mocked RA…
annalimm 4dfe8f7
working app version w/ mocked answer, pdf, working explanation proces…
annalimm 2bf541c
version with properly highlighted ideas in a RAG answer
annalimm 15e7ab7
getting rid of mocked answer ideas, first steps in fixing pages metadata
annalimm 81cc50c
cleaned unnecessary for testing funcs in App.tsx
annalimm a82c5f5
cleaned preproc. module; correctly rewritten response highlighting (i…
annalimm 4b9c31b
correct version for ChatWindow (to the previous commit)
annalimm 425ca99
multiple consise highlighted ideas in response
annalimm cd13f8c
improved prompt for llm splitting response by ideas
annalimm 90c156a
smaller file for testing
annalimm 3693c6f
cleaned ideas coloring logic
annalimm fa22f3d
cleaning response info
annalimm 43b3279
minor changes and unnecessary files cleanup
annalimm d787b73
added activeSourceId,fixed dissapearing of the source file after proc…
annalimm 40031c1
saving (pages) metadata during processing now works!
annalimm 990b1b4
minor logging changes
annalimm e52a6ea
first working steps for pdf/source highlighting
annalimm e9da80b
handling chunks existing on a few pages -> improved highlighting
annalimm 839f148
console issues are fixed
annalimm d1d2a87
resolve merge
dani2112 836daf4
add citations
dani2112 895d2eb
placeholder
dani2112 2b59f35
updated package
annalimm a0843c7
citations are added
annalimm 395b37d
implemented to lexio working version of idea highlighting
annalimm 90904e4
handling types carefully
annalimm 0cb2963
cleaning unnecessary message objects
annalimm f294c54
minor cleanup changes
annalimm 3be274d
removed per-page color indicators in retrieved-source window
annalimm cb697c0
cleaning types
annalimm d12c85f
new module for message highlighting
annalimm e6a793a
removed the highlight count display
annalimm 6ac3dbc
Merge branch 'main' into feature/answer_explainability
annalimm f0203f1
updated packacge lock file
annalimm c91513f
sbd package type definition
annalimm 76f5874
add missing color field in PDFHighlight tests
annalimm e6018d5
generic names
annalimm fdb6957
separate AssistantMarkdownContent into distinct module avoiding circu…
annalimm 3024618
replaced DOM-based highlighting with React components
annalimm bfa7059
reverted to restricted SourcesDisplay root styles
annalimm 40689d1
text highlighting using character positions instead of regex matching
annalimm d6f4c48
redundant code cleanup in SourceDisplay
annalimm 5278ee8
streamline highlight color handling and remove redundant color genera…
annalimm 31664c2
minor changes
annalimm 91c3609
original version of rag-state file
annalimm 5676d55
Citation structure refactoring
annalimm 0d43e0f
minor changes
annalimm 040ccd5
reduced redundancy in a StremChunk
annalimm 5be5434
package file minor cleanup
annalimm da29aa2
minor files cleanup
annalimm e776029
types module documentation minor changes
annalimm 1b18783
test types interface definitions changes
annalimm 22f2c5b
citationGenerator generic component
annalimm 5449dd3
implemented Citation linking mechanism
annalimm 5c09b4e
cleaner matching implementation
annalimm 03c7dc9
minor changes
annalimm 22688b6
minor cleanup
annalimm ff54599
minor format change
annalimm a52c515
simplify setSelectedSource and handle page updates directly in compon…
annalimm a709170
passing the page number instead of embedding it in a metadata object
annalimm 43e9082
minor changes
annalimm 6a86c60
PdfViewer cleaner version
annalimm 254ae4a
metadata handling before data handling
annalimm 283c635
formatting changes
annalimm 04f50cc
formatting
annalimm 78e96ff
formatting
annalimm 1205b01
MessageHighlight type constraint
annalimm efe09ab
citations is now able to be returned asynchronously
annalimm a33c2a9
formatting minor changes
annalimm 7b9fb00
removed the text property from messageHighlights
annalimm 0c409ba
citations w/ both types of highlights inputs (chars/ text)
annalimm 71dd65a
soft dependency approach for the explainability-related libraries
annalimm 6fed05a
sbd lib soft dependency
annalimm 8ff5ed6
openai lib soft dependency
annalimm e7eb40b
fixed TypeScript errors
annalimm 05faf64
REST API for explanation features
annalimm a30e843
vite_config file reverting changes
annalimm 543b5d1
minor cleanup
annalimm 14196a0
minor types change
annalimm cb35948
rag-state cleanup
annalimm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ dummy-package/ | |
|
||
.vscode/ | ||
|
||
examples/llama-index/frontend/rag-ui/ | ||
examples/llama-index/frontend/rag-ui/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,12 @@ | |
# Coverage Reports | ||
coverage | ||
|
||
# Environment Variables | ||
.env.local | ||
|
||
# PDF Files | ||
pdfs/ | ||
|
||
# Logs | ||
logs | ||
*.log | ||
|
111 changes: 111 additions & 0 deletions
111
lexio/lib/components/ChatWindow/AssistantMarkdownContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import React from "react"; | ||
import {ChatWindowStyles} from "./ChatWindow"; | ||
import Markdown from "react-markdown"; | ||
import {Light as SyntaxHighlighter} from "react-syntax-highlighter"; | ||
import {docco} from "react-syntax-highlighter/dist/esm/styles/hljs"; | ||
import remarkGfm from "remark-gfm"; | ||
import {ClipboardIcon, ClipboardDocumentIcon} from "@heroicons/react/24/outline"; | ||
|
||
/** | ||
* Props for the AssistantMarkdownContent component. | ||
* @typedef {Object} AssistantMarkdownContentProps | ||
* @property {string} content - The markdown content to render. | ||
* @property {ChatWindowStyles} style - Styling options for the chat window. | ||
*/ | ||
interface AssistantMarkdownContentProps { | ||
content: string; | ||
style: ChatWindowStyles; | ||
} | ||
|
||
/** | ||
* Renders markdown content with enhanced features such as syntax highlighting and copy functionality. | ||
* | ||
* @param {AssistantMarkdownContentProps} props - The props for the component. | ||
* @returns {JSX.Element} The rendered markdown content. | ||
* | ||
* @internal | ||
*/ | ||
export const AssistantMarkdownContent: React.FC<AssistantMarkdownContentProps> = ({content, style}) => { | ||
return ( | ||
<Markdown | ||
components={{ | ||
/** | ||
* Custom renderer for code blocks to include syntax highlighting and a copy button. | ||
* | ||
* @param {Object} props - Properties passed to the code component. | ||
* @param {Object} props.node - The AST node. | ||
* @param {string} props.className - The class name for the code block. | ||
* @param {React.ReactNode} props.children - The code content. | ||
* @returns {JSX.Element} The customized code block. | ||
*/ | ||
code({node, className, children, ...props}) { | ||
const match = /language-(\w+)/.exec(className || ''); | ||
const language = match ? match[1] : 'plaintext'; | ||
const [copied, setCopied] = React.useState(false); | ||
|
||
/** | ||
* Handles copying the code content to the clipboard. | ||
*/ | ||
const handleCopy = () => { | ||
navigator.clipboard.writeText(String(children)); | ||
setCopied(true); | ||
setTimeout(() => { | ||
setCopied(false); | ||
}, 3000); // Reset copied state after 3 seconds | ||
} | ||
|
||
// Block code (triple ```) | ||
return ( | ||
<div style={{ | ||
position: 'relative', | ||
marginBottom: '1rem' | ||
}} {...(props as React.HTMLProps<HTMLDivElement>)}> | ||
{match && ( | ||
<div | ||
style={{ | ||
marginLeft: '0.33rem', | ||
fontSize: 'var(--font-size-small)', | ||
fontWeight: 'bold', | ||
background: '#f5f5f5', | ||
padding: '0 8px', | ||
borderTopLeftRadius: '5px', | ||
borderTopRightRadius: '5px', | ||
borderBottom: '1px solid #ccc', | ||
display: 'inline-block', | ||
}} | ||
> | ||
{language} | ||
</div> | ||
)} | ||
<div className="relative"> | ||
<SyntaxHighlighter | ||
style={docco} | ||
language={language} | ||
PreTag="div" | ||
wrapLongLine={true} | ||
> | ||
{String(children).replace(/\n$/, '')} | ||
</SyntaxHighlighter> | ||
|
||
<div | ||
className="absolute top-1 right-1 px-1.5 pt-0.5 text-sm rounded-md hover:shadow-md " | ||
style={{ | ||
backgroundColor: style.messageBackgroundColor, | ||
}} | ||
> | ||
<button | ||
onClick={handleCopy} | ||
> | ||
{copied ? <ClipboardDocumentIcon className={"w-5 h-5"} /> : <ClipboardIcon className={"w-5 h-5"} />} | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}, | ||
}} | ||
remarkPlugins={[remarkGfm]}> | ||
{content} | ||
</Markdown> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems to diable current renderer. consider checking if current renderer can still be used when having highlights. either by making the renderer have clickable highlights natively or having some overlay mechanism that overlays certain content in the existing renderd content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still an issue. you render either highlighted contnet or markdown content. can we render highlighted markdown content? see idea with overlay mechanism? could be lightweight addition to current renderer.