;; "view_buffer"
)
)
+
+(gptel-make-tool
+ :name "db_execute"
+ :function (lambda (query)
+ (let ((output-buffer (generate-new-buffer "*query-output*")))
+ (call-process-region query nil "psql" nil output-buffer t "llm")
+ ;; (message "Schema update output: %s" (with-current-buffer output-buffer (buffer-string)))
+ (with-current-buffer output-buffer (buffer-string))
+ ))
+ :description "Run the given query in the sample PostgreSQL database. It can be DML (select, update) or DDL (e.g. create table, alter index)"
+ :confirm nil
+ :args (list '(:name "query"
+ :type string
+ :description "The query to run"
+ )
+ )
+ :category "database")
+
+(gptel-make-tool
+ :name "db_get_schema"
+ :function (lambda ()
+ (let ((output-buffer (generate-new-buffer "*query-output*")))
+ (call-process-region "" nil "pg_dump" nil output-buffer t "llm")
+ ;; (message "Get schema output: %s" (with-current-buffer output-buffer (buffer-string)))
+ (with-current-buffer output-buffer (buffer-string))
+ ))
+ :description "Dump the schema of the sample PostgreSQL database"
+ :confirm nil
+ :args nil
+ :category "database")