[PR #444] [MERGED] Add FewShotExamples managed value (redo) #1469

Closed
opened 2026-02-20 17:44:48 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langgraph/pull/444
Author: @andrewnguonly
Created: 5/13/2024
Status: Merged
Merged: 5/14/2024
Merged by: @nfcampos

Base: mainHead: an/10may/few-shot-clone


📝 Commits (10+)

  • dcb7278 Add search and asearch APIs to BaseCheckpointerSaver class. Implement search and asearch in MemorySaver.
  • 9b1efe9 Implement search() for SqliteSaver.
  • 7a8cbe1 Implement asearch() in AsyncSqliteSaver.
  • aae0540 Lint code.
  • 065e0ff Remove unused imports.
  • c800904 Copy learning.ipynb.
  • d6d33f9 Fix bug with WHERE clause being incorrect when passing before param.
  • 44c6b41 Update implementation of MemorySaver.asearch() to not use custom next_item() iterator function.
  • 0093b77 Remove extra blank line.
  • 3f34b03 Wow. Adding back extra blank line.

📊 Changes

15 files changed (+1774 additions, -60 deletions)

View changed files

examples/learning.ipynb (+648 -0)
📝 langgraph/checkpoint/aiosqlite.py (+45 -1)
📝 langgraph/checkpoint/base.py (+24 -0)
📝 langgraph/checkpoint/memory.py (+75 -0)
📝 langgraph/checkpoint/sqlite.py (+139 -1)
📝 langgraph/managed/base.py (+55 -30)
langgraph/managed/few_shot.py (+87 -0)
📝 langgraph/pregel/__init__.py (+20 -21)
📝 langgraph/pregel/read.py (+3 -3)
tests/checkpoint/__init__.py (+0 -0)
tests/checkpoint/test_aiosqlite.py (+79 -0)
tests/checkpoint/test_memory.py (+107 -0)
tests/checkpoint/test_sqlite.py (+111 -0)
📝 tests/test_pregel.py (+221 -3)
📝 tests/test_pregel_async.py (+160 -1)

📄 Description

Summary

This PR is a reimplementation of the old "Add FewShotExamples managed value" PR. A new PR is created because there are merge conflicts with the old PR. The changes in this PR are mostly derived from the old PR with a few noted exceptions.

Implementation

  1. Add score field to CheckpointMetadata. Clients can specify a score for a checkpoint to mark a thread as "good". This is different from the old PR.
  2. Add search() and asearch() APIs to BaseCheckpointSaver for searching checkpoints by metadata without filtering on thread_id. Implement the APIs in MemorySaver, SqliteSaver, and AsyncSqliteSaver. The implementation is mostly copied from the list() method. The old PR implemented an API called list_w_score().
  3. Copy FewShotExamples class from the old PR.
  4. Copy the tests from the old PR.
  5. Copy learning.ipynb from the old PR.

To Do


🔄 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/langchain-ai/langgraph/pull/444 **Author:** [@andrewnguonly](https://github.com/andrewnguonly) **Created:** 5/13/2024 **Status:** ✅ Merged **Merged:** 5/14/2024 **Merged by:** [@nfcampos](https://github.com/nfcampos) **Base:** `main` ← **Head:** `an/10may/few-shot-clone` --- ### 📝 Commits (10+) - [`dcb7278`](https://github.com/langchain-ai/langgraph/commit/dcb7278c5678db08e84b6ec2593cc9b7bdc2a7ec) Add search and asearch APIs to BaseCheckpointerSaver class. Implement search and asearch in MemorySaver. - [`9b1efe9`](https://github.com/langchain-ai/langgraph/commit/9b1efe969808ba12a2668a77e1a4b2e9e38a06ea) Implement search() for SqliteSaver. - [`7a8cbe1`](https://github.com/langchain-ai/langgraph/commit/7a8cbe18f954323b06c30f6c52a81c62e15b02b4) Implement asearch() in AsyncSqliteSaver. - [`aae0540`](https://github.com/langchain-ai/langgraph/commit/aae05407f4006a22e3490a82b531ccf0123e023b) Lint code. - [`065e0ff`](https://github.com/langchain-ai/langgraph/commit/065e0ff36066e4232436b866d5f49e968db5486d) Remove unused imports. - [`c800904`](https://github.com/langchain-ai/langgraph/commit/c80090465ffd1cf75be3d53be2ab0d102af5aebf) Copy learning.ipynb. - [`d6d33f9`](https://github.com/langchain-ai/langgraph/commit/d6d33f9551d825005b16a30fa99262d4f84266a6) Fix bug with WHERE clause being incorrect when passing before param. - [`44c6b41`](https://github.com/langchain-ai/langgraph/commit/44c6b414c3bbaa933b8a4351915f549ef25576e8) Update implementation of MemorySaver.asearch() to not use custom next_item() iterator function. - [`0093b77`](https://github.com/langchain-ai/langgraph/commit/0093b773f02990b73e6314c49b006c55f9a0b3a4) Remove extra blank line. - [`3f34b03`](https://github.com/langchain-ai/langgraph/commit/3f34b03ba1697203b6e179ca74fc8d97cedd5fe3) Wow. Adding back extra blank line. ### 📊 Changes **15 files changed** (+1774 additions, -60 deletions) <details> <summary>View changed files</summary> ➕ `examples/learning.ipynb` (+648 -0) 📝 `langgraph/checkpoint/aiosqlite.py` (+45 -1) 📝 `langgraph/checkpoint/base.py` (+24 -0) 📝 `langgraph/checkpoint/memory.py` (+75 -0) 📝 `langgraph/checkpoint/sqlite.py` (+139 -1) 📝 `langgraph/managed/base.py` (+55 -30) ➕ `langgraph/managed/few_shot.py` (+87 -0) 📝 `langgraph/pregel/__init__.py` (+20 -21) 📝 `langgraph/pregel/read.py` (+3 -3) ➕ `tests/checkpoint/__init__.py` (+0 -0) ➕ `tests/checkpoint/test_aiosqlite.py` (+79 -0) ➕ `tests/checkpoint/test_memory.py` (+107 -0) ➕ `tests/checkpoint/test_sqlite.py` (+111 -0) 📝 `tests/test_pregel.py` (+221 -3) 📝 `tests/test_pregel_async.py` (+160 -1) </details> ### 📄 Description ### Summary This PR is a reimplementation of the [old "Add FewShotExamples managed value" PR](https://github.com/langchain-ai/langgraph/pull/332). A new PR is created because there are merge conflicts with the old PR. The changes in this PR are mostly derived from the old PR with a few noted exceptions. ### Implementation 1. Add `score` field to `CheckpointMetadata`. Clients can specify a score for a checkpoint to mark a thread as "good". This is different from the old PR. 1. Add `search()` and `asearch()` APIs to `BaseCheckpointSaver` for searching checkpoints by metadata without filtering on `thread_id`. Implement the APIs in `MemorySaver`, `SqliteSaver`, and `AsyncSqliteSaver`. The implementation is mostly copied from the `list()` method. The old PR implemented an API called `list_w_score()`. 1. Copy `FewShotExamples` class from the old PR. 1. Copy the tests from the old PR. 1. Copy `learning.ipynb` from the old PR. ### To Do - [x] Run the `learning.ipynb` notebook. - [x] Close PR https://github.com/langchain-ai/langgraph/pull/332. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-20 17:44:48 -05:00
yindo closed this issue 2026-02-20 17:44:48 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#1469