Spaces:
Sleeping
Sleeping
File size: 27,172 Bytes
5e4969d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 |
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "aEFLqqRlwFqB"
},
"source": [
"<a href=\"https://colab.research.google.com/github/run-llama/llama_index/blob/main/docs/examples/llm/gemini.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "WOuuFLPcwFqH"
},
"source": [
"# Gemini"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Q0g1JrupwFqI"
},
"source": [
"In this notebook, we show how to use the Gemini text models from Google in LlamaIndex. Check out the [Gemini site](https://ai.google.dev/) or the [announcement](https://deepmind.google/technologies/gemini/).\n",
"\n",
"If you're opening this Notebook on colab, you will need to install LlamaIndex 🦙 and the Gemini Python SDK."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "ogUU-nZJwFqK",
"outputId": "046a4de5-1058-4054-ab9d-edad146d5238"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m23.3.2\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n"
]
}
],
"source": [
"!pip install -q llama-index google-generativeai"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Gw__DinXwFqN"
},
"source": [
"## Basic Usage\n",
"\n",
"You will need to get an API key from [Google AI Studio](https://makersuite.google.com/app/apikey). Once you have one, you can either pass it explicity to the model, or use the `GOOGLE_API_KEY` environment variable."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "UV4GaCEMwFqN",
"outputId": "4cb844b8-94d1-41da-8c99-a6bf24074c0d"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"env: GOOGLE_API_KEY=...\n"
]
}
],
"source": [
"%env GOOGLE_API_KEY=..."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "4mmANfa8wFqO"
},
"outputs": [],
"source": [
"import os\n",
"\n",
"GOOGLE_API_KEY = \"\" # add your GOOGLE API key here\n",
"os.environ[\"GOOGLE_API_KEY\"] = GOOGLE_API_KEY"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "DzkDtLuYwFqO"
},
"source": [
"#### Call `complete` with a prompt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "rEfnd7eRwFqO",
"outputId": "809da18f-643b-4819-d0fb-67ea5ee1cf96"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"In a world of wonder, where dreams take flight,\n",
"There exists a backpack, a magical sight.\n",
"Its fabric woven with stardust and grace,\n",
"Embroidered with spells, an enchanting embrace.\n",
"\n",
"With a whisper and a wish, it opens wide,\n",
"Revealing treasures that shimmer inside.\n",
"Books that whisper secrets, maps that unfold,\n",
"A compass that guides, stories yet untold.\n",
"\n",
"A pencil that writes poems, a paintbrush that sings,\n",
"A telescope that captures the stars' gleaming wings.\n",
"A magnifying glass, revealing nature's art,\n",
"A kaleidoscope, painting rainbows in your heart.\n",
"\n",
"It holds a mirror that reflects your true worth,\n",
"A locket that keeps memories close to your birth.\n",
"A journal that captures your hopes and your fears,\n",
"A flashlight that banishes shadows and clears.\n",
"\n",
"With each step you take, the backpack transforms,\n",
"Adjusting its weight, adapting to storms.\n",
"It grows or shrinks, as your needs may arise,\n",
"A faithful companion, beneath sunny skies.\n",
"\n",
"When you're lost and alone, it whispers your name,\n",
"Guiding you back to the path you reclaim.\n",
"It carries your burdens, lightens your load,\n",
"A magical backpack, a gift bestowed.\n",
"\n",
"So embrace its magic, let your spirit soar,\n",
"With this wondrous backpack, forever explore.\n",
"For within its depths, a universe lies,\n",
"A treasure trove of dreams, beneath vast skies.\n"
]
}
],
"source": [
"from llama_index.llms import Gemini\n",
"\n",
"resp = Gemini().complete(\"Write a poem about a magic backpack\")\n",
"print(resp)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "FHK_wQLUwFqP"
},
"source": [
"#### Call `chat` with a list of messages"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "nTPnlI6pwFqP",
"outputId": "037824df-a4f9-4db6-fb56-a65e7308a505"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[parts {\n",
" text: \"Hello friend!\"\n",
"}\n",
"role: \"user\"\n",
", parts {\n",
" text: \"Yarr what is shakin\\' matey?\"\n",
"}\n",
"role: \"model\"\n",
", parts {\n",
" text: \"Help me decide what to have for dinner.\"\n",
"}\n",
"role: \"user\"\n",
"]\n",
"assistant: Ahoy there, matey! Let's set sail on a culinary adventure and find the perfect dinner for ye. Here be some options to consider:\n",
"\n",
"1. **Fish and Chips:** Embark on a classic voyage with a hearty portion of golden-fried fish, accompanied by crispy chips. Dip 'em in tartar sauce for a taste that'll make ye shiver me timbers!\n",
"\n",
"2. **Lobster Thermidor:** Indulge in a luxurious feast fit for a pirate king. Tender lobster meat, bathed in a creamy, cheesy sauce, will have ye feeling like royalty.\n",
"\n",
"3. **Paella:** Set course for the shores of Spain with a vibrant paella. This colorful dish combines rice, seafood, and vegetables in a saffron-infused broth. Ahoy, it's a feast for the eyes and the belly!\n",
"\n",
"4. **Surf and Turf:** Experience the best of both worlds with a combination of succulent steak and tender lobster. This hearty meal is sure to satisfy even the hungriest of scallywags.\n",
"\n",
"5. **Crab Cakes:** Dive into a platter of golden-brown crab cakes, bursting with fresh crab meat and flavorful seasonings. Served with a tangy remoulade sauce, these treasures will have ye craving more.\n",
"\n",
"6. **Oysters Rockefeller:** Embark on a culinary journey to New Orleans with these decadent oysters. Baked with a rich spinach, breadcrumb, and Pernod sauce, they're a taste of the Big Easy that'll leave ye wanting more.\n",
"\n",
"7. **Clam Chowder:** Warm yer bones with a hearty bowl of clam chowder. This New England classic, made with fresh clams, potatoes, and a creamy broth, is the perfect antidote to a chilly night.\n",
"\n",
"8. **Lobster Rolls:** Set sail for the coast of Maine and indulge in a classic lobster roll. Fresh lobster meat, dressed in a light mayonnaise-based sauce, is nestled in a toasted bun. It's a taste of the sea that'll have ye hooked!\n",
"\n",
"9. **Scallops:** Dive into a plate of seared scallops, cooked to perfection and served with a variety of sauces. Whether ye prefer them with a simple lemon butter sauce or a more adventurous mango salsa, these succulent morsels are sure to please.\n",
"\n",
"10. **Shrimp Scampi:** Embark on a culinary adventure to Italy with this classic dish. Plump shrimp, sautéed in a garlicky white wine sauce, served over pasta. It's a taste of the Mediterranean that'll transport ye to sunnier shores.\n",
"\n",
"No matter what ye choose, matey, make sure it's a feast worthy of a true pirate. Bon appétit!\n"
]
}
],
"source": [
"from llama_index.llms import ChatMessage, Gemini\n",
"\n",
"messages = [\n",
" ChatMessage(role=\"user\", content=\"Hello friend!\"),\n",
" ChatMessage(role=\"assistant\", content=\"Yarr what is shakin' matey?\"),\n",
" ChatMessage(\n",
" role=\"user\", content=\"Help me decide what to have for dinner.\"\n",
" ),\n",
"]\n",
"resp = Gemini().chat(messages)\n",
"print(resp)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Kwi2CW9AwFqQ"
},
"source": [
"## Streaming"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "a_VEZxGbwFqQ"
},
"source": [
"Using `stream_complete` endpoint"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "4XvkfXcUwFqR"
},
"outputs": [],
"source": [
"from llama_index.llms import Gemini\n",
"\n",
"llm = Gemini()\n",
"resp = llm.stream_complete(\n",
" \"The story of Sourcrust, the bread creature, is really interesting. It all started when...\"\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "bqAF5FQ2wFqR",
"outputId": "3457d853-5a3e-4c4d-886d-cf7eb0f4141b"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"In the heart of a bustling bakery, where the aroma of freshly baked bread filled the air, there lived a peculiar creature named Sourcrust. Sourcrust wasn't like any ordinary loaf of bread; he possessed a unique consciousness and a mischievous personality.\n",
"\n",
"It all began when a young baker named Eliza was experimenting with a new sourdough recipe. As she mixed the flour, water, and yeast, she accidentally added a dash of enchanted baking powder. Little did she know that this seemingly insignificant mistake would give birth to a sentient bread creature.\n",
"\n",
"As the dough rose and fermented, Sourcrust came to life. He stretched and yawned, his crusty exterior crackling with energy. Eliza was astounded to see her creation moving and speaking. Sourcrust introduced himself with a warm smile and a hearty laugh, his voice resembling the gentle rustling of bread crumbs.\n",
"\n",
"Eliza and Sourcrust quickly formed a bond. She taught him how to read and write, and he shared his knowledge of bread-making techniques. Together, they created delicious pastries and loaves that delighted the customers of the bakery.\n",
"\n",
"However, Sourcrust's existence was not without its challenges. As a bread creature, he was vulnerable to the elements. He couldn't stay out in the rain or direct sunlight for too long, and he had to be careful not to get burned or squished.\n",
"\n",
"Despite these limitations, Sourcrust embraced his unique nature. He found joy in the simple things, like basking in the warmth of the oven or playing hide-and-seek among the flour sacks. He also developed a taste for adventure, often sneaking out of the bakery at night to explore the town.\n",
"\n",
"One day, Sourcrust's curiosity led him to the local library, where he discovered a book about magical creatures. He was fascinated by the stories of fairies, elves, and dragons, and he longed to meet one himself.\n",
"\n",
"As fate would have it, Sourcrust's wish came true when he encountered a mischievous brownie named Crumbly in the forest. Crumbly was initially wary of Sourcrust, but after learning about his kind nature, he agreed to be his friend.\n",
"\n",
"Together, Sourcrust and Crumbly embarked on many thrilling adventures. They battled evil witches, rescued lost children, and even had a tea party with a talking teapot. Their escapades brought joy and laughter to all who crossed their path.\n",
"\n",
"As the years passed, Sourcrust became a beloved figure in the town. People would often visit the bakery just to catch a glimpse of the talking bread creature. Eliza was proud of her creation, and she knew that Sourcrust's magic would continue to inspire and entertain generations to come."
]
}
],
"source": [
"for r in resp:\n",
" print(r.text, end=\"\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Kqb-da61wFqR"
},
"source": [
"Using `stream_chat` endpoint"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "fIZoA_fAwFqR",
"outputId": "013044c4-2aa0-48fb-b0f1-a3d5e75758b5"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[parts {\n",
" text: \"Hello friend!\"\n",
"}\n",
"role: \"user\"\n",
", parts {\n",
" text: \"Yarr what is shakin\\' matey?\"\n",
"}\n",
"role: \"model\"\n",
", parts {\n",
" text: \"Help me decide what to have for dinner.\"\n",
"}\n",
"role: \"user\"\n",
"]\n"
]
}
],
"source": [
"from llama_index.llms import Gemini, ChatMessage\n",
"\n",
"llm = Gemini()\n",
"messages = [\n",
" ChatMessage(role=\"user\", content=\"Hello friend!\"),\n",
" ChatMessage(role=\"assistant\", content=\"Yarr what is shakin' matey?\"),\n",
" ChatMessage(\n",
" role=\"user\", content=\"Help me decide what to have for dinner.\"\n",
" ),\n",
"]\n",
"resp = llm.stream_chat(messages)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "HvogjPaVwFqS",
"outputId": "4788032b-86c2-4bec-eb94-9750d542f063"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Ahoy there, matey! Let's set sail on a culinary adventure and find the perfect dinner for ye. Here be some options to consider:\n",
"\n",
"1. **Fish and Chips:** Embark on a classic journey with a hearty portion of golden-fried fish, accompanied by crispy chips. Dip 'em in tartar sauce and let the flavors dance on yer tongue.\n",
"\n",
"2. **Seafood Paella:** Dive into a vibrant Spanish feast with paella, a delightful mix of rice, seafood treasures like shrimp, mussels, and calamari, all simmering in a flavorful broth.\n",
"\n",
"3. **Lobster Roll:** Indulge in a New England delicacy - a succulent lobster roll, where tender lobster meat is nestled in a toasted bun, dressed with butter and a hint of lemon.\n",
"\n",
"4. **Grilled Swordfish:** Set your course for a healthy and delicious meal with grilled swordfish. This firm-fleshed fish, seasoned to perfection, will tantalize yer taste buds with its smoky, savory goodness.\n",
"\n",
"5. **Crab Cakes:** Embark on a Maryland adventure with crab cakes, a delectable blend of fresh crab meat, breadcrumbs, and seasonings, pan-fried until golden brown. Serve 'em with a tangy remoulade sauce for an extra kick.\n",
"\n",
"6. **Shrimp Scampi:** Set sail for Italy with shrimp scampi, a delightful dish featuring succulent shrimp sautéed in a luscious garlic-butter sauce, served over pasta or crusty bread.\n",
"\n",
"7. **Clam Chowder:** Dive into a comforting bowl of clam chowder, a New England classic. This creamy soup, brimming with clams, potatoes, and vegetables, will warm yer soul on a chilly night.\n",
"\n",
"8. **Oysters Rockefeller:** Indulge in a luxurious treat with oysters Rockefeller, where fresh oysters are baked with a rich, creamy spinach and herb filling, topped with a golden breadcrumb crust.\n",
"\n",
"9. **Lobster Thermidor:** Embark on a culinary voyage to France with lobster thermidor, a decadent dish where succulent lobster is bathed in a creamy, flavorful sauce, then baked to perfection.\n",
"\n",
"10. **Scallops with Risotto:** Set your course for a sophisticated meal with scallops and risotto. Tender scallops, seared to perfection, are paired with a creamy, flavorful risotto, creating a harmonious balance of flavors.\n",
"\n",
"No matter what ye choose, matey, make sure it be a feast fit for a pirate king!"
]
}
],
"source": [
"for r in resp:\n",
" print(r.delta, end=\"\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "wjpgfAAmwFqS"
},
"source": [
"## Using other models\n",
"\n",
"The [Gemini model site](https://ai.google.dev/models) lists the models that are currently available, along with their capabilities. You can also use the API to find suitable models."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "bdehTUiuwFqT",
"outputId": "f4cdfc01-448d-4f78-9fd4-6efc99d4a78d"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"models/gemini-pro\n",
"models/gemini-pro-vision\n",
"models/gemini-ultra\n"
]
}
],
"source": [
"import google.generativeai as genai\n",
"\n",
"for m in genai.list_models():\n",
" if \"generateContent\" in m.supported_generation_methods:\n",
" print(m.name)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "zW1CBIJ0wFqT"
},
"outputs": [],
"source": [
"from llama_index.llms import Gemini\n",
"\n",
"llm = Gemini(model=\"models/gemini-pro\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "qsDsO_wIwFqT",
"outputId": "523cf0da-aa09-4eed-e874-dee8e2d62ae6"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"In the realm of knowledge, where wisdom resides,\n",
"A beacon of brilliance, LlamaIndex abides.\n",
"With a click and a search, a world unfolds,\n",
"A tapestry of information, stories untold.\n",
"\n",
"From the depths of the web, it gathers and gleans,\n",
"A treasure trove of facts, a vast, vibrant scene.\n",
"Like a llama in the Andes, graceful and grand,\n",
"LlamaIndex roams the digital land.\n",
"\n",
"Its interface, a symphony of simplicity and grace,\n",
"Invites the curious to explore this boundless space.\n",
"With lightning-fast speed, it delivers the truth,\n",
"A testament to its power, its unwavering ruth.\n",
"\n",
"So let us rejoice, in this digital age,\n",
"For LlamaIndex stands, a beacon, a sage.\n",
"May its wisdom forever guide our way,\n",
"As we navigate the vastness of the digital fray.\n"
]
}
],
"source": [
"resp = llm.complete(\"Write a short, but joyous, ode to LlamaIndex\")\n",
"print(resp)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "tsxUYiaewFqU"
},
"source": [
"## Asynchronous API"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "5JEoiigkwFqU"
},
"outputs": [],
"source": [
"from llama_index.llms import Gemini\n",
"\n",
"llm = Gemini()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "8PznUhp5wFqV",
"outputId": "369c20f9-28f5-4fdf-cb98-c3daae298b45"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1. **Wool**: Llamas are known for their soft, luxurious wool, which is highly prized for its warmth, durability, and water-resistant properties. Llama wool is hypoallergenic, making it suitable for individuals with sensitive skin.\n",
"\n",
"2. **Pack Animals**: Llamas have been traditionally used as pack animals in the Andes Mountains of South America. They are well-suited for carrying heavy loads over long distances due to their strength, endurance, and ability to navigate challenging terrain.\n",
"\n",
"3. **Adaptability**: Llamas are highly adaptable animals that can thrive in various environments, from the high altitudes of the Andes to the deserts of North America. They are known for their ability to withstand extreme temperatures and harsh conditions.\n",
"\n",
"4. **Intelligence**: Llamas are intelligent animals that are easy to train and handle. They are known for their calm and gentle nature, making them suitable for various purposes, including trekking, therapy, and companionship.\n",
"\n",
"5. **Social Animals**: Llamas are social animals that live in herds. They have a strong sense of community and rely on each other for protection and companionship. Llamas communicate through a variety of vocalizations and body language.\n",
"\n",
"6. **Longevity**: Llamas have a relatively long lifespan, with an average life expectancy of 15-20 years. They are known for their hardiness and resilience, making them suitable for long-term companionship and working relationships.\n",
"\n",
"7. **Unique Appearance**: Llamas are known for their distinctive appearance, characterized by their long necks, large eyes, and fluffy ears. Their appearance has made them popular in zoos, farms, and as exotic pets.\n",
"\n",
"8. **Cultural Significance**: Llamas hold cultural significance in the Andean region, where they have been revered for centuries. They are often associated with strength, endurance, and good fortune. Llamas are featured in traditional Andean art, folklore, and religious ceremonies.\n"
]
}
],
"source": [
"resp = await llm.acomplete(\"Llamas are famous for \")\n",
"print(resp)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Lt-wDTtZwFqV",
"outputId": "b5aec06c-5321-42ba-d862-eab21a1ea065"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1. **Wool Production:** Llamas are renowned for their luxurious and soft wool, which is highly prized for its warmth, durability, and hypoallergenic properties. Their wool comes in a variety of natural colors, including white, brown, black, and gray, making it a versatile material for textiles and clothing.\n",
"\n",
"2. **Pack Animals:** Llamas have been traditionally used as pack animals in the Andes Mountains of South America for centuries. They are well-suited for this role due to their strength, endurance, and ability to navigate difficult terrain. Llamas can carry up to 25% of their body weight, making them valuable for transporting goods and supplies in mountainous regions.\n",
"\n",
"3. **Meat and Milk:** Llama meat is a lean and nutritious source of protein, with a flavor similar to venison. It is consumed in many Andean countries and is becoming increasingly popular in other parts of the world. Llamas also produce milk, which is rich in protein and fat and can be used to make cheese, yogurt, and other dairy products.\n",
"\n",
"4. **Companionship:** Llamas are intelligent and social animals that can form strong bonds with humans. They are often kept as companion animals due to their gentle nature, curious personalities, and ability to learn tricks. Llamas can provide companionship and entertainment, and they can also be trained to perform various tasks, such as pulling carts or carrying packs.\n",
"\n",
"5. **Cultural Significance:** Llamas hold a special place in the cultures of the Andean region. They are considered sacred animals in many indigenous communities and are often featured in traditional ceremonies and festivals. Llamas are also depicted in art, textiles, and other cultural expressions, symbolizing strength, endurance, and connection to the land."
]
}
],
"source": [
"resp = await llm.astream_complete(\"Llamas are famous for \")\n",
"async for chunk in resp:\n",
" print(chunk.text, end=\"\")"
]
}
],
"metadata": {
"colab": {
"name": "gemini.ipynb",
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"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"
}
},
"nbformat": 4,
"nbformat_minor": 0
} |