Skip to content

makes POST /activation/all support pagination#84

Open
anthonyduong9 wants to merge 1 commit intodedupe-get_activations_by_indexfrom
make-POST-activation-all-support-pagination
Open

makes POST /activation/all support pagination#84
anthonyduong9 wants to merge 1 commit intodedupe-get_activations_by_indexfrom
make-POST-activation-all-support-pagination

Conversation

@anthonyduong9
Copy link
Copy Markdown
Contributor

@anthonyduong9 anthonyduong9 commented Apr 27, 2025

Problem

  • For POST /activation/all, the request has a num_results property, but no offset property.
  • There's a TODO to return a better error for when ActivationAllPostRequest.sort_by_token_indexes has out of range indexes.

Fix

  • Adding an offset property in all.yaml.
  • Running make setup-all-inference VERSION=1.4.0.
  • Adding logic to use the offset and number of results, to slice results.
  • Replacing 500 with 400 for when ActivationAllPostRequest.sort_by_token_indexes has out of range indexes.

Testing

From apps/inference, I ran poetry run python start.py, then

curl -X POST http://127.0.0.1:5002/v1/activation/all \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "The narrative of ... unattainable.",
    "model": "gpt2-small",
    "source_set": "res-jb",
    "selected_sources": ["1-res-jb"],
    "sort_by_token_indexes": [4],
    "ignore_bos": true,
    "num_results": 5,
    "offset": 0
  }' | jq '.activations[].index'

, then

curl -X POST http://127.0.0.1:5002/v1/activation/all \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "The narrative of ... unattainable.",
    "model": "gpt2-small",
    "source_set": "res-jb",
    "selected_sources": ["1-res-jb"],
    "sort_by_token_indexes": [4],
    "ignore_bos": true,
    "num_results": 5,
    "offset": 4
  }' | jq '.activations[].index'

and

curl -X POST http://127.0.0.1:5002/v1/activation/all \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Short prompt",
    "model": "gpt2-small",
    "source_set": "res-jb",
    "selected_sources": ["1-res-jb"],
    "sort_by_token_indexes": [10],
    "ignore_bos": true,
    "num_results": 5,
    "offset": 0
  }'

.

Fixes #74

Depends on #80

@anthonyduong9 anthonyduong9 force-pushed the make-POST-activation-all-support-pagination branch 2 times, most recently from 566cbdc to 25729cc Compare May 5, 2025 07:28
@anthonyduong9 anthonyduong9 force-pushed the dedupe-get_activations_by_index branch from 0d684fb to bf93f2b Compare May 7, 2025 01:33
@anthonyduong9 anthonyduong9 force-pushed the make-POST-activation-all-support-pagination branch from 25729cc to 5381986 Compare May 7, 2025 01:33
@anthonyduong9 anthonyduong9 force-pushed the dedupe-get_activations_by_index branch from bf93f2b to 78a245e Compare August 14, 2025 02:45
@anthonyduong9 anthonyduong9 force-pushed the make-POST-activation-all-support-pagination branch from 5381986 to e1367a3 Compare August 14, 2025 23:08
@anthonyduong9 anthonyduong9 marked this pull request as ready for review August 14, 2025 23:11
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.

1 participant