Skip to content

bigfunctions > ask_ai

ask_ai

Signature

ask_ai(prompt, model)

Description

Ask Anything!

Google Generative AI model will get you an answer.

model must be one of:

  • gemini-pro
  • text-bison@001
  • text-bison@002
  • text-unicorn@001
  • code-bison@001
  • code-bison@002
  • ... any future model
  • null, then gemini-pro will be used

Default parameters are used for each model.

Examples

1. Clean data

select bigfunctions.eu.ask_ai(
  '''
  Question: what is the country from the following user input: 'I live in frace' ?
  Answer: formatted as alpha three code
  '''
  , 'gemini-pro')
select bigfunctions.us.ask_ai(
  '''
  Question: what is the country from the following user input: 'I live in frace' ?
  Answer: formatted as alpha three code
  '''
  , 'gemini-pro')
select bigfunctions.europe_west1.ask_ai(
  '''
  Question: what is the country from the following user input: 'I live in frace' ?
  Answer: formatted as alpha three code
  '''
  , 'gemini-pro')
+--------+
| answer |
+--------+
| FRA    |
+--------+

2. Generate SQL

select bigfunctions.eu.ask_ai(
  '''
  Question: get the 10 products which generated the most revenue in 2023
  Table: sales
  Columns: product_id, price, quantity, timestamp
  Answer: bigquery sql query
  '''
  , 'code-bison@002')
select bigfunctions.us.ask_ai(
  '''
  Question: get the 10 products which generated the most revenue in 2023
  Table: sales
  Columns: product_id, price, quantity, timestamp
  Answer: bigquery sql query
  '''
  , 'code-bison@002')
select bigfunctions.europe_west1.ask_ai(
  '''
  Question: get the 10 products which generated the most revenue in 2023
  Table: sales
  Columns: product_id, price, quantity, timestamp
  Answer: bigquery sql query
  '''
  , 'code-bison@002')
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| answer                                                                                                                                                                   |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| SELECT product_id, SUM(price * quantity) AS revenue
FROM sales
WHERE timestamp BETWEEN '2023-01-01' AND '2023-12-31'
GROUP BY product_id
ORDER BY revenue DESC
LIMIT 10
 |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+