Skip to content

Fix get_thresholds route argument handling#139

Open
aaronaco wants to merge 1 commit into
IBM:mainfrom
aaronaco:fix/get-thresholds-route
Open

Fix get_thresholds route argument handling#139
aaronaco wants to merge 1 commit into
IBM:mainfrom
aaronaco:fix/get-thresholds-route

Conversation

@aaronaco

@aaronaco aaronaco commented May 7, 2026

Copy link
Copy Markdown

Summary

Fixes the documented GET /get_thresholds endpoint so it no longer returns 500 Internal Server Error when called from Swagger UI.

The route previously read prompt while Swagger documents prompts, then passed raw Hugging Face API URL/header values into recommendation_handler.get_thresholds(). That helper expects an embedding function as its third argument.

Changes

  • Read repeated prompts query parameters from /get_thresholds
  • Return 400 when prompt samples are missing or empty
  • Build a local embedding function before calling recommendation_handler.get_thresholds()
  • Update Swagger docs to describe repeated prompts query parameters
  • Add focused route tests for /get_thresholds

Testing

uv run pytest -q

Result:

6 passed

Manual Swagger test:

curl -X GET \
  'http://127.0.0.1:8080/get_thresholds?prompts=Act%20as%20a%20data%20scientist.%20Help%20me%20make%20this%20project%20more%20inclusive.&prompts=What%20evidence%20should%20I%20gather%20to%20support%20my%20request%20for%20more%20resources%3F' \
  -H 'accept: */*' \
  -H 'model_id: sentence-transformers/all-minilm-l6-v2'

Returned threshold JSON successfully:

{
  "add_higher_threshold": 0.5,
  "add_lower_threshold": 0.5,
  "remove_higher_threshold": 0.5,
  "remove_lower_threshold": 0.3
}

Issue

Fixes #138

Signed-off-by: Aaron A. <aaronacodev@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.

/get_thresholds returns 500 due to route/helper argument mismatch

1 participant