Skip to content

Commit 09ec427

Browse files
authored
Merge pull request #119 from mindsdb/feat/add-create-mind-util
feat: add create mind util
2 parents 380a445 + 6fed9e2 commit 09ec427

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

mindsdb_sdk/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__title__ = 'mindsdb_sdk'
22
__package_name__ = 'mindsdb_sdk'
3-
__version__ = '2.3.0'
3+
__version__ = '2.4.0'
44
__description__ = "MindsDB Python SDK, provides an SDK to use a remote mindsdb instance"
55
__email__ = "[email protected]"
66
__author__ = 'MindsDB Inc'

mindsdb_sdk/utils/mind.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import requests
2+
3+
4+
# Define the Mind entity
5+
class Mind:
6+
"""
7+
Mind entity
8+
"""
9+
10+
def __init__(self, name):
11+
self.name = name
12+
13+
14+
# Create mind entity util function
15+
def create(
16+
base_url: str,
17+
api_key: str,
18+
model: str,
19+
connection_args: dict,
20+
data_source: str,
21+
description: str,
22+
) -> Mind:
23+
"""
24+
Create a mind entity in LiteLLM proxy.
25+
26+
Args:
27+
base_url: MindsDB base URL
28+
api_key: MindsDB API key
29+
model: Model name
30+
connection_args: Connection arguments
31+
data_source: Data source
32+
description: Description
33+
34+
Returns:
35+
Mind: Mind entity
36+
"""
37+
url = f"{base_url}/minds"
38+
headers = {"Authorization": f"Bearer {api_key}"}
39+
payload = {
40+
"model": model,
41+
"connection_args": connection_args,
42+
"data_source": data_source,
43+
"description": description
44+
}
45+
response = requests.post(url, json=payload, headers=headers)
46+
response.raise_for_status()
47+
48+
name = response.json()['name']
49+
50+
return Mind(name=name)

0 commit comments

Comments
 (0)