@@ -71,9 +71,9 @@ class PendleMarketConfig(BaseModel):
7171 default = None ,
7272 description = "Model configuration for LLM. If not provided, will use agent's core model" ,
7373 )
74- database : Optional [DatabaseConfig ] = Field (
74+ db_url : Optional [str ] = Field (
7575 default = None ,
76- description = "Database configuration. If not provided, will use SQLite with default path" ,
76+ description = "Database URL. For postgres: postgresql://user:password@host:port/database, for sqlite: sqlite:/// path/to/file.db"
7777 )
7878
7979
@@ -87,21 +87,14 @@ def __init__(self, core_model=None):
8787 self .tool_prompt = None
8888 self .DBSession = None
8989
90- def _init_database (self , config : Optional [DatabaseConfig ] = None ) -> None :
90+ def _init_database (self , db_url : Optional [str ] ) -> None :
9191 """Initialize database connection based on configuration"""
9292 # Set default configuration if not provided
93- db_type = "sqlite"
94- db_url = 'sqlite:///' + os .path .join (os .getcwd (), "storage" , f"{ self .name } .db" )
95-
96- if config :
97- db_type = config .type
98- db_url = config .url
93+ if not db_url :
94+ db_url = 'sqlite:///' + os .path .join (os .getcwd (), "storage" , f"{ self .name } .db" )
9995
10096 # Create engine using the database module's create_engine function
101- engine = create_engine (
102- db_type = db_type ,
103- db_url = db_url ,
104- )
97+ engine = create_engine (db_url )
10598
10699 # Create tables and initialize session factory
107100 Base .metadata .create_all (engine )
@@ -119,7 +112,7 @@ async def setup(self, config: PendleMarketConfig) -> None:
119112 """Setup the analysis tool with model and prompt"""
120113
121114 # Initialize database
122- self ._init_database (config .database )
115+ self ._init_database (config .db_url )
123116
124117 # Initialize the model
125118 model_config = config .model if config .model else self .core_model
0 commit comments