DatabaseTools
Wisej.AI.Tools.DatabaseTools
Last updated
Wisej.AI.Tools.DatabaseTools
Last updated
Namespace: Wisej.AI.Tools
Assembly: Wisej.AI (3.5.0.0)
Represents a set of tools for interacting with a database, including schema initialization and SQL execution.
This class provides functionalities to manage database connections, retrieve schema information, and execute SQL queries. It utilizes the to truncate the generated context to fit within the value. By overriding the virtual properties in this class, you can provide predefined values for connection, schema, columns, and server type. This allows for greater flexibility and customization in how the class is used.
Initializes a new instance of the class with optional parameters.
connection
The database connection to use. Default is null
.
columns
The data table containing column information. Default is null
.
schema
The schema of the database. Default is null
.
serverType
The type of the database server. Default is null
.
You can provide the schema in three ways:
Provide the columns data table, which can be retrieved using connection.GetSchema("Columns")
.
Provide the schema string, formatted in a way that is understandable by the LLM.
If both parameters are null, you can override either the or the properties.
Builds a database schema representation from the provided columns.
columns
The data table containing column information.
If the columns parameter is null, the method returns "Missing columns schema".
Returns the JSON string returned in the message by stripping the enclosing markers (sql and
) if present.
message
Message with the response text that may be a JSON string.
Executes a SQL select query and returns the result as a string.
sql
The SQL query to execute.
Represents a container for tools, providing access to a hub, adapter, and a collection of parameters.
: Gets the data table containing column information. (Default: null
)
: Gets the database connection. (Default: null
)
: Gets or sets the maximum number of context tokens. (Default: 4096
)
: Gets the schema of the database. (Default: null
)
: Gets the type of the database server.
: Gets or sets the tokenizer service used for truncating context tokens.
Returns: . A string representation of the database schema.
Returns: . JSON string.
Returns: . The result of the SQL query as a string.