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

feat: add support for user_id in header #1755

Merged
merged 3 commits into from
Sep 13, 2024
Merged

feat: add support for user_id in header #1755

merged 3 commits into from
Sep 13, 2024

Conversation

cpacker
Copy link
Collaborator

@cpacker cpacker commented Sep 13, 2024

Please describe the purpose of this pull request.

Adds basic support for reading user_id from the header of the HTTP request.

Note: implementation is not thread safe and will be / needs to be refactored alongside the stateless server refactor.

How to test.

Test no header:

$ curl --request GET \
     --url http://localhost:8283/v1/models/ \
     --header 'accept: application/json'
[{"model":"gpt-4","model_endpoint_type":"openai","model_endpoint":"https://api.openai.com/v1","model_wrapper":null,"context_window":8192}]%

Test header with bad ID (no user exists):

$ curl --request GET \
     --url http://localhost:8283/v1/models/ \
     --header 'accept: application/json' \
     --header 'user_id: 0x0'
{"detail":"User with id 0x0 not found"}%

Test header with existing ID (the config one):

[client]
anon_clientid = user-6122fbc6-ef57-413e-a84c-7965f42151fe
$  curl --request GET \
     --url http://localhost:8283/v1/models/ \
     --header 'accept: application/json' \
     --header 'user_id: user-6122fbc6-ef57-413e-a84c-7965f42151fe'
[{"model":"gpt-4","model_endpoint_type":"openai","model_endpoint":"https://api.openai.com/v1","model_wrapper":null,"context_window":8192}]%

@cpacker cpacker merged commit 7e70082 into main Sep 13, 2024
12 checks passed
@cpacker cpacker deleted the add-user-in-header branch September 13, 2024 22:21
mattzh72 pushed a commit that referenced this pull request Oct 9, 2024
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