θΏ™ζ˜―indexlocζδΎ›ηš„ζœεŠ‘οΌŒδΈθ¦θΎ“ε…₯任何密码
Skip to content

Conversation

@shatfield4
Copy link
Collaborator

Pull Request Type

  • ✨ feat
  • πŸ› fix
  • ♻️ refactor
  • πŸ’„ style
  • πŸ”¨ chore
  • πŸ“ docs

Relevant Issues

resolves #742

What is in this change?

Describe the changes in this PR that are impactful to the repo.

  • Refactor combineLikeSources function to create object that hold score instead of appending all text together to display to user
  • Show similarity scores for all chunks in citations
  • Improve UI to show citation chunks in a more user friendly way
  • Implement showing similarity score using tooltip

Additional Information

Add any other context about the Pull Request here that was not captured above.

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated
  • I have tested my code functionality
  • Docker build succeeds locally

@shatfield4 shatfield4 linked an issue Feb 21, 2024 that may be closed by this pull request
@review-agent-prime
Copy link

frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/Citation/index.jsx

Consider using React's useMemo hook to memoize the result of the combineLikeSources function. This will prevent unnecessary re-rendering and computation when the sources prop does not change.
Create Issue
See the diff
Checkout the fix

    const combinedSources = useMemo(() => combineLikeSources(sources), [sources]);
git fetch origin && git checkout -b ReviewBot/Impro-23jzurp origin/ReviewBot/Impro-23jzurp

Consider destructuring the properties of the chunk object in the map function. This will make the code more readable and easier to understand.
Create Issue
See the diff
Checkout the fix

    {chunks.map(({id, text, score}, idx) => (
      ...
    ))}
git fetch origin && git checkout -b ReviewBot/Impro-hx5zrw3 origin/ReviewBot/Impro-hx5zrw3

Consider checking if the chunks array is not empty before trying to access its first element. This will prevent unnecessary computation and potential errors.
Create Issue
See the diff
Checkout the fix

    if (!chunks.length || !chunks[0].chunkSource.startsWith("link://")) return nullResponse;
git fetch origin && git checkout -b ReviewBot/Impro-5r3czff origin/ReviewBot/Impro-5r3czff

@timothycarambat timothycarambat merged commit c87ef5b into master Feb 22, 2024
@timothycarambat timothycarambat deleted the 742-feat-show-chunk-score branch February 22, 2024 21:16
cabwds pushed a commit to cabwds/anything-llm that referenced this pull request Jul 3, 2025
* show similarity score in citation chunks

* refactor combine like sources to handle separate similarity scores and improve UI for displaying chunks

* fix parseChunkSource function to work with links

* destructure properties in chunks mapping

* check chunk length in parseChunkSource

* change UI on how score is shown

* remove duplicate import

---------

Co-authored-by: timothycarambat <rambat1010@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT]: Show Chunk score

3 participants