[PR #3413] [CLOSED] Fix building usercontext from memories #36869

Closed
opened 2026-04-25 10:35:29 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/3413
Author: @jh0ker
Created: 6/24/2024
Status: Closed

Base: devHead: fix/building-usercontext-from-memories


📝 Commits (1)

  • 1f30b63 fix: Add all results from queryMemory to userContext

📊 Changes

1 file changed (+3 additions, -3 deletions)

View changed files

📝 src/lib/components/chat/Chat.svelte (+3 -3)

📄 Description

Pull Request Checklist

Before submitting, make sure you've checked the following:

  • Target branch: Please verify that the pull request targets the dev branch.
  • Description: Provide a concise description of the changes made in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Have you written and run sufficient tests for validating the changes?
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Prefix: To cleary categorize this pull request, prefix the pull request title, using one of the following:
    • fix: Bug fix or error correction

Changelog Entry

Description

  • Fixed an issue only one memory was being used for building the user context, even if multiple were retrieved.

Fixed

  • Only one memory could be used for building the user context, even if multiple were retrieved

Additional Information

After @shadowdoggie found out how to change the number of queried memories from Chroma here, he noticed that models were still only ever referring to a single memory.

I was able to track it down to this part of the code in the frontend that would do a reduce on an array that seems to always have only one element. The data structure of the return type queryMemory in this case is for example

{
    "ids": [
        [
            "024afdfb-4964-427a-aaab-3a2e006cdb7f",
            "77a7e0c4-dc32-4e69-98df-fa1230b49b6e"
        ]
    ],
    "distances": [
        [
            0.9557429871345975,
            1.2739408007827933
        ]
    ],
    "metadatas": [
        [
            {
                "created_at": 1719259838
            },
            {
                "created_at": 1719259826
            }
        ]
    ],
    "embeddings": null,
    "documents": [
        [
            "The second word is \"grape\"",
            "The first word is \"automotive\""
        ]
    ],
    "uris": null,
    "data": null
}

I should note that this PR by itself does not allow the use of more than one memory, as the value for the number of memories queried remains hard coded to 1. Perhaps something for a future PR.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/3413 **Author:** [@jh0ker](https://github.com/jh0ker) **Created:** 6/24/2024 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/building-usercontext-from-memories` --- ### 📝 Commits (1) - [`1f30b63`](https://github.com/open-webui/open-webui/commit/1f30b635810d09bb4e0d3dd6c9d90a8d22791805) fix: Add all results from queryMemory to userContext ### 📊 Changes **1 file changed** (+3 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/components/chat/Chat.svelte` (+3 -3) </details> ### 📄 Description # Pull Request Checklist **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Please verify that the pull request targets the `dev` branch. - [x] **Description:** Provide a concise description of the changes made in this pull request. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [ ] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources? - [ ] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [ ] **Testing:** Have you written and run sufficient tests for validating the changes? - [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? - [x] **Prefix:** To cleary categorize this pull request, prefix the pull request title, using one of the following: - **fix**: Bug fix or error correction # Changelog Entry ### Description - Fixed an issue only one memory was being used for building the user context, even if multiple were retrieved. ### Fixed - Only one memory could be used for building the user context, even if multiple were retrieved --- ### Additional Information After @shadowdoggie found out how to change the number of queried memories from Chroma [here](https://github.com/open-webui/open-webui/blob/465c3a99879d34526f1c70ad89af44652e783e85/backend/apps/webui/routers/memories.py#L115), he noticed that models were still only ever referring to a single memory. I was able to track it down to this part of the code in the frontend that would do a `reduce` on an array that seems to always have only one element. The data structure of the return type `queryMemory` in this case is for example ```json { "ids": [ [ "024afdfb-4964-427a-aaab-3a2e006cdb7f", "77a7e0c4-dc32-4e69-98df-fa1230b49b6e" ] ], "distances": [ [ 0.9557429871345975, 1.2739408007827933 ] ], "metadatas": [ [ { "created_at": 1719259838 }, { "created_at": 1719259826 } ] ], "embeddings": null, "documents": [ [ "The second word is \"grape\"", "The first word is \"automotive\"" ] ], "uris": null, "data": null } ``` I should note that this PR by itself does not allow the use of more than one memory, as the value for the number of memories queried remains hard coded to 1. Perhaps something for a future PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-25 10:35:30 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#36869