SQLWITH `bfcte_0` AS (\n",
" SELECT\n",
" *\n",
" FROM UNNEST(ARRAY<STRUCT<`bfcol_0` STRING, `bfcol_1` INT64, `bfcol_2` INT64>>[STRUCT(\n",
" 'gs://cloud-samples-data/vertex-ai/dataset-management/datasets/classic-movie-posters/au_secours.jpeg',\n",
" 0,\n",
" 0\n",
" ), STRUCT(\n",
" 'gs://cloud-samples-data/vertex-ai/dataset-management/datasets/classic-movie-posters/barque_sortant_du_port.jpeg',\n",
" 1,\n",
" 1\n",
" ), STRUCT(\n",
" 'gs://cloud-samples-data/vertex-ai/dataset-management/datasets/classic-movie-posters/battling_butler.jpg',\n",
" 2,\n",
" 2\n",
" ), STRUCT(\n",
" 'gs://cloud-samples-data/vertex-ai/dataset-management/datasets/classic-movie-posters/brown_of_harvard.jpeg',\n",
" 3,\n",
" 3\n",
" ), STRUCT(\n",
" 'gs://cloud-samples-data/vertex-ai/dataset-management/datasets/classic-movie-posters/der_student_von_prag.jpg',\n",
" 4,\n",
" 4\n",
" )])\n",
")\n",
"SELECT\n",
" `bfcol_1` AS `bfuid_col_60`,\n",
" TO_JSON_STRING(\n",
" OBJ.GET_ACCESS_URL(OBJ.MAKE_REF(`bfcol_0`, 'bigframes-dev.us.bigframes-default-connection'), 'R')\n",
" ) AS `bfuid_col_66`\n",
"FROM `bfcte_0`\n",
"WHERE\n",
" AI.IF(\n",
" prompt => (\n",
" 'The movie ',\n",
" AI.GENERATE(\n",
" prompt => (\n",
" 'What is the movie title for this poster image?',\n",
" JSON_VALUE(\n",
" OBJ.GET_ACCESS_URL(OBJ.MAKE_REF(`bfcol_0`, 'bigframes-dev.us.bigframes-default-connection'), 'R'),\n",
" '$.access_urls.read_url'\n",
" )\n",
" ),\n",
" request_type => 'UNSPECIFIED'\n",
" ).`result`,\n",
" ' was made in US'\n",
" ),\n",
" optimization_mode => 'MINIMIZE_COST'\n",
" )\n",
"ORDER BY\n",
" `bfcol_2` ASC NULLS LAST\n",
"LIMIT 1\n",
" "
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n",
" Query processed 0 Bytes in 3 minutes of slot time. [Job bigframes-dev:US.job_NBILG5qU14Aitas81nPCCtYM9KdM details]\n",
" "
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n",
" \n",
" \n",
" | \n",
" poster | \n",
" title | \n",
" year | \n",
"
\n",
" \n",
" \n",
" \n",
" | 2 | \n",
" | \n",
" The movie title for the poster image is **Battling Butler**. | \n",
" 1926 | \n",
"
\n",
" \n",
"
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"us_movies = movies[bbq.ai.if_(\n",
" (\"The movie \", movies['title'], \" was made in US\")\n",
")]\n",
"render_images(us_movies.head(1))"
]
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.0"
}
},
"nbformat": 4,
"nbformat_minor": 0
}