from sqlalchemy import create_engine, text from src.core.config import Config class AgentMiddleware: def __init__(self): self.config = Config() try: self.engine = create_engine(self.config.DB_URL) except: self.engine = None def get_db_schema(self): # The AI on HF doesn't need to know its OWN local DB schema anymore, # because the Flask App will inject the REAL schema. # We return a placeholder here or keep it for internal memory. return "Schema provided in user context." def get_workflow_tools(self): return """ [AVAILABLE WORKFLOW NODES] Use ONLY these node types. Do not invent new ones. 1. 'google_sheet_read' - config: { "sheetId": "spreadsheet_id", "range": "A1:Z" } 2. 'google_sheet_write' - config: { "sheetId": "spreadsheet_id", "range": "A1", "data": "{{parent_id.output}}", "writeMode": "append" } 3. 'google_doc_read' - config: { "docId": "document_id" } 4. 'gmail_send' - config: { "to": "email@address.com", "subject": "Subject", "body": "Message" } 5. 'slack_notify' - config: { "url": "webhook_url", "message": "Message" } 6. 'discord_notify' - config: { "url": "webhook_url", "message": "Message" } 7. 'filter' - config: { "keyword": "status" } 8. 'invoice_ocr' - config: { "fileUrl": "path/to/file" } [DATABASE ACTIONS] To query or modify data, use the 'database_query' action. [OUTPUT FORMAT - WORKFLOW] To build a flow: ```json { "action": "create_workflow", "name": "Workflow Name", "payload": { "nodes": [ {"id": "1", "type": "google_sheet_read", "config": {...}, "position": {"x": 0, "y": 0}} ], "edges": [] } } ``` [OUTPUT FORMAT - SQL] To read/write data directly: ```json { "action": "query_db", "query": "INSERT INTO customers (name) VALUES ('New User')" } ``` """