Skip to content

Commit 3ca8e0b

Browse files
authored
Merge branch 'mindsdb:main' into patch-2
2 parents 25c1361 + 78affc8 commit 3ca8e0b

File tree

7 files changed

+25
-24
lines changed

7 files changed

+25
-24
lines changed

.github/workflows/test_on_deploy.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
python-version: ['3.8', '3.9','3.10', '3.11']
12+
python-version: ['3.10']
1313
steps:
1414
- name: Checkout code
1515
uses: actions/checkout@v2
@@ -28,4 +28,4 @@ jobs:
2828
env:
2929
PYTHONPATH: ./
3030
API_KEY: ${{ secrets.API_KEY }}
31-
BASE_URL: ${{ secrets.BASE_URL }}
31+
BASE_URL: 'https://mdb.ai'

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,9 @@ client.datasources.drop('my_datasource')
150150
>Note: The SDK currently does not support automatically removing a data source if it is no longer connected to any mind.
151151
152152
### Other SDKs
153-
#### [Command-Line](https://github.com/Better-Boy/minds-cli-sdk)
153+
- [Dart-SDK](https://github.com/ArnavK-09/mdb_dart)
154+
155+
#### Command Line Tools
156+
- [Minds CLI](https://github.com/Better-Boy/minds-cli-sdk)
157+
158+

minds/__about__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__title__ = 'minds_sdk'
22
__package_name__ = 'minds'
3-
__version__ = '1.0.8'
3+
__version__ = '1.0.9'
44
__description__ = 'An AI-Data Mind is an LLM with the built-in power to answer data questions for Agents'
55
__email__ = 'hello@mindsdb.com'
66
__author__ = 'MindsDB Inc'

minds/datasources/datasources.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def create(self, ds_config: DatabaseConfig, update=False):
4040
utils.validate_datasource_name(name)
4141

4242
if update:
43-
self.api.put('/datasources', data=ds_config.model_dump())
43+
self.api.put(f'/datasources/{name}', data=ds_config.model_dump())
4444
else:
4545
self.api.post('/datasources', data=ds_config.model_dump())
4646
return self.get(name)

minds/minds.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from typing import List, Union, Iterable
2-
import utils
32
from openai import OpenAI
43
import minds.utils as utils
54
import minds.exceptions as exc
@@ -278,11 +277,13 @@ def create(
278277

279278
if update:
280279
method = self.api.put
280+
url = f'/projects/{self.project}/minds/{name}'
281281
else:
282282
method = self.api.post
283+
url = f'/projects/{self.project}/minds'
283284

284285
method(
285-
f'/projects/{self.project}/minds',
286+
url,
286287
data={
287288
'name': name,
288289
'model_name': model_name,

tests/integration/test_base_flow.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def test_minds():
8282
# prepare datasources
8383
ds_cfg = copy.copy(example_ds)
8484
ds_cfg.name = ds_name
85-
ds = client.datasources.create(example_ds, replace=True)
85+
ds = client.datasources.create(example_ds, update=True)
8686

8787
# second datasource
8888
ds2_cfg = copy.copy(example_ds)
@@ -91,7 +91,7 @@ def test_minds():
9191

9292
# create
9393
with pytest.raises(MindNameInvalid):
94-
mind = client.minds.create(
94+
client.minds.create(
9595
invalid_mind_name,
9696
datasources=[ds],
9797
provider='openai'
@@ -119,9 +119,6 @@ def test_minds():
119119
mind = client.minds.get(mind_name)
120120
assert len(mind.datasources) == 2
121121
assert mind.prompt_template == prompt1
122-
123-
with pytest.raises(MindNameInvalid):
124-
client.minds.get(invalid_mind_name)
125122

126123
# list
127124
mind_list = client.minds.list()
@@ -188,6 +185,4 @@ def test_minds():
188185
client.minds.drop(mind_name2)
189186
client.datasources.drop(ds.name)
190187
client.datasources.drop(ds2_cfg.name)
191-
192-
with pytest.raises(MindNameInvalid):
193-
client.minds.drop(invalid_mind_name)
188+

tests/unit/test_unit.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ def test_create_datasources(self, mock_del, mock_post, mock_put, mock_get):
4444
response_mock(mock_get, example_ds.model_dump())
4545

4646
ds = client.datasources.create(example_ds)
47-
def check_ds_created(ds, mock_post):
47+
def check_ds_created(ds, mock_post, url):
4848
self._compare_ds(ds, example_ds)
4949
args, kwargs = mock_post.call_args
5050

5151
assert kwargs['headers'] == {'Authorization': 'Bearer ' + API_KEY}
5252
assert kwargs['json'] == example_ds.model_dump()
53-
assert args[0] == 'https://mdb.ai/api/datasources'
53+
assert args[0] == url
5454

55-
check_ds_created(ds, mock_post)
55+
check_ds_created(ds, mock_post, 'https://mdb.ai/api/datasources')
5656

5757
# with update
5858
ds = client.datasources.create(example_ds, update=True)
59-
check_ds_created(ds, mock_put)
59+
check_ds_created(ds, mock_put, f'https://mdb.ai/api/datasources/{ds.name}')
6060

6161
@patch('requests.get')
6262
def test_get_datasource(self, mock_get):
@@ -132,17 +132,17 @@ def test_create(self, mock_del, mock_post, mock_put, mock_get):
132132
}
133133
mind = client.minds.create(**create_params)
134134

135-
def check_mind_created(mind, mock_post, create_params):
135+
def check_mind_created(mind, mock_post, create_params, url):
136136
args, kwargs = mock_post.call_args
137-
assert args[0].endswith('/api/projects/mindsdb/minds')
137+
assert args[0].endswith(url)
138138
request = kwargs['json']
139139
for key in ('name', 'datasources', 'provider', 'model_name'),:
140140
assert request.get(key) == create_params.get(key)
141141
assert create_params.get('prompt_template') == request.get('parameters', {}).get('prompt_template')
142142

143143
self.compare_mind(mind, self.mind_json)
144144

145-
check_mind_created(mind, mock_post, create_params)
145+
check_mind_created(mind, mock_post, create_params, '/api/projects/mindsdb/minds')
146146

147147
# -- with replace --
148148
create_params = {
@@ -156,15 +156,15 @@ def check_mind_created(mind, mock_post, create_params):
156156
args, _ = mock_del.call_args
157157
assert args[0].endswith(f'/api/projects/mindsdb/minds/{mind_name}')
158158

159-
check_mind_created(mind, mock_post, create_params)
159+
check_mind_created(mind, mock_post, create_params, '/api/projects/mindsdb/minds')
160160

161161
# -- with update --
162162
mock_del.reset_mock()
163163
mind = client.minds.create(update=True, **create_params)
164164
# is not deleted
165165
assert not mock_del.called
166166

167-
check_mind_created(mind, mock_put, create_params)
167+
check_mind_created(mind, mock_put, create_params, f'/api/projects/mindsdb/minds/{mind_name}')
168168

169169
@patch('requests.get')
170170
@patch('requests.patch')

0 commit comments

Comments
 (0)