Skip to content
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

Add 1 memory endpoint for Retrieving Points #892

Merged
merged 4 commits into from
Sep 25, 2024

Conversation

dave90
Copy link
Contributor

@dave90 dave90 commented Aug 25, 2024

Description

This pull request introduces two new memory endpoints:

  • [GET] Retrieve all points from a single collection.
  • [GET] Retrieve all points from all collections.

The retrieval of points from a single collection is paginated using offset and limit parameters.

Usage Examples retrieve all points from a single collection using offset:

    limit = 10
    next_offset = ""
    collection = "declarative"

    while True:
        res = requests.get(
            f"http://localhost:1865/memory/collections/{collection}/points?limit={limit}&offset={next_offset}",
        )
        json = res.json()
        points = json["points"]
        next_offset = json["next_offset"]

        for point in points:
            payload = point["payload"]
            vector = point["vector"]
            print(payload)
            print(vector)
        
        if next_offset is None:
            break
   

Related to issue #889

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas

@dave90
Copy link
Contributor Author

dave90 commented Sep 4, 2024

@pieroit should I go ahead and remove the endpoint "[GET] Retrieve all points from all collections" as we discussed during the dev meeting?

@pieroit
Copy link
Member

pieroit commented Sep 4, 2024

@pieroit should I go ahead and remove the endpoint "[GET] Retrieve all points from all collections" as we discussed during the dev meeting?

Yes please :)

@dave90 dave90 changed the title Add 2 memory endpoints for Retrieving Points Add 1 memory endpoints for Retrieving Points Sep 11, 2024
@dave90 dave90 changed the title Add 1 memory endpoints for Retrieving Points Add 1 memory endpoint for Retrieving Points Sep 11, 2024
@pieroit pieroit merged commit 05f2375 into cheshire-cat-ai:develop Sep 25, 2024
2 checks passed
@pieroit
Copy link
Member

pieroit commented Sep 25, 2024

Thank you @dave90 and sorry for the dealy.
Merged with a few tweaks:

  • included the offset in the old VectorMemoryCollection.get_all_points method
  • procedural memory is not readable (let's see if a polemic is born out of this :D)
  • added test for missing or reserved (procedural) collection

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.

2 participants