diff --git a/qcms-manifest.json b/qcms-manifest.json index 9af8f6d..32fdd22 100644 --- a/qcms-manifest.json +++ b/qcms-manifest.json @@ -14,7 +14,7 @@ "llm": "/home/steve/dev/data/qcms/azure-openai.json", "catalogs":{ "duckdb":{"sql":"SELECT table_name, TO_JSON(ARRAY_AGG(column_name)) as columns FROM INFORMATION_SCHEMA.COLUMNS GROUP BY table_name"}, - "bigquery":{"sql":"SELECT table_name, column_name, data_type FROM :dataset.R2024Q3R4.INFORMATION_SCHEMA.COLUMNS WHERE REGEXP_CONTAINS(table_name,'^(cb_|_.+|.*_map.*)$') IS FALSE AND REGEXP_CONTAINS(column_name ,'^.*(_id|_value|_code)$') ORDER BY table_name","args":["dataset"]}, + "bigquery":{"sql":"SELECT table_name, column_name, data_type FROM :dataset.INFORMATION_SCHEMA.COLUMNS WHERE REGEXP_CONTAINS(table_name,'^(cb_|_.+|.*_map.*)$') IS FALSE AND REGEXP_CONTAINS(column_name ,'^.*(_id|_value|_code)$') ORDER BY table_name","args":["dataset"]}, "postgresql":{"sql":"select table_name, column_name,data_type from information_schema.columns where table_schema = 'public' order by table_name"}, "sqlite":{"sql":"select tbl_name as table_name, json_group_array(y.name) as columns from sqlite_master x INNER JOIN PRAGMA_TABLE_INFO(tbl_name) y group by table_name'}"} } diff --git a/www/html/_plugins/agent.py b/www/html/_plugins/agent.py index 131b850..9f8f20b 100644 --- a/www/html/_plugins/agent.py +++ b/www/html/_plugins/agent.py @@ -127,15 +127,16 @@ def AIProxy (_label,_query,_path,_CATALOG) : _kwargs = json.loads((open(_path)).read()) _agent = Agent(**_kwargs) _qcat = _CATALOG[_provider] - # if 'args' in _CATALOG[_provider] : - # _entry = transport.registry.get(_label) - # for _var in _CATALOG[_provider]['args'] : - # if _var in _entry: - # _value = _entry[_var] - # _about = f'{_about}\n{_var} = {_value}' - # _qcat['sql'] = _qcat['sql'].replace(f':{_var}',_value) + if 'args' in _CATALOG[_provider] : + _entry = transport.registry.get(_label) + for _var in _CATALOG[_provider]['args'] : + if _var in _entry: + _value = _entry[_var] + _about = f'{_about}\n{_var} = {_value}' + _qcat['sql'] = _qcat['sql'].replace(f':{_var}',_value) - + print (_qcat) + print (' ******************** ') _catalog = _qreader.read(**_qcat).to_csv(index=0) _about = f"The queries will run on {_provider} database.\n{_about}" r = _agent.toSQL(_query,_catalog, _about)