user feeback validation changes LCORE-197#93
Conversation
lpiwowar
left a comment
There was a problem hiding this comment.
Really solid start!:) 💪 You were really quick with proposing the PR. Let's iterate on this:).
Also, two tips:
- How to write a good commit message -> https://cbea.ms/git-commit/
- You should add a proof of testing comment that showcases how you tested your change. I've learnt this from Chris. He writes nice proofs of testing comments [1]. It is a requirement for this repo:
| @@ -0,0 +1 @@ | |||
| {"user_id": "user_id_placeholder", "timestamp": "2025-06-09 22:19:56.810345+00:00", "conversation_id": "12345678-abcd-0000-0123-456789abcdef", "user_question": "sasddfghlljhkgfdghjkl;kjhgfdfghjklkjhiugyftdsfghjkliuyftdrsadtfyuiopiuytrsdfghj", "llm_response": "bar", "sentiment": 1, "user_feedback": "Great service!"} No newline at end of file | |||
There was a problem hiding this comment.
We probably do not want to include the /data folder:).
There was a problem hiding this comment.
Indeed, needs to be removed from the commit
tests/unit/models/test_requests.py
Outdated
| with pytest.raises(ValidationError) as exc_info: | ||
| FeedbackRequest( | ||
| conversation_id="123e4567-e89b-12d3-a456-426614174000", | ||
| user_question="What is OpenStack?", | ||
| llm_response="OpenStack is a cloud computing platform.", | ||
| user_feedback="x" * 4097, | ||
| ) | ||
| assert "should have at most 4096 characters" in str(exc_info.value) |
There was a problem hiding this comment.
Indentation needs to be fixed:). Also, you can probably use match in pytest.rases() . You can check out the test above [1].
src/app/main.py
Outdated
| async def startup_event() -> None: | ||
| """Perform logger setup on service startup.""" | ||
| get_logger("app.endpoints.handlers") | ||
| get_logger("app.endpoints.handlers") No newline at end of file |
There was a problem hiding this comment.
Indent should be fixed and new line at the end of the file is missing.
src/models/requests.py
Outdated
| min_length=1, | ||
| max_length=4096, | ||
| description="Maximum length of user feedback is 4096 characters long.", | ||
| examples=["How to Set Up Kubernetes?"], |
There was a problem hiding this comment.
The example field should most likely contain something like this:
| examples=["How to Set Up Kubernetes?"], | |
| examples=["I'm not satisfied with the response because it is too vague."], |
You can of course come up with something else. Just an idea:)
src/models/requests.py
Outdated
| default=None, | ||
| min_length=1, | ||
| max_length=4096, | ||
| description="Maximum length of user feedback is 4096 characters long.", |
There was a problem hiding this comment.
I think the descriptions field is mostly meant to be used for describing the purpose of the field. I think we can drop the information about the maximum length here. What do you think?
| description="Maximum length of user feedback is 4096 characters long.", | |
| description="Feedback on the LLM response.", |
src/models/requests.py
Outdated
| # Optional user feedback limited to 1–4096 characters to prevent abuse. | ||
| user_feedback: Optional[str] = Field( | ||
| default=None, | ||
| min_length=1, |
There was a problem hiding this comment.
From where I stand, I think we shouldn't be enforcing a min_length on the user_feedback. Maybe the lightspeed-core team has a different opinion on this but for now I would probably remove it.
| min_length=1, |
| @@ -1,5 +1,5 @@ | |||
| import pytest | |||
|
|
|||
| from pydantic import ValidationError | |||
There was a problem hiding this comment.
I would keep the empty line here:).
| from pydantic import ValidationError | |
| import pytest | |
| from pydantic import ValidationError | |
| from models.requests import QueryRequest, Attachment, FeedbackRequest |
From PEP-8:
Imports should be grouped in the following order:
1. Standard library imports.
2. Related third party imports.
3. Local application/library specific imports.
You should put a blank line between each group of imports.
There was a problem hiding this comment.
thanks @lpiwowar for review! Agree with your comments
tisnik
left a comment
There was a problem hiding this comment.
pls. remove those /data/* files. TYVM
| @@ -0,0 +1 @@ | |||
| {"user_id": "user_id_placeholder", "timestamp": "2025-06-09 22:19:56.810345+00:00", "conversation_id": "12345678-abcd-0000-0123-456789abcdef", "user_question": "sasddfghlljhkgfdghjkl;kjhgfdfghjklkjhiugyftdsfghjkliuyftdrsadtfyuiopiuytrsdfghj", "llm_response": "bar", "sentiment": 1, "user_feedback": "Great service!"} No newline at end of file | |||
There was a problem hiding this comment.
Indeed, needs to be removed from the commit
src/models/requests.py
Outdated
| default=None, | ||
| min_length=1, | ||
| max_length=4096, | ||
| description="Maximum length of user feedback is 4096 characters long.", |
tests/unit/models/test_requests.py
Outdated
|
|
||
| def test_user_feedback_too_short(self) -> None: | ||
| """Test that user_feedback shorter than 1 character raises ValidationError.""" | ||
| with pytest.raises(ValidationError) as exc_info: |
There was a problem hiding this comment.
Identation here is off.
Btw, unit-tests can be run locally as:
$ pdm test-unit
src/models/requests.py
Outdated
| # Optional user feedback limited to 1–4096 characters to prevent abuse. | ||
| user_feedback: Optional[str] = Field( | ||
| default=None, | ||
| min_length=1, |
|
now it's much better. Pls just rerun |
src/app/main.py
Outdated
| async def startup_event() -> None: | ||
| """Perform logger setup on service startup.""" | ||
| get_logger("app.endpoints.handlers") | ||
| get_logger("app.endpoints.handlers") |
There was a problem hiding this comment.
This change is outside the scope of the change
And get rid of the data/feedback pls (-: |

## Description
Type of change
Related Tickets & Documents
Checklist before requesting a review
Testing