Skip to content

Commit 9745716

Browse files
Merge branch 'main' into add-tree-api
2 parents a823fa3 + d7e20a7 commit 9745716

File tree

22 files changed

+1075
-1105
lines changed

22 files changed

+1075
-1105
lines changed

.github/workflows/cla.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: "MindsDB CLA Assistant"
2+
on:
3+
issue_comment:
4+
types: [created]
5+
pull_request_target:
6+
types: [opened,closed,synchronize]
7+
8+
permissions:
9+
actions: write
10+
contents: write
11+
pull-requests: write
12+
statuses: write
13+
14+
jobs:
15+
CLAssistant:
16+
runs-on: mdb-dev
17+
steps:
18+
- name: "CLA Assistant"
19+
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
20+
uses: contributor-assistant/[email protected]
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
with:
24+
path-to-signatures: 'assets/contributions-agreement/cla.json'
25+
path-to-document: 'https://github.com/mindsdb/mindsdb/blob/main/assets/contributions-agreement/individual-contributor.md'
26+
branch: 'cla'
27+
allowlist: bot*, ZoranPandovski, torrmal, Stpmax, mindsdbadmin, ea-rus, tmichaeldb, dusvyat, hamishfagg, MinuraPunchihewa, martyna-mindsdb, lucas-koontz

.github/workflows/release.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
matrix:
1212
os: [ubuntu-latest]
13-
python-version: [3.7,3.8,3.9]
13+
python-version: ['3.8', '3.9', '3.10', '3.11']
1414
steps:
1515
- uses: actions/checkout@v2
1616
- name: Set up Python ${{ matrix.python-version }}
@@ -31,11 +31,6 @@ jobs:
3131
3232
fi
3333
shell: bash
34-
env:
35-
CHECK_FOR_UPDATES: False
36-
DATABASE_CREDENTIALS_STRINGIFIED_JSON: ${{ secrets.DATABASE_CREDENTIALS }}
37-
CLOUD_TEST_EMAIL: ${{ secrets.CLOUD_TEST_EMAIL }}
38-
CLOUD_TEST_PASSWORD: ${{ secrets.CLOUD_TEST_PASSWORD }}
3934

4035

4136
deploy:
@@ -46,7 +41,7 @@ jobs:
4641
- name: Set up Python
4742
uses: actions/setup-python@v2
4843
with:
49-
python-version: '3.7'
44+
python-version: '3.9'
5045
- name: Install dependencies
5146
run: |
5247
python -m pip install --upgrade pip==20.2.4

.github/workflows/test_prs.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
matrix:
1313
os: [ubuntu-latest]
14-
python-version: [3.7,3.8,3.9]
14+
python-version: ['3.8', '3.9', '3.10', '3.11']
1515
steps:
1616
- uses: actions/checkout@v2
1717
- name: Set up Python ${{ matrix.python-version }}
@@ -32,11 +32,6 @@ jobs:
3232
3333
fi
3434
shell: bash
35-
env:
36-
CHECK_FOR_UPDATES: False
37-
DATABASE_CREDENTIALS_STRINGIFIED_JSON: ${{ secrets.DATABASE_CREDENTIALS }}
38-
CLOUD_TEST_EMAIL: ${{ secrets.CLOUD_TEST_EMAIL }}
39-
CLOUD_TEST_PASSWORD: ${{ secrets.CLOUD_TEST_PASSWORD }}
4035

4136
coverage:
4237
needs: test

LICENSE

Lines changed: 21 additions & 674 deletions
Large diffs are not rendered by default.

assets/contributions-agreement/cla.json

Whitespace-only changes.

mindsdb_sdk/__about__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
__title__ = 'mindsdb_sdk'
22
__package_name__ = 'mindsdb_sdk'
3-
__version__ = '3.1.6'
3+
__version__ = '3.4.6'
44
__description__ = "MindsDB Python SDK, provides an SDK to use a remote mindsdb instance"
55
__email__ = "[email protected]"
66
__author__ = 'MindsDB Inc'
77
__github__ = 'https://github.com/mindsdb/mindsdb_python_sdk'
88
__pypi__ = 'https://pypi.org/project/mindsdb-sdk/'
9-
__license__ = 'GPL-3.0'
9+
__license__ = 'MIT'
1010
__copyright__ = 'Copyright 2020- mindsdb'

mindsdb_sdk/config.py

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
from mindsdb_sdk.connectors.rest_api import RestAPI
2+
3+
4+
class Config():
5+
"""
6+
**Configuration for MindsDB**
7+
8+
This class provides methods to set and get the various configuration aspects of MindsDB.
9+
10+
Working with configuration:
11+
12+
Set default LLM configuration:
13+
14+
>>> server.config.set_default_llm(
15+
... provider='openai',
16+
... model_name='gpt-4',
17+
... api_key='sk-...'
18+
... )
19+
20+
Get default LLM configuration:
21+
22+
>>> llm_config = server.config.get_default_llm()
23+
>>> print(llm_config)
24+
25+
Set default embedding model:
26+
27+
>>> server.config.set_default_embedding_model(
28+
... provider='openai',
29+
... model_name='text-embedding-ada-002',
30+
... api_key='sk-...'
31+
... )
32+
33+
Get default embedding model:
34+
35+
>>> embedding_config = server.config.get_default_embedding_model()
36+
37+
Set default reranking model:
38+
39+
>>> server.config.set_default_reranking_model(
40+
... provider='openai',
41+
... model_name='gpt-4',
42+
... api_key='sk-...'
43+
... )
44+
45+
Get default reranking model:
46+
47+
>>> reranking_config = server.config.get_default_reranking_model()
48+
"""
49+
def __init__(self, api: RestAPI):
50+
self.api = api
51+
52+
def set_default_llm(
53+
self,
54+
provider: str,
55+
model_name: str,
56+
api_key: str = None,
57+
**kwargs
58+
):
59+
"""
60+
Set the default LLM configuration for MindsDB.
61+
62+
:param provider: The name of the LLM provider (e.g., 'openai', 'google').
63+
:param model_name: The name of the model to use.
64+
:param api_key: Optional API key for the provider.
65+
:param kwargs: Additional parameters for the LLM configuration.
66+
"""
67+
config = {
68+
"default_llm": {
69+
"provider": provider,
70+
"model_name": model_name,
71+
"api_key": api_key,
72+
**kwargs
73+
}
74+
}
75+
self.api.update_config(config)
76+
77+
def get_default_llm(self):
78+
"""
79+
Get the default LLM configuration for MindsDB.
80+
81+
:return: Dictionary containing the default LLM configuration.
82+
"""
83+
return self.api.get_config().get("default_llm", {})
84+
85+
def set_default_embedding_model(
86+
self,
87+
provider: str,
88+
model_name: str,
89+
api_key: str = None,
90+
**kwargs
91+
):
92+
"""
93+
Set the default embedding model configuration for MindsDB.
94+
95+
:param provider: The name of the embedding model provider (e.g., 'openai', 'google').
96+
:param model_name: The name of the embedding model to use.
97+
:param api_key: Optional API key for the provider.
98+
:param kwargs: Additional parameters for the embedding model configuration.
99+
"""
100+
config = {
101+
"default_embedding_model": {
102+
"provider": provider,
103+
"model_name": model_name,
104+
"api_key": api_key,
105+
**kwargs
106+
}
107+
}
108+
self.api.update_config(config)
109+
110+
def get_default_embedding_model(self):
111+
"""
112+
Get the default embedding model configuration for MindsDB.
113+
114+
:return: Dictionary containing the default embedding model configuration.
115+
"""
116+
return self.api.get_config().get("default_embedding_model", {})
117+
118+
def set_default_reranking_model(
119+
self,
120+
provider: str,
121+
model_name: str,
122+
api_key: str = None,
123+
**kwargs
124+
):
125+
"""
126+
Set the default reranking model configuration for MindsDB.
127+
128+
:param provider: The name of the reranking model provider (e.g., 'openai', 'google').
129+
:param model_name: The name of the reranking model to use.
130+
:param api_key: Optional API key for the provider.
131+
:param kwargs: Additional parameters for the reranking model configuration.
132+
"""
133+
config = {
134+
"default_reranking_model": {
135+
"provider": provider,
136+
"model_name": model_name,
137+
"api_key": api_key,
138+
**kwargs
139+
}
140+
}
141+
self.api.update_config(config)
142+
143+
def get_default_reranking_model(self):
144+
"""
145+
Get the default reranking model configuration for MindsDB.
146+
147+
:return: Dictionary containing the default reranking model configuration.
148+
"""
149+
return self.api.get_config().get("default_reranking_model", {})
150+

mindsdb_sdk/connect.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def connect(
1212
password: str = None,
1313
api_key: str = None,
1414
is_managed: bool = False,
15+
cookies=None,
1516
headers=None) -> Server:
1617
"""
1718
Create connection to mindsdb server
@@ -21,6 +22,7 @@ def connect(
2122
:param password: user password to login (for cloud version)
2223
:param api_key: API key to authenticate (for cloud version)
2324
:param is_managed: whether or not the URL points to a managed instance
25+
:param cookies: addtional cookies to send with the connection, optional
2426
:param headers: addtional headers to send with the connection, optional
2527
:return: Server object
2628
@@ -51,6 +53,7 @@ def connect(
5153
# is local
5254
url = DEFAULT_LOCAL_API_URL
5355

54-
api = RestAPI(url, login, password, api_key, is_managed, headers=headers)
56+
api = RestAPI(url, login, password, api_key, is_managed,
57+
cookies=cookies, headers=headers)
5558

5659
return Server(api)

0 commit comments

Comments
 (0)