You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.6 KiB

11 months ago
  1. module.exports.SqlAgentListDatabase = {
  2. name: "sql-list-databases",
  3. plugin: function () {
  4. const { listSQLConnections } = require("./SQLConnectors");
  5. return {
  6. name: "sql-list-databases",
  7. setup(aibitat) {
  8. aibitat.function({
  9. super: aibitat,
  10. name: this.name,
  11. description:
  12. "List all available databases via `list_databases` you currently have access to. Returns a unique string identifier `database_id` that can be used for future calls.",
  13. examples: [
  14. {
  15. prompt: "What databases can you access?",
  16. call: JSON.stringify({}),
  17. },
  18. {
  19. prompt: "What databases can you tell me about?",
  20. call: JSON.stringify({}),
  21. },
  22. {
  23. prompt: "Is there a database named erp-logs you can access?",
  24. call: JSON.stringify({}),
  25. },
  26. ],
  27. parameters: {
  28. $schema: "http://json-schema.org/draft-07/schema#",
  29. type: "object",
  30. properties: {},
  31. additionalProperties: false,
  32. },
  33. handler: async function () {
  34. this.super.handlerProps.log(`Using the sql-list-databases tool.`);
  35. this.super.introspect(
  36. `${this.caller}: Checking what are the available databases.`
  37. );
  38. const connections = (await listSQLConnections()).map((conn) => {
  39. const { connectionString, ...rest } = conn;
  40. return rest;
  41. });
  42. return JSON.stringify(connections);
  43. },
  44. });
  45. },
  46. };
  47. },
  48. };