-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #206 from AdaptiveScale/release-2.2.0
Release 2.2.0
- Loading branch information
Showing
17 changed files
with
598 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -653,6 +653,66 @@ Parameter | Description | |
--pyspark | Generates the Spark SQL file. | ||
--scala | Generates the Scala SQL file. | ||
|
||
#### query | ||
The query command allows you to use natural language commands to query your databases, transforming these commands into SQL SELECT statements. By leveraging the capabilities of AI and LLMs, specifically OpenAI models, it interprets user queries and generates the corresponding SQL queries. For effective use of this command, users need to provide their OpenAI API Key and specify the OpenAI model to be utilized. The output will be written to a CSV file. The max number of rows that will be returned is 200. You can overwrite this value, or remove completely the limit.The default openai model that is used is gpt-3.5-turbo. | ||
|
||
rosetta [-c, --config CONFIG_FILE] query [-h, --help] [-s, --source CONNECTION_NAME] [-q, --query "Natural language QUERY"] | ||
|
||
Parameter | Description | ||
--- | --- | ||
-h, --help | Show the help message and exit. | ||
-c, --config CONFIG_FILE | YAML config file. If none is supplied it will use main.conf in the current directory if it exists. | ||
-s, --source CONNECTION_NAME | The source connection is used to specify which models and connection to use. | ||
-q --query "Natural language QUERY" | pecifies the natural language query to be transformed into an SQL SELECT statement. | ||
-l --limit Response Row limit (Optional) | Limits the number of rows in the generated CSV file. If not specified, the default limit is set to 200 rows. | ||
--no-limit (Optional) | Specifies that there should be no limit on the number of rows in the generated CSV file. | ||
|
||
|
||
**Example** (Setting the key and model) : | ||
|
||
(Config file) | ||
``` | ||
openai_api_key: "sk-abcdefghijklmno1234567890" | ||
openai_model: "gpt-4" | ||
connections: | ||
- name: mysql | ||
databaseName: sakila | ||
schemaName: | ||
dbType: mysql | ||
url: jdbc:mysql://root:sakila@localhost:3306/sakila | ||
userName: root | ||
password: sakila | ||
- name: pg | ||
databaseName: postgres | ||
schemaName: public | ||
dbType: postgres | ||
url: jdbc:postgresql://localhost:5432/postgres?user=postgres&password=sakila | ||
userName: postgres | ||
password: sakila | ||
``` | ||
***Example*** (Query) | ||
``` | ||
rosetta query -s mysql -q "Show me the top 10 customers by revenue." | ||
``` | ||
***CSV Output Example*** | ||
```CSV | ||
customer_name,total_revenue,location,email | ||
John Doe,50000,New York,[email protected] | ||
Jane Smith,45000,Los Angeles,[email protected] | ||
David Johnson,40000,Chicago,[email protected] | ||
Emily Brown,35000,San Francisco,[email protected] | ||
Michael Lee,30000,Miami,[email protected] | ||
Sarah Taylor,25000,Seattle,[email protected] | ||
Robert Clark,20000,Boston,[email protected] | ||
Lisa Martinez,15000,Denver,[email protected] | ||
Christopher Anderson,10000,Austin,[email protected] | ||
Amanda Wilson,5000,Atlanta,[email protected] | ||
``` | ||
**Note:** When giving a request that will not generate a SELECT statement the query will be generated but will not be executed rather be given to the user to execute on their own. | ||
|
||
|
||
|
||
### Safety Operation | ||
In `model.yaml` you can find the attribute `safeMode` which is by default disabled (false). If you want to prevent any DROP operation during | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
plugins { | ||
id 'java' | ||
} | ||
|
||
group = 'com.adaptivescale' | ||
version = '2.1.3' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation project(':common') | ||
implementation project(':source') | ||
|
||
testImplementation platform('org.junit:junit-bom:5.9.1') | ||
testImplementation 'org.junit.jupiter:junit-jupiter' | ||
|
||
implementation 'dev.langchain4j:langchain4j-open-ai:0.25.0' | ||
implementation 'com.google.code.gson:gson:2.10.1' | ||
implementation 'com.github.jsqlparser:jsqlparser:4.9' | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} |
38 changes: 38 additions & 0 deletions
38
queryhelper/src/main/java/queryhelper/pojo/GenericResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package queryhelper.pojo; | ||
|
||
public class GenericResponse { | ||
private Object data; | ||
private String message; | ||
private Integer statusCode; | ||
|
||
public GenericResponse() { | ||
this.data = null; | ||
this.message = null; | ||
this.statusCode = null; | ||
} | ||
|
||
public Object getData() { | ||
return data; | ||
} | ||
|
||
public void setData(Object data) { | ||
this.data = data; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
|
||
public Integer getStatusCode() { | ||
return statusCode; | ||
} | ||
|
||
public void setStatusCode(Integer statusCode) { | ||
this.statusCode = statusCode; | ||
} | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
queryhelper/src/main/java/queryhelper/pojo/OpenAIHttpExceptionErrorResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package queryhelper.pojo; | ||
|
||
public class OpenAIHttpExceptionErrorResponse { | ||
private ErrorDetails error; | ||
|
||
public OpenAIHttpExceptionErrorResponse() { | ||
this.error = null; | ||
} | ||
|
||
public ErrorDetails getError() { | ||
return error; | ||
} | ||
|
||
public void setError(ErrorDetails error) { | ||
this.error = error; | ||
} | ||
|
||
public static class ErrorDetails { | ||
private String message; | ||
private String type; | ||
private String param; | ||
private String code; | ||
|
||
public ErrorDetails() { | ||
this.message = null; | ||
this.type = null; | ||
this.param = null; | ||
this.code = null; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
public String getParam() { | ||
return param; | ||
} | ||
|
||
public void setParam(String param) { | ||
this.param = param; | ||
} | ||
|
||
public String getCode() { | ||
return code; | ||
} | ||
|
||
public void setCode(String code) { | ||
this.code = code; | ||
} | ||
} | ||
} |
Oops, something went wrong.