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

Enabling streaming in BaseSQLTableQueryEngine #13599

Conversation

dhirajsuvarna
Copy link
Contributor

@dhirajsuvarna dhirajsuvarna commented May 20, 2024

Description

Was using NLSQLTableQueryEngine to build a Text to SQL chatbot and found that this particular Query Engine was not able to stream the response.

On analysis found that the streaming flag could be passed to the ResponseSynthesizer but was not being handled in the BaseSQLTableQueryEngine

Fixes # (issue)
Didn't find any issue reported in Github Issues

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

I made changes in the code locally and tested it in my local enviornment

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added Google Colab support for the newly added notebooks.
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I ran make format; make lint to appease the lint gods

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label May 20, 2024
Copy link
Contributor

@nerdai nerdai left a comment

Choose a reason for hiding this comment

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

Thanks @dhirajsuvarna -- I've left a couple of comments.

super().__init__(
callback_manager=callback_manager
or callback_manager_from_settings_or_context(Settings, service_context),
**kwargs,
# **kwargs,
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we commenting out **kwargs here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BaseQueryEngine doesn't take any kwargs so need to comment this, else i get the below error

BaseQueryEngine.__init__() got an unexpected keyword argument 'streaming'

Copy link
Contributor

Choose a reason for hiding this comment

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

Right. So if we do what the other comment proposes then this should no longer be a problem then, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup, right

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but shouldn't the kwargs be removed, if it is not used by the base class (BaseQueryEngine)

Copy link
Contributor

Choose a reason for hiding this comment

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

that's fair! In this case, let's just remove it as opposed to just commenting out.

@@ -351,10 +351,11 @@ def __init__(

self._synthesize_response = synthesize_response
self._verbose = verbose
self._streaming = kwargs["streaming"] if "streaming" in kwargs else False
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 it might be better to include streaming as a param in __init__() instead and give it a default value of False (i.e. treat it like verbose).

CC: @logan-markewich

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree, I would go with that 👍🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, i have done this change, please review

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

@nerdai
Copy link
Contributor

nerdai commented May 20, 2024

@dhirajsuvarna can you kindly run make lint and make format and commit/push the changes :)

Copy link
Contributor

@nerdai nerdai left a comment

Choose a reason for hiding this comment

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

Lgtm!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 21, 2024
@dhirajsuvarna
Copy link
Contributor Author

@dhirajsuvarna can you kindly run make lint and make format and commit/push the changes :)

By the way I ran this command, but this kind of introduced around 800+ changes in the files, mostly likely related to newline. Do know what's going on, but would like to understand it. Any tips is highly appreiciated.

@logan-markewich
Copy link
Collaborator

@dhirajsuvarna could be the way your IDE is configuring newlines

@logan-markewich logan-markewich enabled auto-merge (squash) May 22, 2024 01:01
@logan-markewich logan-markewich merged commit 90cf6a9 into run-llama:main May 22, 2024
5 of 8 checks passed
@dhirajsuvarna dhirajsuvarna deleted the dhiraj/fix_streaming_NLSQLTableQueryEngine branch May 22, 2024 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants