-
Notifications
You must be signed in to change notification settings - Fork 7
Dalgo Migration: Add threads endpoints (thread creation+polling) #171
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
Conversation
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
jerome-white
left a comment
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.
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() |
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.
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
| 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 |
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.
do we need sqlite or we need something related to postgresql for testcases
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.
Oh sorry, I did not realize that I left a redundant code block
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