-
Notifications
You must be signed in to change notification settings - Fork 56
Use correct status codes for /query endpoint #776
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
f20305b
9a4298c
753e3e9
c5bcb25
14b1227
0d2d85b
977825e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| --- | ||
| # A run configuration for lightspeed-stack that defines no models. | ||
| # Used for E2E testing. | ||
| llm: | ||
| mode: "library" | ||
| model_name: "" | ||
| model_provider: "" | ||
| api_key: "EMPTY" | ||
| parameters: | ||
| max_new_tokens: 256 | ||
| server: | ||
| host: "0.0.0.0" | ||
| port: 8080 | ||
| url: "http://llama-stack:8080" | ||
| lightspeed_stack: | ||
| server: | ||
| host: "0.0.0.0" | ||
| port: 8008 | ||
| logging: | ||
| level: "INFO" | ||
| style: "default" | ||
| model_defaults: | ||
| provider: "openai" | ||
| model: "gpt-4-turbo" | ||
| providers: | ||
| - name: "openai" | ||
| api_key: "EMPTY" | ||
| url: "http://llama-stack:8080" | ||
| type: "openai" | ||
| models: [] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,13 +53,43 @@ Feature: Query endpoint API tests | |
| """ | ||
| {"query": "Write a simple code for reversing string"} | ||
| """ | ||
| Then The status code of the response is 400 | ||
| Then The status code of the response is 401 | ||
| And The body of the response is the following | ||
| """ | ||
| {"detail": "No Authorization header found"} | ||
| """ | ||
|
|
||
| Scenario: Check if LLM responds to sent question with error when authenticated with invalid token | ||
| Given The service is started locally | ||
| And REST API service prefix is /v1 | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Given The system is in default state | ||
| And I set the Authorization header to Bearer invalid | ||
| When I use "query" to ask question with authorization header | ||
| """ | ||
| {"query": "Write a simple code for reversing string"} | ||
| """ | ||
| Then The status code of the response is 401 | ||
| And The body of the response is the following | ||
| """ | ||
| {"detail":"Invalid token: decode error"} | ||
| """ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The above scenario fails (returns 200) because "Bearer invalid" is actually a valid token - everything that matches "Bearer something" is valid token.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you actually want to test invalid bearer token, write something like BearerInvalid, Invalid or whatever you want. When you use Bearer with anything, it always passes the check |
||
|
|
||
| Scenario: Check if LLM responds to sent question with error when model does not exist | ||
| Given The service is started locally | ||
| And REST API service prefix is /v1 | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Given The system is in default state | ||
| And I set the Authorization header to Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Ikpva | ||
| When I use "query" to ask question with authorization header | ||
| """ | ||
| {"query": "Write a simple code for reversing string", "model": "does-not-exist", "provider": "does-not-exist"} | ||
| """ | ||
| Then The status code of the response is 404 | ||
| And The body of the response contains Model does-not-exist from provider does-not-exist not found in available models | ||
|
|
||
|
|
||
| Scenario: Check if LLM responds to sent question with error when attempting to access conversation | ||
| Given The service is started locally | ||
| And REST API service prefix is /v1 | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Given The system is in default state | ||
| And I set the Authorization header to Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Ikpva | ||
| When I use "query" to ask question with authorization header | ||
|
|
@@ -138,3 +168,14 @@ Scenario: Check if LLM responds for query request with error for missing query | |
| } | ||
| """ | ||
| Then The status code of the response is 200 | ||
|
|
||
| @no_models | ||
| Scenario: Check if LLM responds with an error when no models are configured | ||
| Given The system is in default state | ||
| And I set the Authorization header to Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Ikpva | ||
| When I use "query" to ask question with authorization header | ||
| """ | ||
| {"query": "Write a simple code for reversing string"} | ||
| """ | ||
| Then The status code of the response is 404 | ||
| And The body of the response contains No models available | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not valid config for lightspeed-stack.