Skip to content

Commit

Permalink
Documentation update #16
Browse files Browse the repository at this point in the history
  • Loading branch information
marcominerva committed Oct 17, 2023
1 parent c0b0dfa commit f8eb421
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ You need to set the required values in the [appsettings.json](https://github.com

For more information about how to configure the ChatGPT integration, refer to the documentation of [ChatGptNet](https://github.com/marcominerva/ChatGptNet).

> **Note**
If possible, use GPT-4 models. Current experiments demonstrates that they are more accurate than GPT-3 models when generating queries.

### Configuration

The system works by using an OpenAI model to generate a SQL query from a natural language question, reading the list of the available tables with their structure. If table names and columns are well defined, the library should be able to automatically determine what tables to use and how to join them. For example:
Expand Down Expand Up @@ -72,7 +75,7 @@ Giving this schema, the model will be able to infer the following information, f
- The `SupplierId` column in the `Products` table is a foreign key to the `Id` column in the `Suppliers` table.
- The `CategoryId` column in the `Products` table is a foreign key to the `Id` column in the `Categories` table.

If in the schema there are tables and columns and you never want to be used, you can exclude these tables and columns from the query generation process by adding them to the `ExcludedTables` and `ExcludedColumns` arrays in the [appsettings.json](https://github.com/marcominerva/DatabaseGPT/blob/master/src/DatabaseGptConsole/appsettings.json) file. For example:
If in the schema there are tables and columns and you never want to be used, you can exclude them from the query generation process by adding them to the `ExcludedTables` and `ExcludedColumns` arrays in the [appsettings.json](https://github.com/marcominerva/DatabaseGPT/blob/master/src/DatabaseGptConsole/appsettings.json#L17-L18) file. For example:

```
"DatabaseSettings": {
Expand All @@ -81,6 +84,14 @@ If in the schema there are tables and columns and you never want to be used, you
}
```

On the other hand, if you want to use only a particular set of tables, you can add them to the `IncludedTables` array in the [appsettings.json](https://github.com/marcominerva/DatabaseGPT/blob/master/src/DatabaseGptConsole/appsettings.json#L16) file. For example:

```json
"DatabaseSettings": {
"IncludedTables": [ "Production.Product", "Sales.SalesOrderHeader" "Sales.SalesOrderDetail" ]
}
```

In some cases, some columns might contains values that have a particular meaning. For example:

```sql
Expand All @@ -102,6 +113,18 @@ In this case, the `Status` column contains an integer value that represents the

You can add as many indications as you need. The library will use this information to generate the query.

#### Retry strategy

As we know, GPT models are not perfect. Sometimes, the generated query is not valid. In this case, the library will retry to generate the query, using a different approach. The number of retries is configured in the [appsettings.json](https://github.com/marcominerva/DatabaseGPT/blob/master/src/DatabaseGptConsole/appsettings.json#L19) file:

```json
"DatabaseSettings": {
"MaxRetries": 3
}
```

The retry strategy is handled using [Polly](https://github.com/App-vNext/Polly).

## Contribute

The project is constantly evolving. Contributions are welcome. Feel free to file issues and pull requests on the repo and we'll address them as we can.

0 comments on commit f8eb421

Please sign in to comment.