1
- from typing import Optional
1
+ from pydantic import BaseModel , Field
2
+ from typing import List , Optional
3
+ from uuid import uuid4
2
4
3
5
import requests
4
6
from logging import getLogger
@@ -16,27 +18,48 @@ def __init__(self, name):
16
18
self .name = name
17
19
18
20
21
+ class DataSourceConfig (BaseModel ):
22
+ """
23
+ Represents a data source that can be made available to a Mind.
24
+ """
25
+ id : str = Field (default_factory = lambda : uuid4 ().hex )
26
+
27
+ # Description for underlying agent to know, based on context, whether to access this data source.
28
+ description : str
29
+
30
+
31
+ class DatabaseConfig (DataSourceConfig ):
32
+ """
33
+ Represents a database that can be made available to a Mind.
34
+ """
35
+
36
+ # Integration name (e.g. postgres)
37
+ type : str
38
+
39
+ # Args for connecting to database.
40
+ connection_args : dict
41
+
42
+ # Tables to make available to the Mind (defaults to ALL).
43
+ tables : List [str ] = []
44
+
45
+
19
46
# Create mind entity util function
20
47
def create_mind (
21
48
base_url : str ,
22
49
api_key : str ,
23
50
name : str ,
24
- description : str ,
25
- data_source_type : str ,
26
- data_source_connection_args : dict ,
51
+ data_source_configs : List [DataSourceConfig ] = None ,
27
52
model : Optional [str ] = None ,
28
53
) -> Mind :
29
54
"""
30
55
Create a mind entity in LiteLLM proxy.
31
56
32
57
Args:
33
- base_url: MindsDB base URL
34
- api_key: MindsDB API key
35
- name: Mind name
36
- description: Mind description
58
+ base_url (str) : MindsDB base URL
59
+ api_key (str) : MindsDB API key
60
+ name (str) : Mind name
61
+ data_source_configs (List[DataSourceConfig]): Data sources to make available to the mind
37
62
model: Model orchestrating the AI reasoning loop
38
- data_source_type: Data source type
39
- data_source_connection_args: Data source connection arguments
40
63
41
64
Returns:
42
65
Mind: Mind entity
@@ -46,10 +69,8 @@ def create_mind(
46
69
headers = {"Authorization" : f"Bearer { api_key } " }
47
70
payload = {
48
71
"name" : name ,
49
- "description" : description ,
50
- "model" : model ,
51
- "data_source_type" : data_source_type ,
52
- "data_source_connection_args" : data_source_connection_args
72
+ "data_source_configs" : [d .model_dump () for d in data_source_configs ],
73
+ "model" : model
53
74
}
54
75
try :
55
76
response = requests .post (url , json = payload , headers = headers )
0 commit comments