MindsDB 25.7.3.0__py3-none-any.whl → 25.8.2.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 (102) hide show
  1. mindsdb/__about__.py +1 -1
  2. mindsdb/__main__.py +11 -1
  3. mindsdb/api/a2a/common/server/server.py +16 -6
  4. mindsdb/api/executor/command_executor.py +215 -150
  5. mindsdb/api/executor/datahub/datanodes/project_datanode.py +14 -3
  6. mindsdb/api/executor/planner/plan_join.py +3 -0
  7. mindsdb/api/executor/planner/plan_join_ts.py +117 -100
  8. mindsdb/api/executor/planner/query_planner.py +1 -0
  9. mindsdb/api/executor/sql_query/steps/apply_predictor_step.py +54 -85
  10. mindsdb/api/executor/sql_query/steps/fetch_dataframe.py +21 -24
  11. mindsdb/api/executor/sql_query/steps/fetch_dataframe_partition.py +9 -3
  12. mindsdb/api/executor/sql_query/steps/subselect_step.py +11 -8
  13. mindsdb/api/executor/utilities/mysql_to_duckdb_functions.py +264 -0
  14. mindsdb/api/executor/utilities/sql.py +30 -0
  15. mindsdb/api/http/initialize.py +18 -44
  16. mindsdb/api/http/namespaces/agents.py +23 -20
  17. mindsdb/api/http/namespaces/chatbots.py +83 -120
  18. mindsdb/api/http/namespaces/file.py +1 -1
  19. mindsdb/api/http/namespaces/jobs.py +38 -60
  20. mindsdb/api/http/namespaces/tree.py +69 -61
  21. mindsdb/api/http/namespaces/views.py +56 -72
  22. mindsdb/api/mcp/start.py +2 -0
  23. mindsdb/api/mysql/mysql_proxy/utilities/dump.py +3 -2
  24. mindsdb/integrations/handlers/autogluon_handler/requirements.txt +1 -1
  25. mindsdb/integrations/handlers/autosklearn_handler/requirements.txt +1 -1
  26. mindsdb/integrations/handlers/bigquery_handler/bigquery_handler.py +25 -5
  27. mindsdb/integrations/handlers/chromadb_handler/chromadb_handler.py +3 -3
  28. mindsdb/integrations/handlers/db2_handler/db2_handler.py +19 -23
  29. mindsdb/integrations/handlers/flaml_handler/requirements.txt +1 -1
  30. mindsdb/integrations/handlers/gong_handler/__about__.py +2 -0
  31. mindsdb/integrations/handlers/gong_handler/__init__.py +30 -0
  32. mindsdb/integrations/handlers/gong_handler/connection_args.py +37 -0
  33. mindsdb/integrations/handlers/gong_handler/gong_handler.py +164 -0
  34. mindsdb/integrations/handlers/gong_handler/gong_tables.py +508 -0
  35. mindsdb/integrations/handlers/gong_handler/icon.svg +25 -0
  36. mindsdb/integrations/handlers/gong_handler/test_gong_handler.py +125 -0
  37. mindsdb/integrations/handlers/google_calendar_handler/google_calendar_tables.py +82 -73
  38. mindsdb/integrations/handlers/hubspot_handler/requirements.txt +1 -1
  39. mindsdb/integrations/handlers/huggingface_handler/__init__.py +8 -12
  40. mindsdb/integrations/handlers/huggingface_handler/finetune.py +203 -223
  41. mindsdb/integrations/handlers/huggingface_handler/huggingface_handler.py +360 -383
  42. mindsdb/integrations/handlers/huggingface_handler/requirements.txt +7 -7
  43. mindsdb/integrations/handlers/huggingface_handler/requirements_cpu.txt +7 -7
  44. mindsdb/integrations/handlers/huggingface_handler/settings.py +25 -25
  45. mindsdb/integrations/handlers/langchain_handler/langchain_handler.py +83 -77
  46. mindsdb/integrations/handlers/lightwood_handler/requirements.txt +4 -4
  47. mindsdb/integrations/handlers/litellm_handler/litellm_handler.py +5 -2
  48. mindsdb/integrations/handlers/litellm_handler/settings.py +2 -1
  49. mindsdb/integrations/handlers/openai_handler/constants.py +11 -30
  50. mindsdb/integrations/handlers/openai_handler/helpers.py +27 -34
  51. mindsdb/integrations/handlers/openai_handler/openai_handler.py +14 -12
  52. mindsdb/integrations/handlers/pgvector_handler/pgvector_handler.py +106 -90
  53. mindsdb/integrations/handlers/postgres_handler/postgres_handler.py +41 -39
  54. mindsdb/integrations/handlers/salesforce_handler/constants.py +215 -0
  55. mindsdb/integrations/handlers/salesforce_handler/salesforce_handler.py +141 -80
  56. mindsdb/integrations/handlers/salesforce_handler/salesforce_tables.py +0 -1
  57. mindsdb/integrations/handlers/tpot_handler/requirements.txt +1 -1
  58. mindsdb/integrations/handlers/web_handler/urlcrawl_helpers.py +32 -17
  59. mindsdb/integrations/handlers/web_handler/web_handler.py +19 -22
  60. mindsdb/integrations/libs/llm/config.py +0 -14
  61. mindsdb/integrations/libs/llm/utils.py +0 -15
  62. mindsdb/integrations/libs/vectordatabase_handler.py +10 -1
  63. mindsdb/integrations/utilities/files/file_reader.py +5 -19
  64. mindsdb/integrations/utilities/handler_utils.py +32 -12
  65. mindsdb/integrations/utilities/rag/rerankers/base_reranker.py +1 -1
  66. mindsdb/interfaces/agents/agents_controller.py +246 -149
  67. mindsdb/interfaces/agents/constants.py +0 -1
  68. mindsdb/interfaces/agents/langchain_agent.py +11 -6
  69. mindsdb/interfaces/data_catalog/data_catalog_loader.py +4 -4
  70. mindsdb/interfaces/database/database.py +38 -13
  71. mindsdb/interfaces/database/integrations.py +20 -5
  72. mindsdb/interfaces/database/projects.py +174 -23
  73. mindsdb/interfaces/database/views.py +86 -60
  74. mindsdb/interfaces/jobs/jobs_controller.py +103 -110
  75. mindsdb/interfaces/knowledge_base/controller.py +33 -6
  76. mindsdb/interfaces/knowledge_base/evaluate.py +2 -1
  77. mindsdb/interfaces/knowledge_base/executor.py +24 -0
  78. mindsdb/interfaces/knowledge_base/preprocessing/document_preprocessor.py +6 -10
  79. mindsdb/interfaces/knowledge_base/preprocessing/text_splitter.py +73 -0
  80. mindsdb/interfaces/query_context/context_controller.py +111 -145
  81. mindsdb/interfaces/skills/skills_controller.py +18 -6
  82. mindsdb/interfaces/storage/db.py +40 -6
  83. mindsdb/interfaces/variables/variables_controller.py +8 -15
  84. mindsdb/utilities/config.py +5 -3
  85. mindsdb/utilities/fs.py +54 -17
  86. mindsdb/utilities/functions.py +72 -60
  87. mindsdb/utilities/log.py +38 -6
  88. mindsdb/utilities/ps.py +7 -7
  89. {mindsdb-25.7.3.0.dist-info → mindsdb-25.8.2.0.dist-info}/METADATA +282 -268
  90. {mindsdb-25.7.3.0.dist-info → mindsdb-25.8.2.0.dist-info}/RECORD +94 -92
  91. mindsdb/integrations/handlers/anyscale_endpoints_handler/__about__.py +0 -9
  92. mindsdb/integrations/handlers/anyscale_endpoints_handler/__init__.py +0 -20
  93. mindsdb/integrations/handlers/anyscale_endpoints_handler/anyscale_endpoints_handler.py +0 -290
  94. mindsdb/integrations/handlers/anyscale_endpoints_handler/creation_args.py +0 -14
  95. mindsdb/integrations/handlers/anyscale_endpoints_handler/icon.svg +0 -4
  96. mindsdb/integrations/handlers/anyscale_endpoints_handler/requirements.txt +0 -2
  97. mindsdb/integrations/handlers/anyscale_endpoints_handler/settings.py +0 -51
  98. mindsdb/integrations/handlers/anyscale_endpoints_handler/tests/test_anyscale_endpoints_handler.py +0 -212
  99. /mindsdb/integrations/handlers/{anyscale_endpoints_handler/tests/__init__.py → gong_handler/requirements.txt} +0 -0
  100. {mindsdb-25.7.3.0.dist-info → mindsdb-25.8.2.0.dist-info}/WHEEL +0 -0
  101. {mindsdb-25.7.3.0.dist-info → mindsdb-25.8.2.0.dist-info}/licenses/LICENSE +0 -0
  102. {mindsdb-25.7.3.0.dist-info → mindsdb-25.8.2.0.dist-info}/top_level.txt +0 -0
@@ -16,42 +16,37 @@ from mindsdb.utilities.exception import EntityNotExistsError
16
16
 
17
17
  def create_chatbot(project_name, name, chatbot):
18
18
  if name is None:
19
- return http_error(
20
- HTTPStatus.BAD_REQUEST,
21
- 'Missing field',
22
- 'Missing "name" field for chatbot'
23
- )
19
+ return http_error(HTTPStatus.BAD_REQUEST, "Missing field", 'Missing "name" field for chatbot')
24
20
 
25
- model_name = chatbot.get('model_name', None)
26
- agent_name = chatbot.get('agent_name', None)
21
+ if not name.islower():
22
+ return http_error(HTTPStatus.BAD_REQUEST, "Wrong name", f"The name must be in lower case: {name}")
23
+
24
+ model_name = chatbot.get("model_name", None)
25
+ agent_name = chatbot.get("agent_name", None)
27
26
  if model_name is None and agent_name is None:
28
27
  return http_error(
29
28
  HTTPStatus.BAD_REQUEST,
30
- 'Missing field',
31
- 'Must include either "model_name" or "agent_name" field for chatbot'
29
+ "Missing field",
30
+ 'Must include either "model_name" or "agent_name" field for chatbot',
32
31
  )
33
32
 
34
33
  session_controller = SessionController()
35
34
 
36
- if 'database_id' in chatbot or 'database_name' in chatbot or ('db_engine' in chatbot and 'db_params' in chatbot):
35
+ if "database_id" in chatbot or "database_name" in chatbot or ("db_engine" in chatbot and "db_params" in chatbot):
37
36
  try:
38
37
  database_id = get_or_create_database_for_chatbot(chatbot, session_controller)
39
38
  except ValueError as value_error:
40
- return http_error(
41
- HTTPStatus.NOT_FOUND,
42
- 'Database not found',
43
- str(value_error)
44
- )
39
+ return http_error(HTTPStatus.NOT_FOUND, "Database not found", str(value_error))
45
40
 
46
41
  else:
47
42
  return http_error(
48
43
  HTTPStatus.BAD_REQUEST,
49
- 'Missing field',
50
- 'Missing "database_id" or ("db_engine" and "database_param") fields for chatbot'
44
+ "Missing field",
45
+ 'Missing "database_id" or ("db_engine" and "database_param") fields for chatbot',
51
46
  )
52
47
 
53
- is_running = chatbot.get('is_running', False)
54
- params = chatbot.get('params', {})
48
+ is_running = chatbot.get("is_running", False)
49
+ params = chatbot.get("params", {})
55
50
 
56
51
  chatbot_controller = ChatBotController()
57
52
 
@@ -62,36 +57,26 @@ def create_chatbot(project_name, name, chatbot):
62
57
  existing_chatbot = chatbot_controller.get_chatbot(name, project_name=project_name)
63
58
  except EntityNotExistsError:
64
59
  # Project must exist.
65
- return http_error(
66
- HTTPStatus.NOT_FOUND,
67
- 'Project not found',
68
- f'Project with name {project_name} does not exist')
60
+ return http_error(HTTPStatus.NOT_FOUND, "Project not found", f"Project with name {project_name} does not exist")
69
61
  if existing_chatbot is not None:
70
62
  return http_error(
71
63
  HTTPStatus.CONFLICT,
72
- 'Chatbot already exists',
73
- f'Chatbot with name {name} already exists. Please use a different name'
64
+ "Chatbot already exists",
65
+ f"Chatbot with name {name} already exists. Please use a different name",
74
66
  )
75
67
 
76
68
  # Model and agent need to exist.
77
69
  if agent_name is not None:
78
70
  agent = AgentsController().get_agent(agent_name, project_name)
79
71
  if agent is None:
80
- return http_error(
81
- HTTPStatus.NOT_FOUND,
82
- 'Agent not found',
83
- f'Agent with name {agent_name} not found'
84
- )
72
+ return http_error(HTTPStatus.NOT_FOUND, "Agent not found", f"Agent with name {agent_name} not found")
85
73
  model_name = agent.model_name
86
74
 
87
75
  model_name_no_version, version = Predictor.get_name_and_version(model_name)
88
76
  try:
89
77
  session_controller.model_controller.get_model(model_name_no_version, version=version, project_name=project_name)
90
78
  except PredictorRecordNotFound:
91
- return http_error(
92
- HTTPStatus.NOT_FOUND,
93
- 'Model not found',
94
- f'Model with name {model_name} not found')
79
+ return http_error(HTTPStatus.NOT_FOUND, "Model not found", f"Model with name {model_name} not found")
95
80
 
96
81
  created_chatbot = chatbot_controller.add_chatbot(
97
82
  name,
@@ -100,7 +85,7 @@ def create_chatbot(project_name, name, chatbot):
100
85
  agent_name=agent_name,
101
86
  database_id=database_id,
102
87
  is_running=is_running,
103
- params=params
88
+ params=params,
104
89
  )
105
90
  return created_chatbot.as_dict(), HTTPStatus.CREATED
106
91
 
@@ -116,22 +101,22 @@ def get_or_create_database_for_chatbot(chatbot: dict, session_controller: Sessio
116
101
  Returns:
117
102
  int: The database ID.
118
103
  """
119
- if 'database_id' in chatbot:
120
- database_record = session_controller.integration_controller.get_by_id(chatbot['database_id'])
104
+ if "database_id" in chatbot:
105
+ database_record = session_controller.integration_controller.get_by_id(chatbot["database_id"])
121
106
  if database_record:
122
- return database_record['id']
107
+ return database_record["id"]
123
108
  else:
124
109
  raise ValueError(f"Database with ID {chatbot['database_id']} not found")
125
110
 
126
- elif 'database_name' in chatbot:
127
- database_record = session_controller.integration_controller.get(chatbot['database_name'])
111
+ elif "database_name" in chatbot:
112
+ database_record = session_controller.integration_controller.get(chatbot["database_name"])
128
113
  if database_record:
129
- return database_record['id']
114
+ return database_record["id"]
130
115
  else:
131
116
  raise ValueError(f"Database with name {chatbot['database_name']} not found")
132
117
 
133
- if 'db_params' in chatbot and 'db_engine' in chatbot:
134
- db_name = chatbot['name'] + '_db'
118
+ if "db_params" in chatbot and "db_engine" in chatbot:
119
+ db_name = chatbot["name"] + "_db"
135
120
 
136
121
  # try to drop
137
122
  existing_db = session_controller.integration_controller.get(db_name)
@@ -139,84 +124,75 @@ def get_or_create_database_for_chatbot(chatbot: dict, session_controller: Sessio
139
124
  # drop
140
125
  session_controller.integration_controller.delete(db_name)
141
126
 
142
- return session_controller.integration_controller.add(db_name, chatbot['db_engine'], chatbot['db_params'])
127
+ return session_controller.integration_controller.add(db_name, chatbot["db_engine"], chatbot["db_params"])
143
128
 
144
129
  return None
145
130
 
146
131
 
147
- @ns_conf.route('/<project_name>/chatbots')
132
+ @ns_conf.route("/<project_name>/chatbots")
148
133
  class ChatBotsResource(Resource):
149
- @ns_conf.doc('list_chatbots')
150
- @api_endpoint_metrics('GET', '/chatbots')
134
+ @ns_conf.doc("list_chatbots")
135
+ @api_endpoint_metrics("GET", "/chatbots")
151
136
  def get(self, project_name):
152
- ''' List all chatbots '''
137
+ """List all chatbots"""
153
138
  chatbot_controller = ChatBotController()
154
139
  try:
155
140
  all_bots = chatbot_controller.get_chatbots(project_name)
156
141
  except (ValueError, EntityNotExistsError):
157
142
  # Project needs to exist.
158
143
  return http_error(
159
- HTTPStatus.NOT_FOUND,
160
- 'Project not found',
161
- f'Project with name {project_name} does not exist')
144
+ HTTPStatus.NOT_FOUND, "Project not found", f"Project with name {project_name} does not exist"
145
+ )
162
146
  return all_bots
163
147
 
164
- @ns_conf.doc('create_chatbot')
165
- @api_endpoint_metrics('POST', '/chatbots')
148
+ @ns_conf.doc("create_chatbot")
149
+ @api_endpoint_metrics("POST", "/chatbots")
166
150
  def post(self, project_name):
167
- '''Create a chatbot'''
151
+ """Create a chatbot"""
168
152
 
169
153
  # Check for required parameters.
170
- if 'chatbot' not in request.json:
154
+ if "chatbot" not in request.json:
171
155
  return http_error(
172
- HTTPStatus.BAD_REQUEST,
173
- 'Missing parameter',
174
- 'Must provide "chatbot" parameter in POST body'
156
+ HTTPStatus.BAD_REQUEST, "Missing parameter", 'Must provide "chatbot" parameter in POST body'
175
157
  )
176
158
 
177
- chatbot = request.json['chatbot']
159
+ chatbot = request.json["chatbot"]
178
160
 
179
- name = chatbot.get('name')
161
+ name = chatbot.get("name")
180
162
  return create_chatbot(project_name, name, chatbot)
181
163
 
182
164
 
183
- @ns_conf.route('/<project_name>/chatbots/<chatbot_name>')
184
- @ns_conf.param('project_name', 'Name of the project')
185
- @ns_conf.param('chatbot_name', 'Name of the chatbot')
165
+ @ns_conf.route("/<project_name>/chatbots/<chatbot_name>")
166
+ @ns_conf.param("project_name", "Name of the project")
167
+ @ns_conf.param("chatbot_name", "Name of the chatbot")
186
168
  class ChatBotResource(Resource):
187
- @ns_conf.doc('get_chatbot')
188
- @api_endpoint_metrics('GET', '/chatbots/chatbot')
169
+ @ns_conf.doc("get_chatbot")
170
+ @api_endpoint_metrics("GET", "/chatbots/chatbot")
189
171
  def get(self, project_name, chatbot_name):
190
- '''Gets a chatbot by name'''
172
+ """Gets a chatbot by name"""
191
173
  chatbot_controller = ChatBotController()
192
174
  try:
193
175
  existing_chatbot = chatbot_controller.get_chatbot(chatbot_name, project_name=project_name)
194
176
  if existing_chatbot is None:
195
177
  return http_error(
196
- HTTPStatus.NOT_FOUND,
197
- 'Chatbot not found',
198
- f'Chatbot with name {chatbot_name} does not exist'
178
+ HTTPStatus.NOT_FOUND, "Chatbot not found", f"Chatbot with name {chatbot_name} does not exist"
199
179
  )
200
180
  return existing_chatbot
201
181
  except (ValueError, EntityNotExistsError):
202
182
  # Project needs to exist.
203
183
  return http_error(
204
- HTTPStatus.NOT_FOUND,
205
- 'Project not found',
206
- f'Project with name {project_name} does not exist'
184
+ HTTPStatus.NOT_FOUND, "Project not found", f"Project with name {project_name} does not exist"
207
185
  )
208
186
 
209
- @ns_conf.doc('update_chatbot')
210
- @api_endpoint_metrics('PUT', '/chatbots/chatbot')
187
+ @ns_conf.doc("update_chatbot")
188
+ @api_endpoint_metrics("PUT", "/chatbots/chatbot")
211
189
  def put(self, project_name, chatbot_name):
212
- '''Updates a chatbot by name, creating one if it doesn't exist'''
190
+ """Updates a chatbot by name, creating one if it doesn't exist"""
213
191
 
214
192
  # Check for required parameters.
215
- if 'chatbot' not in request.json:
193
+ if "chatbot" not in request.json:
216
194
  return http_error(
217
- HTTPStatus.BAD_REQUEST,
218
- 'Missing parameter',
219
- 'Must provide "chatbot" parameter in POST body'
195
+ HTTPStatus.BAD_REQUEST, "Missing parameter", 'Must provide "chatbot" parameter in POST body'
220
196
  )
221
197
  chatbot_controller = ChatBotController()
222
198
 
@@ -225,27 +201,21 @@ class ChatBotResource(Resource):
225
201
  except EntityNotExistsError:
226
202
  # Project needs to exist.
227
203
  return http_error(
228
- HTTPStatus.NOT_FOUND,
229
- 'Project not found',
230
- f'Project with name {project_name} does not exist'
204
+ HTTPStatus.NOT_FOUND, "Project not found", f"Project with name {project_name} does not exist"
231
205
  )
232
206
 
233
207
  session = SessionController()
234
208
 
235
- chatbot = request.json['chatbot']
236
- name = chatbot.get('name', None)
237
- agent_name = chatbot.get('agent_name', None)
238
- model_name = chatbot.get('model_name', None)
209
+ chatbot = request.json["chatbot"]
210
+ name = chatbot.get("name", None)
211
+ agent_name = chatbot.get("agent_name", None)
212
+ model_name = chatbot.get("model_name", None)
239
213
  try:
240
214
  database_id = get_or_create_database_for_chatbot(chatbot, session)
241
215
  except ValueError as value_error:
242
- return http_error(
243
- HTTPStatus.NOT_FOUND,
244
- 'Database not found',
245
- str(value_error)
246
- )
247
- is_running = chatbot.get('is_running', None)
248
- params = chatbot.get('params', None)
216
+ return http_error(HTTPStatus.NOT_FOUND, "Database not found", str(value_error))
217
+ is_running = chatbot.get("is_running", None)
218
+ params = chatbot.get("params", None)
249
219
 
250
220
  # Model needs to exist.
251
221
  if model_name is not None:
@@ -253,29 +223,26 @@ class ChatBotResource(Resource):
253
223
  try:
254
224
  session.model_controller.get_model(model_name_no_version, version=version, project_name=project_name)
255
225
  except PredictorRecordNotFound:
256
- return http_error(
257
- HTTPStatus.NOT_FOUND,
258
- 'Model not found',
259
- f'Model with name {model_name} not found')
226
+ return http_error(HTTPStatus.NOT_FOUND, "Model not found", f"Model with name {model_name} not found")
260
227
 
261
228
  # Agent needs to exist.
262
229
  if agent_name is not None:
263
230
  agent = session.agents_controller.get_agent(agent_name, project_name)
264
231
  if agent is None:
265
- return http_error(
266
- HTTPStatus.NOT_FOUND,
267
- 'Agent not found',
268
- f'Agent with name {agent_name} not found')
232
+ return http_error(HTTPStatus.NOT_FOUND, "Agent not found", f"Agent with name {agent_name} not found")
269
233
 
270
234
  # Chatbot must not exist with new name.
271
- if name is not None and name != chatbot_name:
272
- chatbot_with_new_name = chatbot_controller.get_chatbot(name, project_name=project_name)
273
- if chatbot_with_new_name is not None:
274
- return http_error(
275
- HTTPStatus.CONFLICT,
276
- 'Chatbot already exists',
277
- f'Chatbot with name {name} already exists. Please choose a different one.'
278
- )
235
+ if name is not None:
236
+ if name != chatbot_name:
237
+ chatbot_with_new_name = chatbot_controller.get_chatbot(name, project_name=project_name)
238
+ if chatbot_with_new_name is not None:
239
+ return http_error(
240
+ HTTPStatus.CONFLICT,
241
+ "Chatbot already exists",
242
+ f"Chatbot with name {name} already exists. Please choose a different one.",
243
+ )
244
+ if not name.islower():
245
+ return http_error(HTTPStatus.BAD_REQUEST, "Wrong name", f"The name must be in lower case: {name}")
279
246
 
280
247
  if existing_chatbot is None:
281
248
  # Create
@@ -290,30 +257,26 @@ class ChatBotResource(Resource):
290
257
  agent_name=agent_name,
291
258
  database_id=database_id,
292
259
  is_running=is_running,
293
- params=params
260
+ params=params,
294
261
  )
295
262
  return updated_chatbot.as_dict()
296
263
 
297
- @ns_conf.doc('delete_chatbot')
298
- @api_endpoint_metrics('DELETE', '/chatbots/chatbot')
264
+ @ns_conf.doc("delete_chatbot")
265
+ @api_endpoint_metrics("DELETE", "/chatbots/chatbot")
299
266
  def delete(self, project_name, chatbot_name):
300
- '''Deletes a chatbot by name'''
267
+ """Deletes a chatbot by name"""
301
268
  chatbot_controller = ChatBotController()
302
269
  try:
303
270
  existing_chatbot = chatbot_controller.get_chatbot(chatbot_name, project_name=project_name)
304
271
  if existing_chatbot is None:
305
272
  return http_error(
306
- HTTPStatus.NOT_FOUND,
307
- 'Chatbot not found',
308
- f'Chatbot with name {chatbot_name} does not exist'
273
+ HTTPStatus.NOT_FOUND, "Chatbot not found", f"Chatbot with name {chatbot_name} does not exist"
309
274
  )
310
275
  except EntityNotExistsError:
311
276
  # Project needs to exist.
312
277
  return http_error(
313
- HTTPStatus.NOT_FOUND,
314
- 'Project not found',
315
- f'Project with name {project_name} does not exist'
278
+ HTTPStatus.NOT_FOUND, "Project not found", f"Project with name {project_name} does not exist"
316
279
  )
317
280
 
318
281
  chatbot_controller.delete_chatbot(chatbot_name, project_name=project_name)
319
- return '', HTTPStatus.NO_CONTENT
282
+ return "", HTTPStatus.NO_CONTENT
@@ -47,7 +47,7 @@ class File(Resource):
47
47
  """
48
48
 
49
49
  data = {}
50
- mindsdb_file_name = name
50
+ mindsdb_file_name = name.lower()
51
51
 
52
52
  existing_file_names = ca.file_controller.get_files_names()
53
53
 
@@ -1,99 +1,77 @@
1
1
  from http import HTTPStatus
2
2
 
3
- from flask import request
3
+ from flask import request, current_app as ca
4
4
  from flask_restx import Resource
5
5
 
6
6
  from mindsdb.api.http.namespaces.configs.projects import ns_conf
7
7
  from mindsdb.api.http.utils import http_error
8
8
  from mindsdb.metrics.metrics import api_endpoint_metrics
9
9
 
10
- from mindsdb.interfaces.jobs.jobs_controller import JobsController, parse_job_date
10
+ from mindsdb.interfaces.jobs.jobs_controller import parse_job_date
11
11
 
12
12
 
13
- @ns_conf.route('/<project_name>/jobs')
13
+ @ns_conf.route("/<project_name>/jobs")
14
14
  class JobsResource(Resource):
15
- @ns_conf.doc('list_jobs')
16
- @api_endpoint_metrics('GET', '/jobs')
15
+ @ns_conf.doc("list_jobs")
16
+ @api_endpoint_metrics("GET", "/jobs")
17
17
  def get(self, project_name):
18
- """ List all jobs in a project """
19
- jobs_controller = JobsController()
18
+ """List all jobs in a project"""
19
+ return ca.jobs_controller.get_list(project_name)
20
20
 
21
- return jobs_controller.get_list(project_name)
22
-
23
- @ns_conf.doc('create_job')
24
- @api_endpoint_metrics('POST', '/jobs')
21
+ @ns_conf.doc("create_job")
22
+ @api_endpoint_metrics("POST", "/jobs")
25
23
  def post(self, project_name):
26
24
  """Create a job in a project"""
27
25
 
28
26
  # Check for required parameters.
29
- if 'job' not in request.json:
30
- return http_error(
31
- HTTPStatus.BAD_REQUEST,
32
- 'Missing parameter',
33
- 'Must provide "job" parameter in POST body'
34
- )
35
-
36
- job = request.json['job']
27
+ if "job" not in request.json:
28
+ return http_error(HTTPStatus.BAD_REQUEST, "Missing parameter", 'Must provide "job" parameter in POST body')
37
29
 
38
- name = job.pop('name')
39
- if job['start_at'] is not None:
40
- job['start_at'] = parse_job_date(job['start_at'])
41
- if job['end_at'] is not None:
42
- job['end_at'] = parse_job_date(job['end_at'])
30
+ job = request.json["job"]
43
31
 
44
- jobs_controller = JobsController()
32
+ name = job.pop("name")
33
+ if job["start_at"] is not None:
34
+ job["start_at"] = parse_job_date(job["start_at"])
35
+ if job["end_at"] is not None:
36
+ job["end_at"] = parse_job_date(job["end_at"])
45
37
 
46
- create_job_name = jobs_controller.add(name, project_name, **job)
38
+ create_job_name = ca.jobs_controller.add(name, project_name, **job)
47
39
 
48
- return jobs_controller.get(create_job_name, project_name)
40
+ return ca.jobs_controller.get(create_job_name, project_name)
49
41
 
50
42
 
51
- @ns_conf.route('/<project_name>/jobs/<job_name>')
52
- @ns_conf.param('project_name', 'Name of the project')
53
- @ns_conf.param('job_name', 'Name of the job')
43
+ @ns_conf.route("/<project_name>/jobs/<job_name>")
44
+ @ns_conf.param("project_name", "Name of the project")
45
+ @ns_conf.param("job_name", "Name of the job")
54
46
  class JobResource(Resource):
55
- @ns_conf.doc('get_job')
56
- @api_endpoint_metrics('GET', '/jobs/job')
47
+ @ns_conf.doc("get_job")
48
+ @api_endpoint_metrics("GET", "/jobs/job")
57
49
  def get(self, project_name, job_name):
58
50
  """Gets a job by name"""
59
-
60
- jobs_controller = JobsController()
61
- job_info = jobs_controller.get(job_name, project_name)
51
+ job_info = ca.jobs_controller.get(job_name, project_name)
62
52
  if job_info is not None:
63
53
  return job_info
64
54
 
65
- return http_error(
66
- HTTPStatus.NOT_FOUND,
67
- 'Job not found',
68
- f'Job with name {job_name} does not exist'
69
- )
55
+ return http_error(HTTPStatus.NOT_FOUND, "Job not found", f"Job with name {job_name} does not exist")
70
56
 
71
- @ns_conf.doc('delete_job')
72
- @api_endpoint_metrics('DELETE', '/jobs/job')
57
+ @ns_conf.doc("delete_job")
58
+ @api_endpoint_metrics("DELETE", "/jobs/job")
73
59
  def delete(self, project_name, job_name):
74
60
  """Deletes a job by name"""
61
+ ca.jobs_controller.delete(job_name, project_name)
75
62
 
76
- jobs_controller = JobsController()
77
- jobs_controller.delete(job_name, project_name)
63
+ return "", HTTPStatus.NO_CONTENT
78
64
 
79
- return '', HTTPStatus.NO_CONTENT
80
65
 
81
-
82
- @ns_conf.route('/<project_name>/jobs/<job_name>/history')
83
- @ns_conf.param('project_name', 'Name of the project')
84
- @ns_conf.param('job_name', 'Name of the job')
66
+ @ns_conf.route("/<project_name>/jobs/<job_name>/history")
67
+ @ns_conf.param("project_name", "Name of the project")
68
+ @ns_conf.param("job_name", "Name of the job")
85
69
  class JobsHistory(Resource):
86
- @ns_conf.doc('job_history')
87
- @api_endpoint_metrics('GET', '/jobs/job/history')
70
+ @ns_conf.doc("job_history")
71
+ @api_endpoint_metrics("GET", "/jobs/job/history")
88
72
  def get(self, project_name, job_name):
89
73
  """Get history of job calls"""
74
+ if ca.jobs_controller.get(job_name, project_name) is None:
75
+ return http_error(HTTPStatus.NOT_FOUND, "Job not found", f"Job with name {job_name} does not exist")
90
76
 
91
- jobs_controller = JobsController()
92
- if jobs_controller.get(job_name, project_name) is None:
93
- return http_error(
94
- HTTPStatus.NOT_FOUND,
95
- 'Job not found',
96
- f'Job with name {job_name} does not exist'
97
- )
98
-
99
- return jobs_controller.get_history(job_name, project_name)
77
+ return ca.jobs_controller.get_history(job_name, project_name)