ibis-project / ibis-birdbrain

portable Python ML-powered data bot
https://ibis-project.github.io/ibis-birdbrain/
Apache License 2.0
23 stars 4 forks source link

feat: add search text-sql pair in cached table #60

Closed jitingxu1 closed 3 months ago

jitingxu1 commented 3 months ago

Related issue: #46

Search question to check if it is in the cached table.


ADDED

from ibis_birdbrain.bot import Bot
import ibis
ibis.options.interactive = True

con = ibis.duckdb.connect()
t = ibis.read_parquet("m.parquet")
con.create_table("mortgage", t.to_pyarrow())

questions = [
    {
        "question": "how many rows in the table",
        "sql": "select count(*) from mortgage",
        "dialect": "duckdb",
    },
    {
        "question": "top 10 rows in the table",
        "sql": "select * from mortgage limit 10",
        "dialect": "duckdb",
    },
]
cached_table = ibis.memtable(questions)
bot = Bot(con=con, cached_table=cached_table)

bot("top 10 rows in the table")
lostmygithubaccount commented 3 months ago

merging, thanks!