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

error handling for /stream endpoints #914

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

sarfarazsiddiquii
Copy link
Contributor

@sarfarazsiddiquii sarfarazsiddiquii commented Apr 9, 2024

This PR (ref #910) addresses both frontend and application aspects of implementing error handling for the /stream endpoint.

It enables the frontend to display meaningful error messages when errors occur during streaming, while the backend ensures proper wrapping of the stream function to handle and stream error types back to the frontend.

during my first PR i overlooked some tests, in this PR the failed tests issue is resolved.

Copy link

vercel bot commented Apr 9, 2024

@sarfarazsiddiquii is attempting to deploy a commit to the Arc53 Team on Vercel.

A member of the Team first needs to authorize it.

dependabot bot added 2 commits April 9, 2024 14:22
Bumps [pymongo](https://github.com/mongodb/mongo-python-driver) from 4.6.1 to 4.6.3.
- [Release notes](https://github.com/mongodb/mongo-python-driver/releases)
- [Changelog](https://github.com/mongodb/mongo-python-driver/blob/master/doc/changelog.rst)
- [Commits](mongodb/mongo-python-driver@4.6.1...4.6.3)

---
updated-dependencies:
- dependency-name: pymongo
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Removes [tar](https://github.com/isaacs/node-tar). It's no longer used after updating ancestor dependency [npm](https://github.com/npm/cli). These dependencies need to be updated together.


Removes `tar`

Updates `npm` from 10.5.0 to 10.5.1
- [Release notes](https://github.com/npm/cli/releases)
- [Changelog](https://github.com/npm/cli/blob/latest/CHANGELOG.md)
- [Commits](npm/cli@v10.5.0...v10.5.1)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: indirect
- dependency-name: npm
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
@dartpain
Copy link
Contributor

dartpain commented Apr 10, 2024

Can you rebase your commit to sync with the latest version please, so that we can avoid branch conflicts.
Thank you!

@sarfarazsiddiquii
Copy link
Contributor Author

@dartpain, thank you for your response. I have rebased my commits as requested.

Please let me know if there are any further changes needed for this PR.

Copy link
Contributor

@dartpain dartpain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think some stuff was lost due to rebase.
Please check out the retriever part.
Now answers are generated using retrievers.

Thank you!

context = messages[0]['content']
user_question = messages[-1]['content']
prompt = f"### Instruction \n {user_question} \n ### Context \n {context} \n ### Answer \n"
def gen_stream(self, model, engine, messages, stream=True, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We removed the engine here recently


retriever = RetrieverCreator.create_retriever(retriever_name, question=question,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think during rebase you have removed some recent changes.
We should be using retrievers now for generating answers

@sarfarazsiddiquii
Copy link
Contributor Author

Thank you, @dartpain , for pointing out the issues with the retriever integration and the removal of the engine. I'm sorry for the oversight during the rebase process. The issue should be fixed in my latest commit.

@dartpain
Copy link
Contributor

Thank you so much, final thing would be:
to adapt FAILED tests/test_error.py::test_bad_request_without_message
in the tests file now.

@sarfarazsiddiquii
Copy link
Contributor Author

Thanks, @dartpain , for the feedback. After the last commit, everything looks fine. I have updated tests/test_error.py::test_response_error_without_message and tests/test_error.py::test_bad_request_without_message to match the expected error message outputs.

Copy link

vercel bot commented Apr 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-gpt ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 18, 2024 8:10am

@dartpain
Copy link
Contributor

So I captured this error when I tried making a request, although its not dispayed on Frontend Im happy to see that it was logged
CleanShot 2024-04-15 at 11 40 23@2x

But the error is due to this change:
CleanShot 2024-04-15 at 11 42 47@2x

…multi-4407677fd1

build(deps): bump tar and npm in /docs
…mongo-4.6.3

Bump pymongo from 4.6.1 to 4.6.3 in /application
@sarfarazsiddiquii
Copy link
Contributor Author

sarfarazsiddiquii commented Apr 15, 2024

Thanks @dartpain, my recent commit stores the latest query's error in Redux, and conversation.tsx handles its display.
and the error due to settings.gpt_model is now fixed.
Another possible solution to this problem would be to use alert.
Let me know if further changes are needed.

@sarfarazsiddiquii
Copy link
Contributor Author

@dartpain, could you please review the changes I made in my last commit and confirm if they are correct? Alternatively, if you believe I should use an alert or consider any other possible solution, please let me know.
Thanks.

gpt_model=gpt_model)

return Response(
stream_with_context(complete_stream(question, retriever,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @sarfarazsiddiquii
the chat_history argument is being passed here in the complete_stream function without specifying it in the function definition which is throwing an error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @siiddhantt for addressing the error, it seems like chat_history and prompt_id was unnecessary regarding this issue.
I may have overlooked the above create_retriever function while making changes. I removed the unnecessary properties from complete_stream function and the recent commit should work without any errors.
Tell me if any further changes are required.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, I'd recommend running the code and testing the flow as I encountered this error at the very start. Do let me know when you've tested it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @siiddhantt , I have made some minor changes since my last commits, and after running the code as requested, I did not encounter any errors, and the code worked fine. Please review the commits, and if you encounter any errors, please let me know what errors you're getting.
Thank you.

@dartpain
Copy link
Contributor

Hey, I keep getting this error
TypeError: Can't instantiate abstract class DOCSGTAPILLM with abstract nethod pen strean
Please check it out, also please try syncing with main branch, might help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants