Fix chat_with_SQL_3_ways.ipynb: SQLQuery breaks with OpenAIChatGenerator - #310
Open
mittalpk wants to merge 1 commit into
Open
Fix chat_with_SQL_3_ways.ipynb: SQLQuery breaks with OpenAIChatGenerator#310mittalpk wants to merge 1 commit into
mittalpk wants to merge 1 commit into
Conversation
llm.replies from OpenAIChatGenerator is List[ChatMessage], but SQLQuery.run()
declared queries: List[str] -- pipeline.connect("llm.replies", "sql_querier.queries")
raised PipelineConnectError, so the notebook couldn't even build.
SQLQuery now accepts List[Union[str, ChatMessage]] and extracts .text when
given a ChatMessage, so it still works with the notebook's other two call
sites that pass plain strings directly (the standalone .run() call, and the
function-calling variant).
Also fixed a second bug in the same notebook's conditional-routing section:
the ConditionalRouter's 'no_answer' in/not in replies[0] check operated on a
ChatMessage object directly, which raises TypeError (ChatMessage isn't
iterable) -- needs .text. Its declared output_type: List[str] for the sql
route was also inconsistent with the actual List[ChatMessage] value being
routed.
Fixes deepset-ai#212.
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
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.
Fixes #212.
llm.repliesfromOpenAIChatGeneratorisList[ChatMessage], butSQLQuery.run()declaredqueries: List[str], sopipeline.connect("llm.replies", "sql_querier.queries")raisedPipelineConnectErrorand the notebook couldn't even build.SQLQuerynow acceptsList[Union[str, ChatMessage]]and extracts.textwhen given aChatMessage. I usedUnionrather than switching the type outright because the notebook also callsSQLQuery.run()directly with plain strings in two other places (the standalone test call, and the function-calling variant later in the same notebook) — aChatMessage-only signature would have fixed this pipeline while breaking those two.Also found and fixed a second bug in the same notebook's conditional-routing section:
ConditionalRouter's'no_answer' in/not in replies[0]check operates on aChatMessageobject directly, which raisesTypeError(ChatMessageisn't iterable) — needs.text. Its declaredoutput_type: List[str]for thesqlroute was also inconsistent with the actualList[ChatMessage]value being routed.Verified end-to-end against a real SQLite database (not just
.connect()type-checking) with haystack-ai installed: the standalone string call, theChatMessagepipeline call, the function-calling variant, and bothConditionalRouterbranches (normal reply →sql,no_answerreply →go_to_fallback) all produce correct results with the patched notebook.