1- from typing import Optional
1+ from pydantic import BaseModel , Field
2+ from typing import List , Optional
3+ from uuid import uuid4
24
35import requests
46from logging import getLogger
@@ -16,27 +18,48 @@ def __init__(self, name):
1618 self .name = name
1719
1820
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+
1946# Create mind entity util function
2047def create_mind (
2148 base_url : str ,
2249 api_key : str ,
2350 name : str ,
24- description : str ,
25- data_source_type : str ,
26- data_source_connection_args : dict ,
51+ data_source_configs : List [DataSourceConfig ] = None ,
2752 model : Optional [str ] = None ,
2853) -> Mind :
2954 """
3055 Create a mind entity in LiteLLM proxy.
3156
3257 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
3762 model: Model orchestrating the AI reasoning loop
38- data_source_type: Data source type
39- data_source_connection_args: Data source connection arguments
4063
4164 Returns:
4265 Mind: Mind entity
@@ -46,10 +69,8 @@ def create_mind(
4669 headers = {"Authorization" : f"Bearer { api_key } " }
4770 payload = {
4871 "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
5374 }
5475 try :
5576 response = requests .post (url , json = payload , headers = headers )
0 commit comments