MindsDB 25.5.3.0__py3-none-any.whl → 25.5.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of MindsDB might be problematic. Click here for more details.

Files changed (310) hide show
  1. mindsdb/__about__.py +1 -1
  2. mindsdb/__main__.py +127 -79
  3. mindsdb/api/a2a/__init__.py +0 -0
  4. mindsdb/api/a2a/__main__.py +114 -0
  5. mindsdb/api/a2a/a2a_client.py +439 -0
  6. mindsdb/api/a2a/agent.py +308 -0
  7. mindsdb/api/a2a/common/__init__.py +0 -0
  8. mindsdb/api/a2a/common/client/__init__.py +4 -0
  9. mindsdb/api/a2a/common/client/card_resolver.py +21 -0
  10. mindsdb/api/a2a/common/client/client.py +86 -0
  11. mindsdb/api/a2a/common/server/__init__.py +4 -0
  12. mindsdb/api/a2a/common/server/server.py +164 -0
  13. mindsdb/api/a2a/common/server/task_manager.py +287 -0
  14. mindsdb/api/a2a/common/server/utils.py +28 -0
  15. mindsdb/api/a2a/common/types.py +365 -0
  16. mindsdb/api/a2a/constants.py +9 -0
  17. mindsdb/api/a2a/run_a2a.py +129 -0
  18. mindsdb/api/a2a/task_manager.py +594 -0
  19. mindsdb/api/executor/command_executor.py +47 -27
  20. mindsdb/api/executor/datahub/classes/response.py +5 -2
  21. mindsdb/api/executor/datahub/datanodes/integration_datanode.py +39 -72
  22. mindsdb/api/executor/planner/query_planner.py +10 -1
  23. mindsdb/api/executor/sql_query/result_set.py +185 -52
  24. mindsdb/api/executor/sql_query/sql_query.py +1 -1
  25. mindsdb/api/executor/sql_query/steps/apply_predictor_step.py +9 -12
  26. mindsdb/api/executor/sql_query/steps/fetch_dataframe.py +8 -10
  27. mindsdb/api/executor/sql_query/steps/fetch_dataframe_partition.py +5 -44
  28. mindsdb/api/executor/sql_query/steps/insert_step.py +24 -15
  29. mindsdb/api/executor/sql_query/steps/join_step.py +1 -1
  30. mindsdb/api/executor/sql_query/steps/project_step.py +1 -1
  31. mindsdb/api/executor/sql_query/steps/sql_steps.py +1 -1
  32. mindsdb/api/executor/sql_query/steps/subselect_step.py +4 -8
  33. mindsdb/api/executor/sql_query/steps/union_step.py +1 -3
  34. mindsdb/api/http/initialize.py +99 -83
  35. mindsdb/api/http/namespaces/analysis.py +3 -3
  36. mindsdb/api/http/namespaces/file.py +8 -2
  37. mindsdb/api/http/namespaces/sql.py +13 -27
  38. mindsdb/api/mcp/start.py +42 -5
  39. mindsdb/api/mysql/mysql_proxy/data_types/mysql_packet.py +0 -1
  40. mindsdb/api/mysql/mysql_proxy/data_types/mysql_packets/binary_resultset_row_package.py +52 -19
  41. mindsdb/api/mysql/mysql_proxy/executor/mysql_executor.py +8 -10
  42. mindsdb/api/mysql/mysql_proxy/libs/constants/mysql.py +54 -38
  43. mindsdb/api/mysql/mysql_proxy/mysql_proxy.py +82 -115
  44. mindsdb/api/mysql/mysql_proxy/utilities/dump.py +351 -0
  45. mindsdb/api/postgres/postgres_proxy/executor/executor.py +1 -1
  46. mindsdb/api/postgres/postgres_proxy/postgres_proxy.py +5 -6
  47. mindsdb/integrations/handlers/altibase_handler/altibase_handler.py +26 -27
  48. mindsdb/integrations/handlers/altibase_handler/connection_args.py +13 -13
  49. mindsdb/integrations/handlers/altibase_handler/tests/test_altibase_handler.py +8 -8
  50. mindsdb/integrations/handlers/altibase_handler/tests/test_altibase_handler_dsn.py +13 -13
  51. mindsdb/integrations/handlers/anthropic_handler/__init__.py +2 -2
  52. mindsdb/integrations/handlers/anthropic_handler/anthropic_handler.py +1 -3
  53. mindsdb/integrations/handlers/aurora_handler/aurora_handler.py +1 -0
  54. mindsdb/integrations/handlers/autosklearn_handler/autosklearn_handler.py +1 -1
  55. mindsdb/integrations/handlers/autosklearn_handler/config.py +0 -1
  56. mindsdb/integrations/handlers/bigquery_handler/bigquery_handler.py +1 -1
  57. mindsdb/integrations/handlers/bigquery_handler/tests/test_bigquery_handler.py +1 -1
  58. mindsdb/integrations/handlers/binance_handler/binance_handler.py +1 -0
  59. mindsdb/integrations/handlers/binance_handler/binance_tables.py +3 -4
  60. mindsdb/integrations/handlers/byom_handler/__init__.py +0 -1
  61. mindsdb/integrations/handlers/ckan_handler/ckan_handler.py +3 -0
  62. mindsdb/integrations/handlers/clickhouse_handler/__init__.py +1 -1
  63. mindsdb/integrations/handlers/cloud_spanner_handler/tests/test_cloud_spanner_handler.py +0 -2
  64. mindsdb/integrations/handlers/cloud_sql_handler/cloud_sql_handler.py +0 -1
  65. mindsdb/integrations/handlers/cohere_handler/__init__.py +1 -1
  66. mindsdb/integrations/handlers/cohere_handler/cohere_handler.py +11 -13
  67. mindsdb/integrations/handlers/confluence_handler/confluence_tables.py +6 -0
  68. mindsdb/integrations/handlers/databend_handler/connection_args.py +1 -1
  69. mindsdb/integrations/handlers/databend_handler/databend_handler.py +4 -4
  70. mindsdb/integrations/handlers/databend_handler/tests/__init__.py +0 -1
  71. mindsdb/integrations/handlers/databend_handler/tests/test_databend_handler.py +1 -1
  72. mindsdb/integrations/handlers/derby_handler/connection_args.py +1 -1
  73. mindsdb/integrations/handlers/derby_handler/derby_handler.py +14 -22
  74. mindsdb/integrations/handlers/derby_handler/tests/test_derby_handler.py +6 -6
  75. mindsdb/integrations/handlers/discord_handler/discord_handler.py +5 -5
  76. mindsdb/integrations/handlers/discord_handler/discord_tables.py +3 -3
  77. mindsdb/integrations/handlers/discord_handler/tests/test_discord.py +5 -3
  78. mindsdb/integrations/handlers/dockerhub_handler/dockerhub.py +3 -3
  79. mindsdb/integrations/handlers/dockerhub_handler/dockerhub_handler.py +2 -2
  80. mindsdb/integrations/handlers/dockerhub_handler/dockerhub_tables.py +57 -54
  81. mindsdb/integrations/handlers/dremio_handler/__init__.py +2 -2
  82. mindsdb/integrations/handlers/druid_handler/__init__.py +1 -1
  83. mindsdb/integrations/handlers/druid_handler/druid_handler.py +2 -2
  84. mindsdb/integrations/handlers/edgelessdb_handler/tests/test_edgelessdb_handler.py +9 -9
  85. mindsdb/integrations/handlers/email_handler/email_client.py +1 -1
  86. mindsdb/integrations/handlers/email_handler/email_ingestor.py +1 -1
  87. mindsdb/integrations/handlers/email_handler/email_tables.py +0 -1
  88. mindsdb/integrations/handlers/email_handler/settings.py +0 -1
  89. mindsdb/integrations/handlers/eventstoredb_handler/eventstoredb_handler.py +2 -1
  90. mindsdb/integrations/handlers/firebird_handler/firebird_handler.py +1 -1
  91. mindsdb/integrations/handlers/flaml_handler/flaml_handler.py +9 -9
  92. mindsdb/integrations/handlers/frappe_handler/frappe_client.py +5 -5
  93. mindsdb/integrations/handlers/frappe_handler/frappe_handler.py +6 -5
  94. mindsdb/integrations/handlers/frappe_handler/frappe_tables.py +2 -2
  95. mindsdb/integrations/handlers/github_handler/connection_args.py +2 -2
  96. mindsdb/integrations/handlers/github_handler/github_handler.py +1 -8
  97. mindsdb/integrations/handlers/github_handler/github_tables.py +13 -24
  98. mindsdb/integrations/handlers/gitlab_handler/gitlab_handler.py +2 -1
  99. mindsdb/integrations/handlers/gitlab_handler/gitlab_tables.py +1 -4
  100. mindsdb/integrations/handlers/gmail_handler/gmail_handler.py +6 -13
  101. mindsdb/integrations/handlers/google_books_handler/google_books_handler.py +2 -1
  102. mindsdb/integrations/handlers/google_books_handler/google_books_tables.py +0 -3
  103. mindsdb/integrations/handlers/google_calendar_handler/google_calendar_handler.py +4 -4
  104. mindsdb/integrations/handlers/google_calendar_handler/google_calendar_tables.py +2 -6
  105. mindsdb/integrations/handlers/google_content_shopping_handler/google_content_shopping_handler.py +3 -2
  106. mindsdb/integrations/handlers/google_content_shopping_handler/google_content_shopping_tables.py +0 -3
  107. mindsdb/integrations/handlers/google_fit_handler/google_fit_handler.py +10 -12
  108. mindsdb/integrations/handlers/google_fit_handler/google_fit_tables.py +11 -13
  109. mindsdb/integrations/handlers/google_search_handler/google_search_handler.py +2 -1
  110. mindsdb/integrations/handlers/google_search_handler/google_search_tables.py +0 -3
  111. mindsdb/integrations/handlers/groq_handler/__init__.py +3 -3
  112. mindsdb/integrations/handlers/hackernews_handler/hn_handler.py +5 -7
  113. mindsdb/integrations/handlers/hackernews_handler/hn_table.py +6 -7
  114. mindsdb/integrations/handlers/hive_handler/tests/test_hive_handler.py +1 -1
  115. mindsdb/integrations/handlers/hsqldb_handler/connection_args.py +6 -6
  116. mindsdb/integrations/handlers/hsqldb_handler/hsqldb_handler.py +4 -3
  117. mindsdb/integrations/handlers/huggingface_api_handler/exceptions.py +1 -1
  118. mindsdb/integrations/handlers/huggingface_api_handler/huggingface_api_handler.py +1 -8
  119. mindsdb/integrations/handlers/huggingface_handler/huggingface_handler.py +6 -6
  120. mindsdb/integrations/handlers/huggingface_handler/requirements.txt +1 -1
  121. mindsdb/integrations/handlers/huggingface_handler/requirements_cpu.txt +1 -1
  122. mindsdb/integrations/handlers/ignite_handler/ignite_handler.py +2 -1
  123. mindsdb/integrations/handlers/impala_handler/impala_handler.py +9 -12
  124. mindsdb/integrations/handlers/impala_handler/tests/test_impala_handler.py +11 -11
  125. mindsdb/integrations/handlers/influxdb_handler/influxdb_handler.py +10 -13
  126. mindsdb/integrations/handlers/influxdb_handler/influxdb_tables.py +20 -20
  127. mindsdb/integrations/handlers/informix_handler/__about__.py +8 -8
  128. mindsdb/integrations/handlers/informix_handler/__init__.py +12 -5
  129. mindsdb/integrations/handlers/informix_handler/informix_handler.py +99 -133
  130. mindsdb/integrations/handlers/informix_handler/tests/test_informix_handler.py +13 -11
  131. mindsdb/integrations/handlers/ingres_handler/__about__.py +0 -1
  132. mindsdb/integrations/handlers/ingres_handler/ingres_handler.py +1 -0
  133. mindsdb/integrations/handlers/jira_handler/jira_handler.py +4 -4
  134. mindsdb/integrations/handlers/jira_handler/jira_tables.py +9 -9
  135. mindsdb/integrations/handlers/kinetica_handler/__init__.py +0 -1
  136. mindsdb/integrations/handlers/langchain_handler/langchain_handler.py +4 -4
  137. mindsdb/integrations/handlers/langchain_handler/tools.py +9 -10
  138. mindsdb/integrations/handlers/leonardoai_handler/__init__.py +1 -1
  139. mindsdb/integrations/handlers/lightwood_handler/functions.py +2 -2
  140. mindsdb/integrations/handlers/lightwood_handler/lightwood_handler.py +0 -1
  141. mindsdb/integrations/handlers/lightwood_handler/tests/test_lightwood_handler.py +11 -11
  142. mindsdb/integrations/handlers/llama_index_handler/llama_index_handler.py +4 -4
  143. mindsdb/integrations/handlers/llama_index_handler/settings.py +10 -9
  144. mindsdb/integrations/handlers/materialize_handler/tests/test_materialize_handler.py +8 -10
  145. mindsdb/integrations/handlers/matrixone_handler/matrixone_handler.py +4 -4
  146. mindsdb/integrations/handlers/matrixone_handler/tests/test_matrixone_handler.py +8 -9
  147. mindsdb/integrations/handlers/maxdb_handler/connection_args.py +25 -25
  148. mindsdb/integrations/handlers/maxdb_handler/maxdb_handler.py +1 -0
  149. mindsdb/integrations/handlers/mediawiki_handler/mediawiki_handler.py +3 -2
  150. mindsdb/integrations/handlers/mediawiki_handler/mediawiki_tables.py +1 -1
  151. mindsdb/integrations/handlers/mendeley_handler/__about__.py +1 -1
  152. mindsdb/integrations/handlers/mendeley_handler/__init__.py +2 -2
  153. mindsdb/integrations/handlers/mendeley_handler/mendeley_handler.py +48 -56
  154. mindsdb/integrations/handlers/mendeley_handler/mendeley_tables.py +24 -29
  155. mindsdb/integrations/handlers/mendeley_handler/tests/test_mendeley_handler.py +19 -17
  156. mindsdb/integrations/handlers/merlion_handler/merlion_handler.py +5 -4
  157. mindsdb/integrations/handlers/minds_endpoint_handler/__init__.py +3 -3
  158. mindsdb/integrations/handlers/mlflow_handler/mlflow_handler.py +58 -36
  159. mindsdb/integrations/handlers/monetdb_handler/__about__.py +8 -8
  160. mindsdb/integrations/handlers/monetdb_handler/__init__.py +15 -5
  161. mindsdb/integrations/handlers/monetdb_handler/connection_args.py +17 -18
  162. mindsdb/integrations/handlers/monetdb_handler/monetdb_handler.py +40 -57
  163. mindsdb/integrations/handlers/monetdb_handler/tests/test_monetdb_handler.py +7 -8
  164. mindsdb/integrations/handlers/monetdb_handler/utils/monet_get_id.py +13 -14
  165. mindsdb/integrations/handlers/monkeylearn_handler/__about__.py +1 -1
  166. mindsdb/integrations/handlers/monkeylearn_handler/__init__.py +1 -1
  167. mindsdb/integrations/handlers/monkeylearn_handler/monkeylearn_handler.py +2 -5
  168. mindsdb/integrations/handlers/ms_one_drive_handler/ms_graph_api_one_drive_client.py +1 -0
  169. mindsdb/integrations/handlers/ms_one_drive_handler/ms_one_drive_handler.py +1 -1
  170. mindsdb/integrations/handlers/ms_teams_handler/ms_graph_api_teams_client.py +23 -23
  171. mindsdb/integrations/handlers/ms_teams_handler/ms_teams_handler.py +3 -3
  172. mindsdb/integrations/handlers/ms_teams_handler/ms_teams_tables.py +10 -5
  173. mindsdb/integrations/handlers/mssql_handler/mssql_handler.py +73 -8
  174. mindsdb/integrations/handlers/mysql_handler/__about__.py +8 -8
  175. mindsdb/integrations/handlers/mysql_handler/__init__.py +15 -5
  176. mindsdb/integrations/handlers/mysql_handler/connection_args.py +43 -47
  177. mindsdb/integrations/handlers/mysql_handler/mysql_handler.py +101 -34
  178. mindsdb/integrations/handlers/mysql_handler/settings.py +15 -13
  179. mindsdb/integrations/handlers/neuralforecast_handler/neuralforecast_handler.py +1 -1
  180. mindsdb/integrations/handlers/newsapi_handler/newsapi_handler.py +1 -1
  181. mindsdb/integrations/handlers/newsapi_handler/tests/test_newsapi_handler.py +4 -4
  182. mindsdb/integrations/handlers/nuo_jdbc_handler/connection_args.py +2 -2
  183. mindsdb/integrations/handlers/nuo_jdbc_handler/nuo_jdbc_handler.py +28 -36
  184. mindsdb/integrations/handlers/nuo_jdbc_handler/tests/test_nuo_handler.py +5 -5
  185. mindsdb/integrations/handlers/oceanbase_handler/oceanbase_handler.py +0 -1
  186. mindsdb/integrations/handlers/oceanbase_handler/tests/test_oceanbase_handler.py +8 -10
  187. mindsdb/integrations/handlers/ollama_handler/ollama_handler.py +3 -3
  188. mindsdb/integrations/handlers/opengauss_handler/tests/test_opengauss_handler.py +1 -2
  189. mindsdb/integrations/handlers/openstreetmap_handler/__init__.py +7 -7
  190. mindsdb/integrations/handlers/oracle_handler/connection_args.py +6 -0
  191. mindsdb/integrations/handlers/oracle_handler/oracle_handler.py +77 -11
  192. mindsdb/integrations/handlers/orioledb_handler/tests/test_orioledb_handler.py +8 -10
  193. mindsdb/integrations/handlers/palm_handler/__about__.py +1 -1
  194. mindsdb/integrations/handlers/palm_handler/__init__.py +1 -1
  195. mindsdb/integrations/handlers/palm_handler/palm_handler.py +1 -3
  196. mindsdb/integrations/handlers/paypal_handler/paypal_handler.py +2 -2
  197. mindsdb/integrations/handlers/paypal_handler/paypal_tables.py +15 -14
  198. mindsdb/integrations/handlers/pgvector_handler/pgvector_handler.py +53 -10
  199. mindsdb/integrations/handlers/phoenix_handler/__init__.py +1 -1
  200. mindsdb/integrations/handlers/phoenix_handler/phoenix_handler.py +1 -0
  201. mindsdb/integrations/handlers/pinot_handler/__init__.py +1 -1
  202. mindsdb/integrations/handlers/pinot_handler/pinot_handler.py +3 -2
  203. mindsdb/integrations/handlers/plaid_handler/plaid_handler.py +13 -13
  204. mindsdb/integrations/handlers/plaid_handler/plaid_tables.py +10 -12
  205. mindsdb/integrations/handlers/plaid_handler/utils.py +4 -6
  206. mindsdb/integrations/handlers/planetscale_handler/planetscale_handler.py +1 -4
  207. mindsdb/integrations/handlers/portkey_handler/__init__.py +2 -2
  208. mindsdb/integrations/handlers/postgres_handler/postgres_handler.py +105 -24
  209. mindsdb/integrations/handlers/postgres_handler/tests/test_postgres_handler.py +11 -6
  210. mindsdb/integrations/handlers/questdb_handler/questdb_handler.py +1 -2
  211. mindsdb/integrations/handlers/questdb_handler/tests/test_questdb_handler.py +2 -3
  212. mindsdb/integrations/handlers/quickbooks_handler/quickbooks_handler.py +6 -8
  213. mindsdb/integrations/handlers/quickbooks_handler/quickbooks_table.py +10 -10
  214. mindsdb/integrations/handlers/rag_handler/ingest.py +2 -2
  215. mindsdb/integrations/handlers/rag_handler/rag_handler.py +1 -1
  216. mindsdb/integrations/handlers/rag_handler/settings.py +1 -1
  217. mindsdb/integrations/handlers/reddit_handler/reddit_handler.py +2 -7
  218. mindsdb/integrations/handlers/reddit_handler/reddit_tables.py +2 -3
  219. mindsdb/integrations/handlers/replicate_handler/replicate_handler.py +6 -6
  220. mindsdb/integrations/handlers/rocket_chat_handler/rocket_chat_handler.py +1 -2
  221. mindsdb/integrations/handlers/rocket_chat_handler/rocket_chat_tables.py +0 -3
  222. mindsdb/integrations/handlers/rockset_handler/connection_args.py +14 -14
  223. mindsdb/integrations/handlers/rockset_handler/tests/test_rockset_handler.py +1 -0
  224. mindsdb/integrations/handlers/scylla_handler/scylla_handler.py +6 -5
  225. mindsdb/integrations/handlers/sendinblue_handler/sendinblue_handler.py +2 -1
  226. mindsdb/integrations/handlers/sendinblue_handler/sendinblue_tables.py +16 -16
  227. mindsdb/integrations/handlers/sentence_transformers_handler/__init__.py +1 -1
  228. mindsdb/integrations/handlers/sheets_handler/connection_args.py +1 -1
  229. mindsdb/integrations/handlers/shopify_handler/shopify_handler.py +7 -6
  230. mindsdb/integrations/handlers/shopify_handler/shopify_tables.py +38 -41
  231. mindsdb/integrations/handlers/singlestore_handler/__about__.py +1 -1
  232. mindsdb/integrations/handlers/singlestore_handler/__init__.py +0 -1
  233. mindsdb/integrations/handlers/singlestore_handler/singlestore_handler.py +1 -0
  234. mindsdb/integrations/handlers/singlestore_handler/tests/test_singlestore_handler.py +3 -3
  235. mindsdb/integrations/handlers/slack_handler/__init__.py +3 -3
  236. mindsdb/integrations/handlers/snowflake_handler/snowflake_handler.py +100 -6
  237. mindsdb/integrations/handlers/solr_handler/connection_args.py +7 -7
  238. mindsdb/integrations/handlers/solr_handler/solr_handler.py +2 -1
  239. mindsdb/integrations/handlers/solr_handler/tests/test_solr_handler.py +2 -1
  240. mindsdb/integrations/handlers/sqlany_handler/sqlany_handler.py +3 -2
  241. mindsdb/integrations/handlers/sqlite_handler/sqlite_handler.py +1 -0
  242. mindsdb/integrations/handlers/sqreamdb_handler/connection_args.py +1 -1
  243. mindsdb/integrations/handlers/sqreamdb_handler/sqreamdb_handler.py +15 -20
  244. mindsdb/integrations/handlers/sqreamdb_handler/tests/test_sqreamdb_handler.py +4 -4
  245. mindsdb/integrations/handlers/stabilityai_handler/__init__.py +1 -1
  246. mindsdb/integrations/handlers/starrocks_handler/starrocks_handler.py +0 -1
  247. mindsdb/integrations/handlers/starrocks_handler/tests/test_starrocks_handler.py +8 -10
  248. mindsdb/integrations/handlers/statsforecast_handler/statsforecast_handler.py +2 -2
  249. mindsdb/integrations/handlers/strava_handler/strava_handler.py +4 -8
  250. mindsdb/integrations/handlers/strava_handler/strava_tables.py +22 -30
  251. mindsdb/integrations/handlers/stripe_handler/stripe_handler.py +3 -2
  252. mindsdb/integrations/handlers/stripe_handler/stripe_tables.py +11 -27
  253. mindsdb/integrations/handlers/supabase_handler/tests/test_supabase_handler.py +1 -1
  254. mindsdb/integrations/handlers/surrealdb_handler/surrealdb_handler.py +4 -4
  255. mindsdb/integrations/handlers/tdengine_handler/tdengine_handler.py +25 -27
  256. mindsdb/integrations/handlers/tdengine_handler/tests/test_tdengine_handler.py +8 -8
  257. mindsdb/integrations/handlers/tidb_handler/tests/test_tidb_handler.py +1 -2
  258. mindsdb/integrations/handlers/timegpt_handler/timegpt_handler.py +5 -5
  259. mindsdb/integrations/handlers/tpot_handler/tpot_handler.py +21 -26
  260. mindsdb/integrations/handlers/trino_handler/trino_handler.py +14 -14
  261. mindsdb/integrations/handlers/twitter_handler/twitter_handler.py +2 -4
  262. mindsdb/integrations/handlers/unify_handler/tests/test_unify_handler.py +7 -8
  263. mindsdb/integrations/handlers/unify_handler/unify_handler.py +9 -9
  264. mindsdb/integrations/handlers/vertex_handler/vertex_client.py +1 -1
  265. mindsdb/integrations/handlers/vertica_handler/tests/test_vertica_handler.py +11 -11
  266. mindsdb/integrations/handlers/vertica_handler/vertica_handler.py +11 -14
  267. mindsdb/integrations/handlers/vitess_handler/tests/test_vitess_handler.py +9 -11
  268. mindsdb/integrations/handlers/vitess_handler/vitess_handler.py +0 -1
  269. mindsdb/integrations/handlers/web_handler/web_handler.py +1 -0
  270. mindsdb/integrations/handlers/whatsapp_handler/__init__.py +3 -3
  271. mindsdb/integrations/handlers/writer_handler/evaluate.py +1 -1
  272. mindsdb/integrations/handlers/writer_handler/settings.py +0 -1
  273. mindsdb/integrations/handlers/writer_handler/writer_handler.py +1 -0
  274. mindsdb/integrations/handlers/youtube_handler/youtube_handler.py +5 -5
  275. mindsdb/integrations/handlers/youtube_handler/youtube_tables.py +26 -27
  276. mindsdb/integrations/handlers/yugabyte_handler/tests/test_yugabyte_handler.py +3 -3
  277. mindsdb/integrations/handlers/yugabyte_handler/yugabyte_handler.py +0 -6
  278. mindsdb/integrations/libs/response.py +67 -52
  279. mindsdb/integrations/libs/vectordatabase_handler.py +6 -0
  280. mindsdb/integrations/utilities/handler_utils.py +15 -3
  281. mindsdb/integrations/utilities/handlers/api_utilities/__init__.py +0 -1
  282. mindsdb/integrations/utilities/handlers/auth_utilities/__init__.py +0 -2
  283. mindsdb/integrations/utilities/utils.py +3 -3
  284. mindsdb/interfaces/agents/agents_controller.py +164 -1
  285. mindsdb/interfaces/agents/constants.py +15 -0
  286. mindsdb/interfaces/agents/langchain_agent.py +16 -4
  287. mindsdb/interfaces/agents/mindsdb_database_agent.py +101 -2
  288. mindsdb/interfaces/knowledge_base/controller.py +25 -0
  289. mindsdb/interfaces/knowledge_base/preprocessing/document_preprocessor.py +13 -10
  290. mindsdb/interfaces/knowledge_base/preprocessing/json_chunker.py +434 -0
  291. mindsdb/interfaces/knowledge_base/preprocessing/models.py +54 -0
  292. mindsdb/interfaces/query_context/context_controller.py +66 -10
  293. mindsdb/interfaces/skills/custom/text2sql/mindsdb_kb_tools.py +190 -0
  294. mindsdb/interfaces/skills/custom/text2sql/mindsdb_sql_toolkit.py +92 -0
  295. mindsdb/interfaces/skills/skill_tool.py +202 -57
  296. mindsdb/interfaces/skills/sql_agent.py +205 -17
  297. mindsdb/interfaces/storage/fs.py +1 -0
  298. mindsdb/interfaces/variables/__init__.py +0 -0
  299. mindsdb/interfaces/variables/variables_controller.py +97 -0
  300. mindsdb/migrations/env.py +5 -7
  301. mindsdb/migrations/migrate.py +47 -7
  302. mindsdb/migrations/versions/2025-05-21_9f150e4f9a05_checkpoint_1.py +360 -0
  303. mindsdb/utilities/config.py +331 -219
  304. mindsdb/utilities/starters.py +13 -0
  305. {mindsdb-25.5.3.0.dist-info → mindsdb-25.5.4.0.dist-info}/METADATA +641 -695
  306. {mindsdb-25.5.3.0.dist-info → mindsdb-25.5.4.0.dist-info}/RECORD +309 -288
  307. {mindsdb-25.5.3.0.dist-info → mindsdb-25.5.4.0.dist-info}/WHEEL +1 -1
  308. mindsdb/integrations/handlers/monkeylearn_handler/requirements.txt +0 -1
  309. {mindsdb-25.5.3.0.dist-info → mindsdb-25.5.4.0.dist-info}/licenses/LICENSE +0 -0
  310. {mindsdb-25.5.3.0.dist-info → mindsdb-25.5.4.0.dist-info}/top_level.txt +0 -0
@@ -1,10 +1,10 @@
1
+ from .__about__ import __version__ as version
2
+ from .__about__ import __description__ as description
1
3
  from mindsdb.integrations.libs.const import HANDLER_TYPE
2
4
  from mindsdb.utilities import log
3
5
 
4
6
  logger = log.getLogger(__name__)
5
7
 
6
- from .__about__ import __description__ as description
7
- from .__about__ import __version__ as version
8
8
 
9
9
  try:
10
10
  from .portkey_handler import PortkeyHandler as Handler
@@ -1,12 +1,13 @@
1
1
  import time
2
2
  import json
3
- from typing import Optional
3
+ from typing import Optional, Any
4
4
 
5
5
  import pandas as pd
6
+ from pandas import DataFrame
6
7
  import psycopg
7
- from psycopg.postgres import types
8
+ from psycopg import Column as PGColumn, Cursor
9
+ from psycopg.postgres import TypeInfo, types as pg_types
8
10
  from psycopg.pq import ExecStatus
9
- from pandas import DataFrame
10
11
 
11
12
  from mindsdb_sql_parser import parse_sql
12
13
  from mindsdb.utilities.render.sqlalchemy_render import SqlalchemyRender
@@ -27,7 +28,7 @@ logger = log.getLogger(__name__)
27
28
  SUBSCRIBE_SLEEP_INTERVAL = 1
28
29
 
29
30
 
30
- def _map_type(internal_type_name: str) -> MYSQL_DATA_TYPE:
31
+ def _map_type(internal_type_name: str | None) -> MYSQL_DATA_TYPE:
31
32
  """Map Postgres types to MySQL types.
32
33
 
33
34
  Args:
@@ -36,14 +37,22 @@ def _map_type(internal_type_name: str) -> MYSQL_DATA_TYPE:
36
37
  Returns:
37
38
  MYSQL_DATA_TYPE: The MySQL type that corresponds to the Postgres type.
38
39
  """
40
+ fallback_type = MYSQL_DATA_TYPE.VARCHAR
41
+
42
+ if internal_type_name is None:
43
+ return fallback_type
44
+
39
45
  internal_type_name = internal_type_name.lower()
40
46
  types_map = {
41
- ('smallint', 'integer', 'bigint', 'int', 'smallserial', 'serial', 'bigserial'): MYSQL_DATA_TYPE.INT,
42
- ('real', 'money', 'float'): MYSQL_DATA_TYPE.FLOAT,
47
+ ('smallint', 'smallserial'): MYSQL_DATA_TYPE.SMALLINT,
48
+ ('integer', 'int', 'serial'): MYSQL_DATA_TYPE.INT,
49
+ ('bigint', 'bigserial'): MYSQL_DATA_TYPE.BIGINT,
50
+ ('real', 'float'): MYSQL_DATA_TYPE.FLOAT,
43
51
  ('numeric', 'decimal'): MYSQL_DATA_TYPE.DECIMAL,
44
52
  ('double precision',): MYSQL_DATA_TYPE.DOUBLE,
45
53
  ('character varying', 'varchar'): MYSQL_DATA_TYPE.VARCHAR,
46
- ('character', 'char', 'bpchar', 'bpchar', 'text'): MYSQL_DATA_TYPE.TEXT,
54
+ # NOTE: if return chars-types as mysql's CHAR, then response will be padded with spaces, so return as TEXT
55
+ ('money', 'character', 'char', 'bpchar', 'bpchar', 'text'): MYSQL_DATA_TYPE.TEXT,
47
56
  ('timestamp', 'timestamp without time zone', 'timestamp with time zone'): MYSQL_DATA_TYPE.DATETIME,
48
57
  ('date', ): MYSQL_DATA_TYPE.DATE,
49
58
  ('time', 'time without time zone', 'time with time zone'): MYSQL_DATA_TYPE.TIME,
@@ -55,8 +64,51 @@ def _map_type(internal_type_name: str) -> MYSQL_DATA_TYPE:
55
64
  if internal_type_name in db_types_list:
56
65
  return mysql_data_type
57
66
 
58
- logger.warning(f"Postgres handler type mapping: unknown type: {internal_type_name}, use VARCHAR as fallback.")
59
- return MYSQL_DATA_TYPE.VARCHAR
67
+ logger.debug(f"Postgres handler type mapping: unknown type: {internal_type_name}, use VARCHAR as fallback.")
68
+ return fallback_type
69
+
70
+
71
+ def _make_table_response(result: list[tuple[Any]], cursor: Cursor) -> Response:
72
+ """Build response from result and cursor.
73
+
74
+ Args:
75
+ result (list[tuple[Any]]): result of the query.
76
+ cursor (psycopg.Cursor): cursor object.
77
+
78
+ Returns:
79
+ Response: response object.
80
+ """
81
+ description: list[PGColumn] = cursor.description
82
+ mysql_types: list[MYSQL_DATA_TYPE] = []
83
+ for column in description:
84
+ pg_type_info: TypeInfo = pg_types.get(column.type_code)
85
+ if pg_type_info is None:
86
+ logger.warning(f'Postgres handler: unknown type: {column.type_code}')
87
+ regtype: str = pg_type_info.regtype if pg_type_info is not None else None
88
+ mysql_type = _map_type(regtype)
89
+ mysql_types.append(mysql_type)
90
+
91
+ # region cast int and bool to nullable types
92
+ serieses = []
93
+ for i, mysql_type in enumerate(mysql_types):
94
+ expected_dtype = None
95
+ if mysql_type in (
96
+ MYSQL_DATA_TYPE.SMALLINT, MYSQL_DATA_TYPE.INT, MYSQL_DATA_TYPE.MEDIUMINT,
97
+ MYSQL_DATA_TYPE.BIGINT, MYSQL_DATA_TYPE.TINYINT
98
+ ):
99
+ expected_dtype = 'Int64'
100
+ elif mysql_type in (MYSQL_DATA_TYPE.BOOL, MYSQL_DATA_TYPE.BOOLEAN):
101
+ expected_dtype = 'boolean'
102
+ serieses.append(pd.Series([row[i] for row in result], dtype=expected_dtype, name=description[i].name))
103
+ df = pd.concat(serieses, axis=1, copy=False)
104
+ # endregion
105
+
106
+ return Response(
107
+ RESPONSE_TYPE.TABLE,
108
+ data_frame=df,
109
+ affected_rows=cursor.rowcount,
110
+ mysql_types=mysql_types
111
+ )
60
112
 
61
113
 
62
114
  class PostgresHandler(DatabaseHandler):
@@ -199,13 +251,13 @@ class PostgresHandler(DatabaseHandler):
199
251
  for column_index, column_name in enumerate(df.columns):
200
252
  col = df[column_name]
201
253
  if str(col.dtype) == 'object':
202
- pg_type = types.get(description[column_index].type_code)
203
- if pg_type is not None and pg_type.name in types_map:
204
- col = col.fillna(0)
254
+ pg_type_info: TypeInfo = pg_types.get(description[column_index].type_code) # type_code is int!?
255
+ if pg_type_info is not None and pg_type_info.name in types_map:
256
+ col = col.fillna(0) # TODO rework
205
257
  try:
206
- df[column_name] = col.astype(types_map[pg_type.name])
258
+ df[column_name] = col.astype(types_map[pg_type_info.name])
207
259
  except ValueError as e:
208
- logger.error(f'Error casting column {col.name} to {types_map[pg_type.name]}: {e}')
260
+ logger.error(f'Error casting column {col.name} to {types_map[pg_type_info.name]}: {e}')
209
261
  df.columns = columns
210
262
 
211
263
  @profiler.profile()
@@ -232,16 +284,7 @@ class PostgresHandler(DatabaseHandler):
232
284
  response = Response(RESPONSE_TYPE.OK, affected_rows=cur.rowcount)
233
285
  else:
234
286
  result = cur.fetchall()
235
- df = DataFrame(
236
- result,
237
- columns=[x.name for x in cur.description]
238
- )
239
- self._cast_dtypes(df, cur.description)
240
- response = Response(
241
- RESPONSE_TYPE.TABLE,
242
- data_frame=df,
243
- affected_rows=cur.rowcount
244
- )
287
+ response = _make_table_response(result, cur)
245
288
  connection.commit()
246
289
  except Exception as e:
247
290
  logger.error(f'Error running query: {query} on {self.database}, {e}!')
@@ -257,6 +300,44 @@ class PostgresHandler(DatabaseHandler):
257
300
 
258
301
  return response
259
302
 
303
+ def query_stream(self, query: ASTNode, fetch_size: int = 1000):
304
+ """
305
+ Executes a SQL query and stream results outside by batches
306
+
307
+ :param query: An ASTNode representing the SQL query to be executed.
308
+ :param fetch_size: size of the batch
309
+ :return: generator with query results
310
+ """
311
+ query_str, params = self.renderer.get_exec_params(query, with_failback=True)
312
+
313
+ need_to_close = not self.is_connected
314
+
315
+ connection = self.connect()
316
+ with connection.cursor() as cur:
317
+ try:
318
+ if params is not None:
319
+ cur.executemany(query_str, params)
320
+ else:
321
+ cur.execute(query_str)
322
+
323
+ if cur.pgresult is not None and ExecStatus(cur.pgresult.status) != ExecStatus.COMMAND_OK:
324
+ while True:
325
+ result = cur.fetchmany(fetch_size)
326
+ if not result:
327
+ break
328
+ df = DataFrame(
329
+ result,
330
+ columns=[x.name for x in cur.description]
331
+ )
332
+ self._cast_dtypes(df, cur.description)
333
+ yield df
334
+ connection.commit()
335
+ finally:
336
+ connection.rollback()
337
+
338
+ if need_to_close:
339
+ self.disconnect()
340
+
260
341
  def insert(self, table_name: str, df: pd.DataFrame) -> Response:
261
342
  need_to_close = not self.is_connected
262
343
 
@@ -1,7 +1,6 @@
1
1
  import pytest
2
2
  import psycopg2
3
3
  import os
4
- import time
5
4
 
6
5
  from mindsdb.integrations.handlers.postgres_handler.postgres_handler import (
7
6
  PostgresHandler,
@@ -14,7 +13,9 @@ HANDLER_KWARGS = {
14
13
  "port": os.environ.get("MDB_TEST_POSTGRES_PORT", "5432"),
15
14
  "user": os.environ.get("MDB_TEST_POSTGRES_USER", "postgres"),
16
15
  "password": os.environ.get("MDB_TEST_POSTGRES_PASSWORD", "supersecret"),
17
- "database": os.environ.get("MDB_TEST_POSTGRES_DATABASE", "postgres_db_handler_test"),
16
+ "database": os.environ.get(
17
+ "MDB_TEST_POSTGRES_DATABASE", "postgres_db_handler_test"
18
+ ),
18
19
  }
19
20
  }
20
21
 
@@ -24,6 +25,7 @@ expected_columns = ["col_one", "col_two", "col_three", "col_four"]
24
25
 
25
26
  curr_dir = os.path.dirname(os.path.realpath(__file__))
26
27
 
28
+
27
29
  def seed_db():
28
30
  """Seed the test DB with some data"""
29
31
 
@@ -36,7 +38,7 @@ def seed_db():
36
38
  try:
37
39
  cursor.execute("DROP DATABASE IF EXISTS postgres_db_handler_test;")
38
40
  db.commit()
39
-
41
+
40
42
  # Create the test database
41
43
  cursor.execute("CREATE DATABASE postgres_db_handler_test;")
42
44
 
@@ -56,12 +58,14 @@ def seed_db():
56
58
  cursor.close()
57
59
  db.close()
58
60
 
61
+
59
62
  @pytest.fixture(scope="module")
60
63
  def handler(request):
61
64
  seed_db()
62
65
  handler = PostgresHandler(**HANDLER_KWARGS)
63
66
  yield handler
64
67
 
68
+
65
69
  def check_valid_response(res):
66
70
  if res.resp_type == RESPONSE_TYPE.TABLE:
67
71
  assert res.data_frame is not None, "expected to have some data, but got None"
@@ -72,6 +76,7 @@ def check_valid_response(res):
72
76
  res.error_message is None
73
77
  ), f"expected to have None in error message, but got {res.error_message}"
74
78
 
79
+
75
80
  def get_table_names(handler):
76
81
  res = handler.get_tables()
77
82
  tables = res.data_frame
@@ -157,15 +162,15 @@ class TestPostgresColumns:
157
162
  describe_data = described.data_frame
158
163
  check_valid_response(described)
159
164
  got_columns = list(describe_data.iloc[:, 0])
160
- assert (
161
- set(got_columns) == set(expected_columns)
165
+ assert set(got_columns) == set(
166
+ expected_columns
162
167
  ), f"expected to have next columns in test table:\n{expected_columns}\nbut got:\n{got_columns}"
163
168
 
164
169
 
165
170
  class TestPostgresDisconnect:
166
171
  def test_disconnect(self, handler):
167
172
  handler.disconnect()
168
- assert handler.is_connected == False, "failed to disconnect"
173
+ assert handler.is_connected is False, "failed to disconnect"
169
174
 
170
175
  def test_check_connection(self, handler):
171
176
  res = handler.check_connection()
@@ -5,7 +5,6 @@ from questdb.ingress import Sender
5
5
 
6
6
  from mindsdb.integrations.handlers.postgres_handler import Handler as PostgresHandler
7
7
  from mindsdb.integrations.libs.response import (
8
- HandlerStatusResponse as StatusResponse,
9
8
  HandlerResponse as Response,
10
9
  RESPONSE_TYPE
11
10
  )
@@ -17,7 +16,7 @@ logger = log.getLogger(__name__)
17
16
 
18
17
  class QuestDBHandler(PostgresHandler):
19
18
  """
20
- This handler handles connection and execution of the QuestDB statements.
19
+ This handler handles connection and execution of the QuestDB statements.
21
20
  TODO: check the dialect for questdb
22
21
  """
23
22
  name = 'questdb'
@@ -19,11 +19,11 @@ class QuestDBHandlerTest(unittest.TestCase):
19
19
 
20
20
  def test_0_check_connection(self):
21
21
  assert self.handler.check_connection()
22
-
22
+
23
23
  def test_1_describe_table(self):
24
24
  described = self.handler.describe_table("house_rentals_data")
25
25
  assert described['type'] is not RESPONSE_TYPE.ERROR
26
-
26
+
27
27
  def test_2_get_tables(self):
28
28
  tables = self.handler.get_tables()
29
29
  assert tables['type'] is not RESPONSE_TYPE.ERROR
@@ -32,4 +32,3 @@ class QuestDBHandlerTest(unittest.TestCase):
32
32
  query = "SELECT * FROM house_rentals_data WHERE 'id'='1'"
33
33
  result = self.handler.query(query)
34
34
  assert len(result) > 0
35
-
@@ -1,11 +1,8 @@
1
1
  import os
2
- import pandas as pd
3
2
  from qbosdk import QuickbooksOnlineSDK
4
3
  from mindsdb.integrations.libs.api_handler import APIHandler
5
4
  from mindsdb.integrations.libs.response import (
6
- HandlerStatusResponse as StatusResponse,
7
- HandlerResponse as Response,
8
- RESPONSE_TYPE
5
+ HandlerStatusResponse as StatusResponse
9
6
  )
10
7
  from mindsdb.utilities.config import Config
11
8
  from mindsdb.utilities import log
@@ -14,11 +11,12 @@ from .quickbooks_table import AccountsTable, PurchasesTable, BillPaymentsTable,
14
11
 
15
12
  logger = log.getLogger(__name__)
16
13
 
14
+
17
15
  class QuickbooksHandler(APIHandler):
18
16
  """
19
17
  A class for handling connections and interactions with Quickbooks API.
20
18
  """
21
-
19
+
22
20
  def __init__(self, name=None, **kwargs):
23
21
  super().__init__(name)
24
22
 
@@ -26,7 +24,7 @@ class QuickbooksHandler(APIHandler):
26
24
 
27
25
  self.connection_args = {}
28
26
  handler_config = Config().get('quickbooks_handler', {})
29
- for k in ['client_id', 'client_secret', 'refresh_token', 'realm_id', 'environment']:
27
+ for k in ['client_id', 'client_secret', 'refresh_token', 'realm_id', 'environment']:
30
28
  if k in args:
31
29
  self.connection_args[k] = args[k]
32
30
  elif f'QUICKBOOKS_{k.upper()}' in os.environ:
@@ -39,7 +37,7 @@ class QuickbooksHandler(APIHandler):
39
37
 
40
38
  accountso = AccountsTable(self)
41
39
  self._register_table('accountso', accountso)
42
- purchases= PurchasesTable(self)
40
+ purchases = PurchasesTable(self)
43
41
  self._register_table('purchases', purchases)
44
42
  bills_payments = BillPaymentsTable(self)
45
43
  self._register_table('bills_payments', bills_payments)
@@ -47,7 +45,7 @@ class QuickbooksHandler(APIHandler):
47
45
  self._register_table('vendors', vendors)
48
46
  bills = BillsTable(self)
49
47
  self._register_table('bills', bills)
50
- employees= EmployeesTable(self)
48
+ employees = EmployeesTable(self)
51
49
  self._register_table('employees', employees)
52
50
 
53
51
  def connect(self):
@@ -1,7 +1,6 @@
1
1
  import pandas as pd
2
2
  from mindsdb.integrations.libs.api_handler import APITable
3
3
  from mindsdb_sql_parser import ast
4
- from mindsdb.integrations.utilities.sql_utils import extract_comparison_conditions
5
4
 
6
5
 
7
6
  class AccountsTable(APITable):
@@ -77,8 +76,6 @@ class PurchasesTable(APITable):
77
76
  flat_data[f"{prefix}{key}"] = value
78
77
  return flat_data
79
78
 
80
-
81
-
82
79
  def select(self, query: ast.Select) -> pd.DataFrame:
83
80
  qbo = self.handler.connect()
84
81
  purchases_data = qbo.purchases.get()
@@ -124,6 +121,7 @@ class PurchasesTable(APITable):
124
121
  if len(columns) > 0:
125
122
  result = result[columns]
126
123
 
124
+
127
125
  class BillPaymentsTable(APITable):
128
126
  def flatten_dict(self, data: dict, prefix: str = ""):
129
127
  flat_data = {}
@@ -174,7 +172,7 @@ class BillPaymentsTable(APITable):
174
172
  'domain',
175
173
  'sparse',
176
174
  ]
177
-
175
+
178
176
  def filter_columns(self, result: pd.DataFrame, query: ast.Select = None):
179
177
  columns = []
180
178
  if query is not None:
@@ -187,8 +185,9 @@ class BillPaymentsTable(APITable):
187
185
  if len(columns) > 0:
188
186
  result = result[columns]
189
187
 
188
+
190
189
  class VendorsTable(APITable):
191
-
190
+
192
191
  def flatten_dict(self, data: dict, prefix: str = ""):
193
192
  flat_data = {}
194
193
  for key, value in data.items():
@@ -198,7 +197,7 @@ class VendorsTable(APITable):
198
197
  else:
199
198
  flat_data[f"{prefix}{key}"] = value
200
199
  return flat_data
201
-
200
+
202
201
  def select(self, query: ast.Select) -> pd.DataFrame:
203
202
  qbo = self.handler.connect()
204
203
  vendors_data = qbo.vendors.get()
@@ -206,7 +205,7 @@ class VendorsTable(APITable):
206
205
  result = pd.DataFrame(flattened_vendors_data)
207
206
  self.filter_columns(result, query)
208
207
  return result
209
-
208
+
210
209
  def get_columns(self):
211
210
  return [
212
211
  'Balance',
@@ -223,7 +222,7 @@ class VendorsTable(APITable):
223
222
  'domain',
224
223
  'sparse'
225
224
  ]
226
-
225
+
227
226
  def filter_columns(self, result: pd.DataFrame, query: ast.Select = None):
228
227
  columns = []
229
228
  if query is not None:
@@ -316,8 +315,9 @@ class BillsTable(APITable):
316
315
  if len(columns) > 0:
317
316
  result = result[columns]
318
317
 
318
+
319
319
  class EmployeesTable(APITable):
320
-
320
+
321
321
  def flatten_dict(self, data: dict, prefix: str = ""):
322
322
  flat_data = {}
323
323
  for key, value in data.items():
@@ -371,4 +371,4 @@ class EmployeesTable(APITable):
371
371
  elif isinstance(target, ast.Identifier):
372
372
  columns.append(target.value)
373
373
  if len(columns) > 0:
374
- result = result[columns]
374
+ result = result[columns]
@@ -64,7 +64,7 @@ class RAGIngestor:
64
64
 
65
65
  def split_documents(self, chunk_size, chunk_overlap) -> list:
66
66
  # Load documents and split in chunks
67
- logger.info(f"Loading documents from input data")
67
+ logger.info("Loading documents from input data")
68
68
 
69
69
  documents = []
70
70
 
@@ -146,7 +146,7 @@ class RAGIngestor:
146
146
  self.embeddings_model_name, self.args.use_gpu
147
147
  )
148
148
 
149
- logger.info(f"Creating vectorstore from documents")
149
+ logger.info("Creating vectorstore from documents")
150
150
 
151
151
  if not validate_documents(documents):
152
152
  raise ValueError("Invalid documents")
@@ -61,7 +61,7 @@ class RAGHandler(BaseMLEngine):
61
61
  ml_engine_args = self.engine_storage.get_connection_args()
62
62
 
63
63
  # for a model created with USING, only get api for that specific llm type
64
- args.update({k:v for k, v in ml_engine_args.items() if args["llm_type"] in k})
64
+ args.update({k: v for k, v in ml_engine_args.items() if args["llm_type"] in k})
65
65
 
66
66
  input_args = build_llm_params(args)
67
67
 
@@ -34,7 +34,7 @@ SUPPORTED_VECTOR_STORES = ("chromadb", "faiss")
34
34
 
35
35
  SUPPORTED_LLMS = ("writer", "openai")
36
36
 
37
- ## Default parameters for RAG Handler
37
+ # Default parameters for RAG Handler
38
38
 
39
39
  # this is the default prompt template for qa
40
40
  DEFAULT_QA_PROMPT_TEMPLATE = """
@@ -1,6 +1,5 @@
1
1
  import praw
2
- import pandas as pd
3
- from datetime import datetime
2
+ import os
4
3
  from mindsdb.integrations.libs.api_handler import APIHandler
5
4
  from mindsdb.integrations.libs.response import (
6
5
  HandlerStatusResponse as StatusResponse,
@@ -14,8 +13,8 @@ from .reddit_tables import CommentTable, SubmissionTable
14
13
 
15
14
  logger = log.getLogger(__name__)
16
15
 
17
- class RedditHandler(APIHandler):
18
16
 
17
+ class RedditHandler(APIHandler):
19
18
 
20
19
  def __init__(self, name=None, **kwargs):
21
20
  super().__init__(name)
@@ -57,7 +56,6 @@ class RedditHandler(APIHandler):
57
56
  self.is_connected = True
58
57
  return self.reddit
59
58
 
60
-
61
59
  def check_connection(self) -> StatusResponse:
62
60
  '''It evaluates if the connection with Reddit API is alive and healthy.
63
61
  Returns:
@@ -101,6 +99,3 @@ class RedditHandler(APIHandler):
101
99
  RESPONSE_TYPE.TABLE,
102
100
  data_frame=df
103
101
  )
104
-
105
-
106
-
@@ -49,7 +49,6 @@ class CommentTable(APITable):
49
49
  self.filter_columns(result, query)
50
50
  return result
51
51
 
52
-
53
52
  def get_columns(self):
54
53
  '''Get the list of column names for the comment table.
55
54
 
@@ -80,6 +79,7 @@ class CommentTable(APITable):
80
79
  if len(columns) > 0:
81
80
  result = result[columns]
82
81
 
82
+
83
83
  class SubmissionTable(APITable):
84
84
  def select(self, query: ast.Select) -> pd.DataFrame:
85
85
  '''Select data from the submission table and return it as a pandas DataFrame.
@@ -143,7 +143,6 @@ class SubmissionTable(APITable):
143
143
  self.filter_columns(result, query)
144
144
  return result
145
145
 
146
-
147
146
  def get_columns(self):
148
147
  '''Get the list of column names for the submission table.
149
148
 
@@ -188,7 +187,7 @@ class SubmissionTable(APITable):
188
187
  result[col] = None
189
188
 
190
189
  result = result[columns]
191
-
190
+
192
191
  if query is not None and query.limit is not None:
193
192
  return result.head(query.limit.value)
194
193
 
@@ -33,7 +33,7 @@ class ReplicateHandler(BaseMLEngine):
33
33
  raise Exception("Provided api_key is Incorrect. Get your api_key here: https://replicate.com/account/api-tokens")
34
34
 
35
35
  else:
36
- raise Exception(f"Error occured.", e)
36
+ raise Exception("Error occured.", e)
37
37
 
38
38
  def create(self, target: str, df: Optional[pd.DataFrame] = None, args: Optional[Dict] = None) -> None:
39
39
  """Saves model details in storage to access it later
@@ -44,11 +44,11 @@ class ReplicateHandler(BaseMLEngine):
44
44
 
45
45
  def predict(self, df: pd.DataFrame, args: Optional[Dict] = None) -> pd.DataFrame:
46
46
  """Using replicate makes the prediction according to your parameters
47
-
47
+
48
48
  Args:
49
49
  df (pd.DataFrame): The input DataFrame containing data to predict.
50
50
  args (Optional[Dict]): Additional arguments for prediction parameters.
51
-
51
+
52
52
  Returns:
53
53
  pd.DataFrame: The DataFrame containing the predicted results.
54
54
  """
@@ -67,7 +67,7 @@ class ReplicateHandler(BaseMLEngine):
67
67
  output = replicate.run(
68
68
  f"{args['model_name']}:{args['version']}",
69
69
  input={**conditions.to_dict(), **pred_args} # Unpacking parameters inputted
70
- )
70
+ )
71
71
  # Process output based on the model type
72
72
  if isinstance(output, types.GeneratorType) and args.get('model_type') == 'LLM':
73
73
  output = ''.join(list(output)) # If model_type is LLM, make the stream a string
@@ -87,7 +87,7 @@ class ReplicateHandler(BaseMLEngine):
87
87
 
88
88
  if wrong_params:
89
89
  raise Exception(f"""'{wrong_params}' is/are not supported parameter for this model.
90
- Use DESCRIBE PREDICTOR mindsdb.<model_name>.features; to know about available parameters. OR
90
+ Use DESCRIBE PREDICTOR mindsdb.<model_name>.features; to know about available parameters. OR
91
91
  Visit https://replicate.com/{model_name}/versions/{version} to check parameters.""")
92
92
 
93
93
  # Set the Replicate API token for communication with the server
@@ -134,7 +134,7 @@ Visit https://replicate.com/{model_name}/versions/{version} to check parameters.
134
134
  return replicate_cfg['api_key']
135
135
 
136
136
  if strict:
137
- raise Exception(f'Missing API key "api_key". Either re-create this ML_ENGINE specifying the `api_key` parameter,\
137
+ raise Exception('Missing API key "api_key". Either re-create this ML_ENGINE specifying the `api_key` parameter,\
138
138
  or re-create this model and pass the API key with `USING` syntax.')
139
139
 
140
140
  def _get_schema(self, only_keys=False):
@@ -1,5 +1,4 @@
1
1
  import pandas as pd
2
- from typing import Dict, List
3
2
 
4
3
  from rocketchat_API.rocketchat import RocketChat
5
4
 
@@ -15,6 +14,7 @@ from mindsdb_sql_parser import parse_sql
15
14
 
16
15
  logger = log.getLogger(__name__)
17
16
 
17
+
18
18
  class RocketChatHandler(APIChatHandler):
19
19
  """A class for handling connections and interactions with the Rocket Chat API.
20
20
 
@@ -132,7 +132,6 @@ class RocketChatHandler(APIChatHandler):
132
132
  ast = parse_sql(query)
133
133
  return self.query(ast)
134
134
 
135
-
136
135
  def call_api(self, method_name: str = None, *args, **kwargs) -> pd.DataFrame:
137
136
  """Calls the Rocket Chat API method with the given params.
138
137
 
@@ -1,5 +1,3 @@
1
- from typing import List
2
-
3
1
  import pandas as pd
4
2
 
5
3
  from mindsdb.integrations.libs.api_handler import APITable
@@ -198,4 +196,3 @@ class UsersTable(APITable):
198
196
  'active',
199
197
  'type',
200
198
  ]
201
-