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

Extract query from text2sql agent #158

Merged
merged 5 commits into from
Sep 11, 2024
Merged

Conversation

dusvyat
Copy link
Contributor

@dusvyat dusvyat commented Sep 6, 2024

This introduces some utilities to the sdk for parsing streaming completions for text2sql agents

depends on mindsdb/mindsdb#9698

part of ML-129

Introduced a `MindsDBSQLStreamParser` class to facilitate debugging and SQL query extraction from MindsDB completion streams. Updated the text2sql examples to implement the new parser and modified model name handling for consistency.
Introduced a `MindsDBSQLStreamParser` class to facilitate debugging and SQL query extraction from MindsDB completion streams. Updated the text2sql examples to implement the new parser and modified model name handling for consistency.
Copy link

github-actions bot commented Sep 6, 2024

Coverage

Coverage Report
FileStmtsMissCoverMissing
mindsdb_sdk
   agents.py2035274%33, 101, 104, 112, 120, 138, 156, 166, 169, 173, 175, 177, 179, 181, 183, 245, 258, 262–277, 289, 298–302, 309–310, 356, 364–365, 415, 464–465, 468, 475, 496–498, 502–506
   databases.py45296%109, 137
   handlers.py39197%77
   jobs.py97793%41, 53, 81, 85, 147–150
   knowledge_bases.py1261588%58–61, 155, 159–166, 171–175, 254–257, 326, 343
   ml_engines.py42393%94, 126, 128
   models.py2101991%109, 140–141, 222, 231, 233, 303, 339, 348, 372, 397, 491, 499, 518, 534, 542, 567, 571, 584
   projects.py64198%160
   query.py13192%14
   skills.py53394%43, 45, 49
   tables.py1301588%140–142, 145, 165, 192, 203–204, 209, 224, 227, 321, 342–347, 356, 376
   views.py37295%105, 138
mindsdb_sdk/connectors
   rest_api.py2254281%19–29, 35–36, 51, 54–55, 75–77, 98, 101, 108–111, 144–152, 173–174, 209–212, 226–227, 281–286
mindsdb_sdk/utils
   agents.py50492%72, 79–81
   mind.py41410%1–119
   openai.py853065%37–40, 83–85, 107, 148–158, 215–216, 234–240, 258–276
   table_schema.py21210%1–54
TOTAL156825983% 

Tests Skipped Failures Errors Time
28 0 💤 0 ❌ 0 🔥 10.669s ⏱️

@dusvyat
Copy link
Contributor Author

dusvyat commented Sep 6, 2024

@martyna-mindsdb fyi this updates some of the sdk examples

Consolidate various log statements for better visibility at `INFO` level. Remove redundant debug-level logging in `using_agents_with_text2sql_streaming.py` and streamline MindsDBSQLStreamParser instantiation.
@martyna-mindsdb
Copy link

@dusvyat
It looks like the functions implemented in this PR are used under the hood by the streaming feature.

Here is the current SDK example from docs. Please let me know if there is anything that changes from user's perspective, or anything that should be better emphasized in docs.

@dusvyat
Copy link
Contributor Author

dusvyat commented Sep 6, 2024

@martyna-mindsdb no doc changes required, just tagging as an FYI

Refactor the agent utils to log SQL queries directly from chunk content instead of extracting from actions. This simplifies the process and removes redundant code related to action handling.
Copy link

@QuantumPlumber QuantumPlumber left a comment

Choose a reason for hiding this comment

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

Looks good to me, but what happens when the CoT runs multiple SQL queries. Shouldn't we return the last SQL query?

@dusvyat
Copy link
Contributor Author

dusvyat commented Sep 11, 2024

Looks good to me, but what happens when the CoT runs multiple SQL queries. Shouldn't we return the last SQL query?

@QuantumPlumber As it stands, only last query that was generated is returned. Hence it accounts for scenarios where sql_db_query task is executed multiple times

Introduce comprehensive tests for MindsDBSQLStreamParser functionality. Included tests cover initialization, streaming and parsing SQL queries with both dict and string inputs, and processing streams with and without SQL content.
@dusvyat dusvyat merged commit 4a6f725 into main Sep 11, 2024
4 checks passed
@ea-rus ea-rus mentioned this pull request Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: merged
Development

Successfully merging this pull request may close these issues.

4 participants