File size: 2,236 Bytes
2e91995
 
 
 
 
 
 
 
 
 
 
 
 
80ce065
 
 
 
2e91995
 
 
 
80ce065
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2e91995
80ce065
 
 
 
 
 
 
 
2e91995
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

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')"
        }
        ```
        """