Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ai_to_sql transalte natual lanauge to SQL based on your table schema #10637

Merged
merged 5 commits into from Mar 18, 2023

Conversation

BohuTANG
Copy link
Member

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

CREATE DATABASE openai;
USE openai;

CREATE TABLE users(
    id INT,
    name VARCHAR,
    age INT
);

SELECT * FROM ai_to_sql('List all users older than 30 years', '<openai-api-key>');

Output:

*************************** 1. row ***************************
     database: simple_example
generated_sql:  SELECT * FROM users WHERE age > 30;

Closes #issue

@vercel
Copy link

vercel bot commented Mar 18, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated
databend ⬜️ Ignored (Inspect) Visit Preview Mar 18, 2023 at 4:07PM (UTC)

@mergify mergify bot added the pr-feature this PR introduces a new feature to the codebase label Mar 18, 2023
@Xuanwo
Copy link
Member

Xuanwo commented Mar 18, 2023

CI failed becuase async-openai doesn't has rustls support, please use the fork I created: 64bit/async-openai#60

Signed-off-by: Xuanwo <github@xuanwo.io>
@BohuTANG BohuTANG merged commit 0e06b47 into datafuselabs:main Mar 18, 2023
@l1t1
Copy link

l1t1 commented Mar 19, 2023

I tried the function in v1.0.23

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.26-v1.0.23-nightly-0e06b47048d90e53126f785e6db12c67cb592d46(rust-1.70.0-nightly-2023-03-18T16:36:53.222545484Z) 0

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> CREATE DATABASE openai;
Query OK, 0 rows affected (0.079 sec)

MySQL [(none)]> USE openai;
Database changed
MySQL [openai]>
MySQL [openai]> CREATE TABLE users(
    ->     id INT,
    ->     name VARCHAR,
    ->     age INT
    -> );
Query OK, 0 rows affected (0.224 sec)

MySQL [openai]>
MySQL [openai]> SELECT * FROM ai_to_sql('List all users older than 30 years', '<openai-api-key>');
ERROR 1105 (HY000): Code: 1001, displayText = openai http error: reqwest::Error { kind: Builder, source: Custom { kind: NotFound, error: "error reading DNS system conf: No such file or directory (os error 2)" } }.
MySQL [openai]>

@BohuTANG
Copy link
Member Author

@l1t1 Make your network can access openai

@l1t1
Copy link

l1t1 commented Mar 19, 2023

database usually behind the firewall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants