Spaces:
Running
Running
Update app/tools.py
Browse files- app/tools.py +12 -3
app/tools.py
CHANGED
|
@@ -27,6 +27,7 @@ from typing import Any, Dict, Optional
|
|
| 27 |
|
| 28 |
from . import config # reads app/.pyfun — single source of truth
|
| 29 |
from . import providers # LLM + Search execution + fallback chain
|
|
|
|
| 30 |
|
| 31 |
logger = logging.getLogger("tools")
|
| 32 |
|
|
@@ -115,9 +116,17 @@ async def run(
|
|
| 115 |
|
| 116 |
# --- DB tools (read-only, delegated to db_sync when ready) ---
|
| 117 |
if provider_type == "db":
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
# --- Unknown provider type ---
|
| 123 |
logger.warning(f"Tool '{tool_name}' has unknown provider_type '{provider_type}' — skipped.")
|
|
|
|
| 27 |
|
| 28 |
from . import config # reads app/.pyfun — single source of truth
|
| 29 |
from . import providers # LLM + Search execution + fallback chain
|
| 30 |
+
from . import db_sync
|
| 31 |
|
| 32 |
logger = logging.getLogger("tools")
|
| 33 |
|
|
|
|
| 116 |
|
| 117 |
# --- DB tools (read-only, delegated to db_sync when ready) ---
|
| 118 |
if provider_type == "db":
|
| 119 |
+
sql = prompt # prompt ist hier die SQL-Query
|
| 120 |
+
return await db_sync.query(sql)
|
| 121 |
+
|
| 122 |
+
# in run() — neuer persist-Block:
|
| 123 |
+
if provider_type == "persist":
|
| 124 |
+
# hub_state lesen + an PSQL schicken via db_sync bridge
|
| 125 |
+
key = tool_cfg.get("state_read_key", "")
|
| 126 |
+
table = tool_cfg.get("target_table", "hub_results")
|
| 127 |
+
data = await db_sync.read(key) if key else {"prompt": prompt}
|
| 128 |
+
await db_sync.persist(table, data)
|
| 129 |
+
return f"Persisted to PostgreSQL table '{table}'."
|
| 130 |
|
| 131 |
# --- Unknown provider type ---
|
| 132 |
logger.warning(f"Tool '{tool_name}' has unknown provider_type '{provider_type}' — skipped.")
|