Dalgo Migration: Add threads endpoints (thread creation+polling)#171
Merged
AkhileshNegi merged 25 commits intomainfrom May 13, 2025
Merged
Dalgo Migration: Add threads endpoints (thread creation+polling)#171AkhileshNegi merged 25 commits intomainfrom
AkhileshNegi merged 25 commits intomainfrom
Conversation
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
jerome-white
approved these changes
May 9, 2025
Contributor
jerome-white
left a comment
There was a problem hiding this comment.
My comments are mostly stylistic; no show stoppers
|
|
||
| @patch("app.api.routes.threads.OpenAI") | ||
| def test_poll_run_and_prepare_response_completed(mock_openai, db): | ||
| mock_client = MagicMock() |
Contributor
There was a problem hiding this comment.
For now this is okay, but consider using the OpenAI mock library: https://mharrisb1.github.io/openai-responses-python/ In addition to their examples, the see the collections CRUD tests for more
AkhileshNegi
requested changes
May 9, 2025
AkhileshNegi
requested changes
May 13, 2025
Comment on lines
+9
to
+14
| def session(): | ||
| """Creates a new in-memory database session for each test.""" | ||
| engine = create_engine("sqlite://", echo=False) | ||
| SQLModel.metadata.create_all(engine) | ||
| with Session(engine) as session: | ||
| yield session |
Collaborator
There was a problem hiding this comment.
do we need sqlite or we need something related to postgresql for testcases
Collaborator
Author
There was a problem hiding this comment.
Oh sorry, I did not realize that I left a redundant code block
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Target issue is #172
Notes
New Endpoints
1. POST /threads/start
Purpose: Initiates an OpenAI thread with the user question and starts processing in a background task.
Behavior:
Sets up a new thread (or reuses an existing one).
Saves the thread_id and question in the ThreadResponse table.
Begins polling in the background and stores the result once complete.
Returns thread_id and status as processing.
2. GET /threads/result/{thread_id}
Purpose: Fetches the result of a thread by its thread_id.
Behavior:
If the thread is still being processed, returns status processing.
If the message is available, returns it along with status success.
Extra : Needed to make small changes in "test creds" file as well, as CI check was failing because of it