AutoGPT
AutoGPT copied to clipboard
perform sql query on PostgresSql database
Background
I wanted to allow autogpt to browse database and perfom sql queries to research from a database.
Changes
Add 4 commands to allow autogpt to execute sql queries on PostgresSql databases. The databases config are listed in a very basic config file config/external_db_config.py.
- available_databases : return all available databases with description.
- sql_query : takes in a sql query as a string and returns a string response from a PostgresSql database.
- database_table_names : return a string containing all table name of database_name.
- database_table_column_names : return column table names according to table name
Documentation
Tried to respect the code style of this project. It's certainly still not perfect.
Test Plan
Using a sample database that contains a list of French town names, i was able to make autogpt :
- look for available database
- analyze the database structure with the database_table_names and database_table_column_names commands
- generate adequate select query and save the data to a file
ai_settings.yaml example :
ai_goals:
- Find a database that list the french towns name using external databases
- Use the french town database to find french town name limit to 25 result
- Save acquired town names to file
- Find population of every town on google
- Write report
ai_name: Database browser
ai_role: an AI designed to browse database to find french
town name and browse the internet to find their population number
Example of result : https://pastebin.com/wjauQC00
PR Quality Checklist
- [x] My pull request is atomic and focuses on a single change.
- [x] I have thoroughly tested my changes with multiple different prompts.
- [x] I have considered potential risks and mitigations for my changes.
- [ ] I have documented my changes clearly and comprehensively.
- [x] I have not snuck in any "extra" small tweaks changes
This pull request is far from ready to be merged but i wanted to know if addition like this are wanted ?
If we're being very pedantic, the specifying of the package versions of the packages already existing in the requirements.txt file should be done in a separate PR according to the last point in the checklist. Not sure if that's a problem or not.
will redo this correctly