File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from uuid import uuid4
22
33from openai import OpenAI
4- from mindsdb_sdk .utils .mind import create_mind
4+ from mindsdb_sdk .utils .mind import create_mind , DatabaseConfig
55import os
66
77
2121 base_url = base_url
2222)
2323
24- # create a database mind
25- mind = create_mind (
26- name = f'my_house_data_mind_{ uuid4 ().hex } ' ,
27- description = 'House Sales' ,
28- base_url = base_url ,
29- api_key = MINDSDB_API_KEY ,
30- model = model_name ,
31- data_source_type = 'postgres' ,
32- data_source_connection_args = {
24+ # Create a Database Config.
25+ pg_config = DatabaseConfig (
26+ description = 'House Sales' ,
27+ type = 'postgres' ,
28+ connection_args = {
3329 'user' : 'demo_user' ,
3430 'password' : 'demo_password' ,
3531 'host' : 'samples.mindsdb.com' ,
3632 'port' : '5432' ,
3733 'database' : 'demo' ,
3834 'schema' : 'demo_data'
39- }
35+ },
36+ tables = ['house_sales' ]
37+ )
38+
39+ # create a database mind
40+ mind = create_mind (
41+ base_url = base_url ,
42+ api_key = MINDSDB_API_KEY ,
43+ name = f'my_house_data_mind_{ uuid4 ().hex } ' ,
44+ data_source_configs = [pg_config ],
45+ model = model_name
4046)
4147
4248# Actually pass in our tool to get a SQL completion.
You can’t perform that action at this time.
0 commit comments