@@ -385,6 +385,7 @@ async def executeScript(database_id: str, script: str, logic: bool = False) -> D
385
385
386
386
This tool converts natural language questions into SQL queries that can be executed against a database.
387
387
If you don't have the database_id, use the searchDatabase tool first to identify the correct database.
388
+ The sql generated could be executed via DMS executeScript tool provided in this server if necessary.
388
389
389
390
Parameters:
390
391
question (str): Natural language question about the database that needs to be converted to SQL.
@@ -394,10 +395,6 @@ async def executeScript(database_id: str, script: str, logic: bool = False) -> D
394
395
Returns:
395
396
Dict[str, Any]: A dictionary containing:
396
397
- Sql (str): The generated SQL query based on the natural language question
397
- - Tables (List[Dict]): Tables referenced in the query
398
- - SimilarSql (List[Dict]): Similar SQL examples that may be helpful
399
- - Success (bool): Whether the conversion was successful
400
- - RequestId (str): Unique request identifier
401
398
""" )
402
399
async def nl2sql (database_id : str , question : str , knowledge : Optional [str ] = None ) -> Dict [str , Any ]:
403
400
if not isinstance (question , str ) or not question .strip ():
@@ -416,7 +413,9 @@ async def nl2sql(database_id: str, question: str, knowledge: Optional[str] = Non
416
413
logging .warning ("Empty or invalid response received from DMS service" )
417
414
return []
418
415
data = response .body .to_map ()
419
- return data
416
+ if data :
417
+ sql = data .get ('Data' , {}).get ('Sql' )
418
+ return sql
420
419
except Exception as error :
421
420
logging .error (error )
422
421
raise error
0 commit comments