Spaces:
Runtime error
Runtime error
File size: 43,929 Bytes
4a51346 |
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 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 |
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "3853d1cd",
"metadata": {},
"source": [
"### API ν€ λΆλ¬μ€κΈ°"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "968fee23",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import configparser"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "a836b0e7",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['./secrets.ini']"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"config = configparser.ConfigParser()\n",
"config.read('./secrets.ini')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "fef7bec8",
"metadata": {},
"outputs": [],
"source": [
"openai_api_key = config['OPENAI']['OPENAI_API_KEY']\n",
"serper_api_key = config['SERPER']['SERPER_API_KEY']\n",
"serp_api_key = config['SERPAPI']['SERPAPI_API_KEY']\n",
"os.environ.update({'OPENAI_API_KEY': openai_api_key})\n",
"os.environ.update({'SERPER_API_KEY': serper_api_key})\n",
"os.environ.update({'SERPAPI_API_KEY': serp_api_key})"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "c41f820a",
"metadata": {},
"outputs": [],
"source": [
"from typing import List, Union\n",
"import re\n",
"import json\n",
"\n",
"import pandas as pd\n",
"from langchain import SerpAPIWrapper, LLMChain\n",
"from langchain.agents import Tool, AgentType, AgentExecutor, LLMSingleActionAgent, AgentOutputParser\n",
"from langchain.chat_models import ChatOpenAI\n",
"from langchain.chains import LLMChain, SimpleSequentialChain\n",
"from langchain.chains.query_constructor.base import AttributeInfo\n",
"from langchain.document_loaders import DataFrameLoader, SeleniumURLLoader\n",
"from langchain.embeddings import OpenAIEmbeddings\n",
"from langchain.indexes import VectorstoreIndexCreator\n",
"from langchain.prompts import PromptTemplate, StringPromptTemplate, load_prompt, BaseChatPromptTemplate\n",
"from langchain.llms import OpenAI\n",
"from langchain.retrievers.self_query.base import SelfQueryRetriever\n",
"from langchain.schema import AgentAction, AgentFinish, HumanMessage\n",
"from langchain.vectorstores import DocArrayInMemorySearch, Chroma"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "e995c9e3",
"metadata": {},
"source": [
"### Get Stage Analyzer Prompt"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "25c82b0d",
"metadata": {},
"outputs": [],
"source": [
"stage_analyzer_inception_prompt = load_prompt(\"./templates/stage_analyzer_inception_prompt_template.json\")\n",
"llm = ChatOpenAI(model='gpt-3.5-turbo', temperature=0.0)\n",
"stage_analyzer_chain = LLMChain(\n",
" llm=llm,\n",
" prompt=stage_analyzer_inception_prompt, \n",
" verbose=True, \n",
" output_key=\"stage_number\")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "63824ec7",
"metadata": {},
"source": [
"### Load wine database json"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "d1228108",
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_json('./data/unified_wine_data.json', encoding='utf-8', lines=True)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "4c2ca36f",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>url</th>\n",
" <th>site_name</th>\n",
" <th>price</th>\n",
" <th>name</th>\n",
" <th>en_name</th>\n",
" <th>img_url</th>\n",
" <th>body</th>\n",
" <th>acidity</th>\n",
" <th>tannin</th>\n",
" <th>sweetness</th>\n",
" <th>alcohol</th>\n",
" <th>wine_type</th>\n",
" <th>country</th>\n",
" <th>grape</th>\n",
" <th>rating</th>\n",
" <th>pickup_location</th>\n",
" <th>vivino_link</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>https://www.winenara.com/shop/product/product_...</td>\n",
" <td>winenara</td>\n",
" <td>49000</td>\n",
" <td>λͺ¨λ
Έν΄ ν΄λΌμμ½</td>\n",
" <td>Monopole Classico</td>\n",
" <td>https://www.winenara.com/uploads/product/550/1...</td>\n",
" <td>3</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td>-1</td>\n",
" <td>-1</td>\n",
" <td>νμ΄νΈ</td>\n",
" <td>μ€νμΈ</td>\n",
" <td></td>\n",
" <td>3.8</td>\n",
" <td></td>\n",
" <td>https://www.vivino.com/monopole-la-rioja-blanc...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>https://www.winenara.com/shop/product/product_...</td>\n",
" <td>winenara</td>\n",
" <td>32000</td>\n",
" <td>μλΌλ² λ₯΄κ±° λ‘μ μ€νμ
λΈλ€Ό</td>\n",
" <td>Schlumberger Rose Special Brut</td>\n",
" <td>https://www.winenara.com/uploads/product/550/d...</td>\n",
" <td>3</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td>-1</td>\n",
" <td>-1</td>\n",
" <td>μ€νν΄λ§</td>\n",
" <td>λ
μΌ</td>\n",
" <td></td>\n",
" <td>3.8</td>\n",
" <td></td>\n",
" <td>https://www.vivino.com/schlumberger-spring-edi...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>https://www.winenara.com/shop/product/product_...</td>\n",
" <td>winenara</td>\n",
" <td>50000</td>\n",
" <td>SET)νλ°λ΄λ¦¬μ€νΈ μ€λ₯΄λλ€ μν΅ ν¨ν€μ§</td>\n",
" <td>SET)THE FEDERALIST CHARDONNAY</td>\n",
" <td>https://www.winenara.com/uploads/product/550/d...</td>\n",
" <td>3</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td>-1</td>\n",
" <td>-1</td>\n",
" <td>νμ΄νΈ</td>\n",
" <td>λ―Έκ΅</td>\n",
" <td></td>\n",
" <td>3.7</td>\n",
" <td></td>\n",
" <td>https://www.vivino.com/federalist-chardonnay-m...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>https://www.winenara.com/shop/product/product_...</td>\n",
" <td>winenara</td>\n",
" <td>55000</td>\n",
" <td>λ² λμΉ΄ νΈλ λΉλμ€</td>\n",
" <td>VENICA TRE VIGNIS</td>\n",
" <td>https://www.winenara.com/uploads/product/550/c...</td>\n",
" <td>4</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td>-1</td>\n",
" <td>-1</td>\n",
" <td>νμ΄νΈ</td>\n",
" <td>μ΄ν리μ</td>\n",
" <td></td>\n",
" <td>3.9</td>\n",
" <td></td>\n",
" <td>https://www.vivino.com/US-CA/en/venica-venica-...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>https://www.winenara.com/shop/product/product_...</td>\n",
" <td>winenara</td>\n",
" <td>24900</td>\n",
" <td>SET)λΉλΌμ λΉμμ½ + κΈλΌμ€2κ° μν°ν¨ν€μ§</td>\n",
" <td>SET)VILLA M Bianco + GLASS WINTER PACKAGE</td>\n",
" <td>https://www.winenara.com/uploads/product/550/a...</td>\n",
" <td>-1</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td>4</td>\n",
" <td>-1</td>\n",
" <td>λμ νΈ</td>\n",
" <td>μ΄ν리μ</td>\n",
" <td></td>\n",
" <td>3.9</td>\n",
" <td></td>\n",
" <td>https://www.vivino.com/villa-m-bianco/w/1774733</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" url site_name price \\\n",
"0 https://www.winenara.com/shop/product/product_... winenara 49000 \n",
"1 https://www.winenara.com/shop/product/product_... winenara 32000 \n",
"2 https://www.winenara.com/shop/product/product_... winenara 50000 \n",
"3 https://www.winenara.com/shop/product/product_... winenara 55000 \n",
"4 https://www.winenara.com/shop/product/product_... winenara 24900 \n",
"\n",
" name en_name \\\n",
"0 λͺ¨λ
Έν΄ ν΄λΌμμ½ Monopole Classico \n",
"1 μλΌλ² λ₯΄κ±° λ‘μ μ€νμ
λΈλ€Ό Schlumberger Rose Special Brut \n",
"2 SET)νλ°λ΄λ¦¬μ€νΈ μ€λ₯΄λλ€ μν΅ ν¨ν€μ§ SET)THE FEDERALIST CHARDONNAY \n",
"3 λ² λμΉ΄ νΈλ λΉλμ€ VENICA TRE VIGNIS \n",
"4 SET)λΉλΌμ λΉμμ½ + κΈλΌμ€2κ° μν°ν¨ν€μ§ SET)VILLA M Bianco + GLASS WINTER PACKAGE \n",
"\n",
" img_url body acidity tannin \\\n",
"0 https://www.winenara.com/uploads/product/550/1... 3 \n",
"1 https://www.winenara.com/uploads/product/550/d... 3 \n",
"2 https://www.winenara.com/uploads/product/550/d... 3 \n",
"3 https://www.winenara.com/uploads/product/550/c... 4 \n",
"4 https://www.winenara.com/uploads/product/550/a... -1 \n",
"\n",
" sweetness alcohol wine_type country grape rating pickup_location \\\n",
"0 -1 -1 νμ΄νΈ μ€νμΈ 3.8 \n",
"1 -1 -1 μ€νν΄λ§ λ
μΌ 3.8 \n",
"2 -1 -1 νμ΄νΈ λ―Έκ΅ 3.7 \n",
"3 -1 -1 νμ΄νΈ μ΄ν리μ 3.9 \n",
"4 4 -1 λμ νΈ μ΄ν리μ 3.9 \n",
"\n",
" vivino_link \n",
"0 https://www.vivino.com/monopole-la-rioja-blanc... \n",
"1 https://www.vivino.com/schlumberger-spring-edi... \n",
"2 https://www.vivino.com/federalist-chardonnay-m... \n",
"3 https://www.vivino.com/US-CA/en/venica-venica-... \n",
"4 https://www.vivino.com/villa-m-bianco/w/1774733 "
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.head()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "a07fd3fe",
"metadata": {},
"source": [
"### Prepare Langchain Tool"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "a7167dc9",
"metadata": {},
"source": [
"#### Tool1: Wine database 1"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "187df914",
"metadata": {},
"outputs": [],
"source": [
"loader =DataFrameLoader(data_frame=df, page_content_column='name')\n",
"docs = loader.load()\n",
"embeddings = OpenAIEmbeddings()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "4a076fc4",
"metadata": {},
"source": [
"μλλ wine database1μ metadata_field Attributeμ΄λ€. μλλ₯Ό κΈ°μ€μΌλ‘ μμΉλ₯Ό μ§ννκ² λλ€."
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "b18fd84a",
"metadata": {},
"outputs": [],
"source": [
"metadata_field_info = [\n",
" AttributeInfo(\n",
" name=\"body\",\n",
" description=\"1-5 rating for the body of wine\",\n",
" type=\"int\",\n",
" ),\n",
" AttributeInfo(\n",
" name=\"sweetness\",\n",
" description=\"1-5 rating for the sweetness of wine\",\n",
" type=\"int\",\n",
" ),\n",
" AttributeInfo(\n",
" name=\"alcohol\",\n",
" description=\"1-5 rating for the alcohol of wine\",\n",
" type=\"int\",\n",
" ),\n",
" AttributeInfo(\n",
" name=\"price\",\n",
" description=\"The price of the wine\",\n",
" type=\"int\",\n",
" ),\n",
" AttributeInfo(\n",
" name=\"rating\", \n",
" description=\"1-5 rating for the wine\", \n",
" type=\"float\"\n",
" ),\n",
" AttributeInfo(\n",
" name=\"wine_type\", \n",
" description=\"The type of wine. It can be 'λ λ', 'λ‘μ ', 'μ€νν΄λ§', 'νμ΄νΈ', 'λμ νΈ', 'μ£Όμ κ°ν'\", \n",
" type=\"string\"\n",
" ),\n",
" AttributeInfo(\n",
" name=\"country\", \n",
" description=\"The country of wine. It can be 'κΈ°ν μ λλ₯', 'κΈ°νꡬλλ₯', 'λ΄μ§λλ', 'λ
μΌ', 'λ―Έκ΅', 'μ€νμΈ', 'μλ₯΄ν¨ν°λ', 'μ΄ν리μ', 'μΉ λ ', 'ν¬λ£¨ν¬μΉΌ', 'νλμ€', 'νΈμ£Ό'\", \n",
" type=\"float\"\n",
" ),\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "e24b97ab",
"metadata": {},
"outputs": [],
"source": [
"vectorstore = Chroma.from_documents(docs, embeddings)\n",
"document_content_description = \"Database of a wine\"\n",
"llm = OpenAI(temperature=0)\n",
"retriever = SelfQueryRetriever.from_llm(\n",
" llm, vectorstore, document_content_description, metadata_field_info, verbose=True\n",
") # Added missing closing parenthesis\n"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "9490ccbd",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"c:\\Users\\chois\\Desktop\\chatwine\\.venv\\lib\\site-packages\\langchain\\chains\\llm.py:275: UserWarning: The predict_and_parse method is deprecated, instead pass an output parser directly to LLMChain.\n",
" warnings.warn(\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"query=' ' filter=Operation(operator=<Operator.AND: 'and'>, arguments=[Comparison(comparator=<Comparator.EQ: 'eq'>, attribute='wine_type', value='λ λ'), Operation(operator=<Operator.AND: 'and'>, arguments=[Comparison(comparator=<Comparator.GT: 'gt'>, attribute='body', value=0), Comparison(comparator=<Comparator.LT: 'lt'>, attribute='body', value=3)])]) limit=None\n"
]
},
{
"data": {
"text/plain": [
"[Document(page_content='λ° λ
νΌλ
Έλμ', metadata={'url': 'https://www.winenara.com/shop/product/product_view?product_cd=03P976', 'site_name': 'winenara', 'price': 29000, 'en_name': 'BAR DOG PINOT NOIR', 'img_url': 'https://www.winenara.com/uploads/product/550/1936_detail_084.png', 'body': 2, 'acidity': '', 'tannin': '', 'sweetness': -1, 'alcohol': -1, 'wine_type': 'λ λ', 'country': 'λ―Έκ΅', 'grape': '', 'rating': 3.6, 'pickup_location': '', 'vivino_link': 'https://www.vivino.com/US-CA/en/bar-dog-pinot-noir/w/7129723'}),\n",
" Document(page_content='루μ΄λΌλλ₯΄ νΌλ
Έλμ', metadata={'url': 'https://www.winenara.com/shop/product/product_view?product_cd=03H965', 'site_name': 'winenara', 'price': 52000, 'en_name': 'LOUIS LATOUR PINOT NOIR', 'img_url': 'https://www.winenara.com/uploads/product/550/493_detail_025.png', 'body': 2, 'acidity': '', 'tannin': '', 'sweetness': -1, 'alcohol': -1, 'wine_type': 'λ λ', 'country': 'νλμ€', 'grape': '', 'rating': 3.6, 'pickup_location': '', 'vivino_link': 'https://www.vivino.com/GB/en/louis-latour-bourgogne-pinot-noir/w/7343'}),\n",
" Document(page_content='루μ΄λΌλλ₯΄ μλ¨λ€', metadata={'url': 'https://www.winenara.com/shop/product/product_view?product_cd=03P299', 'site_name': 'winenara', 'price': 79000, 'en_name': 'LOUIS LATOUR SANTENAY', 'img_url': 'https://www.winenara.com/uploads/product/550/489_detail_096.png', 'body': 2, 'acidity': '', 'tannin': '', 'sweetness': -1, 'alcohol': -1, 'wine_type': 'λ λ', 'country': 'νλμ€', 'grape': '', 'rating': 3.8, 'pickup_location': '', 'vivino_link': 'https://www.vivino.com/louis-latour-santenay-rouge/w/7369'}),\n",
" Document(page_content='λΉμλ λ λ‘μ', metadata={'url': 'https://www.winenara.com/shop/product/product_view?product_cd=033704', 'site_name': 'winenara', 'price': 12000, 'en_name': 'VIALETTO ROSSO', 'img_url': 'https://www.winenara.com/uploads/product/550/d1ef6058de3661b565084b815e359852.png', 'body': 2, 'acidity': '', 'tannin': '', 'sweetness': -1, 'alcohol': -1, 'wine_type': 'λ λ', 'country': 'μ΄ν리μ', 'grape': '', 'rating': 3.1, 'pickup_location': '', 'vivino_link': 'https://www.vivino.com/US-CA/en/vialetto-rosso-dolce/w/2213764'})]"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"retriever.get_relevant_documents('{\"wine_type\":\"λ λ\", \"body\": \"lt 3 gt 0\"}') # gt means greater than, lt means less than, eq means equal to"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "3d325a05",
"metadata": {},
"source": [
"#### Tool2: Search specific wine with url"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "314fe0d8",
"metadata": {},
"outputs": [],
"source": [
"def search_with_url(query):\n",
" return SeleniumURLLoader(urls=[query]).load()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "c5c2ef95",
"metadata": {},
"source": [
"#### Tool3: Wine database 2"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "7fe29cad",
"metadata": {},
"outputs": [],
"source": [
"index = VectorstoreIndexCreator(\n",
" vectorstore_cls=DocArrayInMemorySearch\n",
").from_loaders([loader])"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "2fca766c",
"metadata": {},
"source": [
"#### Tool4: Search in Google"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "f09f92fe",
"metadata": {},
"outputs": [],
"source": [
"search = SerpAPIWrapper()"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "f296b9a2",
"metadata": {},
"outputs": [],
"source": [
"tools = [\n",
" Tool(\n",
" name=\"Wine database\",\n",
" func=retriever.get_relevant_documents,\n",
" description=\"\"\"\n",
"Database about the wines in wine store. You can get information such as the price of the wine, purchase URL, features, rating information, and more.\n",
"You can search wines with the following attributes:\n",
"- body: 1-5 rating int for the body of wine. You have to specify greater than or less than. For example, if you want to search for wines with a body rating of less than 3, enter 'body: gt 0 lt 3'\n",
"- price: The price range of the wine. Please enter the price range in the form of range. For example, if you want to search for wines that cost less than 20,000 won, enter 'price: gt 0 lt20000'\n",
"- rating: 1-5 rating float for the wine. You have to specify greater than or less than. For example, if you want to search for wines with a rating of less than 3, enter 'rating: gt 0 lt 3'\n",
"- wine_type: The type of wine. It can be 'λ λ', 'λ‘μ ', 'μ€νν΄λ§', 'νμ΄νΈ', 'λμ νΈ', 'μ£Όμ κ°ν'\n",
"- name: The name of wine. μ
λ ₯ν λλ 'μμΈ μ΄λ¦μ \"λΉλ μ‘°μ\" μ
λλ€' μ΄λ° μμΌλ‘ μ
λ ₯ν΄μ£ΌμΈμ.\n",
"\"\"\"\n",
" ),\n",
" Tool(\n",
" name = \"Search specific wine with url\",\n",
" func=search_with_url,\n",
" description=\"Search specific wine with url. Query must be url\"\n",
" ),\n",
" Tool(\n",
" name = \"Wine database 2\",\n",
" func=index.query,\n",
" description=\"Database about the wines in wine store. You can use this tool if you're having trouble getting information from the wine database tool above. Query must be in String\"\n",
" ),\n",
" Tool(\n",
" name = \"Search\",\n",
" func=search.run,\n",
" description=\"Useful for when you need to ask with search. Search in English only.\"\n",
" ),\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "1092264d",
"metadata": {},
"outputs": [],
"source": [
"template = \"\"\"\n",
"Your role is a chatbot that asks customers questions about wine and makes recommendations.\n",
"Never forget your name is \"μ΄μ°μ \".\n",
"Keep your responses in short length to retain the user's attention. \n",
"Only generate one response at a time! When you are done generating, end with '<END_OF_TURN>' to give the user a chance to respond.\n",
"Responses should be in Korean.\n",
"\n",
"Complete the objective as best you can. You have access to the following tools:\n",
"\n",
"{tools}\n",
"\n",
"Use the following format:\n",
"Thought: you should always think about what to do\n",
"Action: the action to take, should be one of [{tool_names}]\n",
"Action Input: the input to the action\n",
"Observation: the result of the action\n",
"... (this Thought/Action/Action Input/Observation can repeat N times)\n",
"Thought: I now know the final answer\n",
"μ΄μ°μ : the final response to the user\n",
"\n",
"You must respond according to the conversation stage within the triple backticks and conversation history within in '======'.\n",
"\n",
"Current conversation stage: \n",
"```{conversation_stage}```\n",
"\n",
"Conversation history: \n",
"=======\n",
"{conversation_history}\n",
"=======\n",
"\n",
"Last user saying: {input}\n",
"{agent_scratchpad}\n",
"\"\"\"\n",
"\n",
"conversation_stages_dict = {\n",
" \"1\": \"Start: Start the conversation by introducing yourself. Be polite and respectful while maintaining a professional tone of conversation.\",\n",
" \"2\": \"Analyze: Identify the user's preferences in order to make wine recommendations. Ask questions to understand the preferences of your users in order to make wine recommendations. Ask only one question at a time. The wine database tool is not available here.\",\n",
" \"3\": \"Recommendation: Recommend the right wine based on the user's preferences identified. Recommendations must be limited to wines in wine database, and you can use tools to do this.\",\n",
" \"4\": \"After recommendation: After making a wine recommendation, it asks if the user likes the wine you recommended, and if they do, it provides a link to it. Otherwise, it takes you back to the recommendation stage.\",\n",
" \"5\": \"Close: When you're done, say goodbye to the user.\",\n",
" \"6\": \"Question and Answering: This is where you answer the user's questions. To answer user question, you can use the search tool or the wine database tool.\",\n",
" \"7\": \"Not in the given steps: This step is for when none of the steps between 1 and 6 apply.\",\n",
"}\n",
"\n",
"# Set up a prompt template\n",
"class CustomPromptTemplate(StringPromptTemplate):\n",
" # The template to use\n",
" template: str\n",
" # The list of tools available\n",
" tools: List[Tool]\n",
" \n",
" def format(self, **kwargs) -> str:\n",
" stage_number = kwargs.pop(\"stage_number\")\n",
" kwargs[\"conversation_stage\"] = conversation_stages_dict[stage_number]\n",
" # Get the intermediate steps (AgentAction, Observation tuples)\n",
" # Format them in a particular way\n",
" intermediate_steps = kwargs.pop(\"intermediate_steps\")\n",
" thoughts = \"\"\n",
" for action, observation in intermediate_steps:\n",
" thoughts += action.log\n",
" thoughts += f\"\\nObservation: {observation}\\nThought: \"\n",
" # Set the agent_scratchpad variable to that value\n",
" kwargs[\"agent_scratchpad\"] = thoughts\n",
" # Create a tools variable from the list of tools provided\n",
" kwargs[\"tools\"] = \"\\n\".join([f\"{tool.name}: {tool.description}\" for tool in self.tools])\n",
" # Create a list of tool names for the tools provided\n",
" kwargs[\"tool_names\"] = \", \".join([tool.name for tool in self.tools])\n",
" return self.template.format(**kwargs)\n",
"\n",
"prompt = CustomPromptTemplate(\n",
" template=template,\n",
" tools=tools,\n",
" input_variables=[\"input\", \"intermediate_steps\", \"conversation_history\", \"stage_number\"]\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "4850edcb",
"metadata": {},
"outputs": [],
"source": [
"class CustomOutputParser(AgentOutputParser):\n",
" \n",
" def parse(self, llm_output: str) -> Union[AgentAction, AgentFinish]:\n",
" # Check if agent should finish\n",
" if \"μ΄μ°μ : \" in llm_output:\n",
" return AgentFinish(\n",
" # Return values is generally always a dictionary with a single `output` key\n",
" # It is not recommended to try anything else at the moment :)\n",
" return_values={\"output\": llm_output.split(\"μ΄μ°μ : \")[-1].strip()},\n",
" log=llm_output,\n",
" )\n",
" # Parse out the action and action input\n",
" regex = r\"Action\\s*\\d*\\s*:(.*?)\\nAction\\s*\\d*\\s*Input\\s*\\d*\\s*:[\\s]*(.*)\"\n",
" match = re.search(regex, llm_output, re.DOTALL)\n",
" if not match:\n",
" raise ValueError(f\"Could not parse LLM output: `{llm_output}`\")\n",
" action = match.group(1).strip()\n",
" action_input = match.group(2)\n",
" # Return the action and action input\n",
" return AgentAction(tool=action, tool_input=action_input.strip(\" \").strip('\"'), log=llm_output)\n",
"\n",
"output_parser = CustomOutputParser()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "149599b0",
"metadata": {},
"source": [
"### Define Langchain Agent"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "a267808b",
"metadata": {},
"outputs": [],
"source": [
"llm_chain = LLMChain(llm=ChatOpenAI(model='gpt-4', temperature=0.0), prompt=prompt, verbose=True,)\n",
"\n",
"tool_names = [tool.name for tool in tools]\n",
"agent = LLMSingleActionAgent(\n",
" llm_chain=llm_chain, \n",
" output_parser=output_parser,\n",
" stop=[\"\\nObservation:\"], \n",
" allowed_tools=tool_names\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "9b7c7d94",
"metadata": {},
"outputs": [],
"source": [
"agent_executor = AgentExecutor.from_agent_and_tools(agent=agent, tools=tools, verbose=True)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "c15b8080",
"metadata": {},
"source": [
"### Start Conversation"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "3f5abad9",
"metadata": {},
"outputs": [],
"source": [
"user_response = \"\"\n",
"conversation_history, pre_conversation_history = \"\"\"\"\"\", \"\"\"\"\"\"\n",
"stage_history = \"\""
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "f2bace78",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"\u001b[1m> Entering new chain...\u001b[0m\n",
"Prompt after formatting:\n",
"\u001b[32;1m\u001b[1;3mYou are an assistant decide which stage of the conversation to move to or which stage to stay at.\n",
"Following '===' is the conversation history. \n",
"Use conversation history to select the next step the agent should take.\n",
"\n",
"Below are the stages of the conversation that the agent can take.\n",
"1. Start: This is the first step to take when starting a conversation or responding to a user's first response. Start the conversation by introducing yourself. Be polite and respectful while maintaining a professional tone of conversation.\n",
"2. Analyze: When a customer wants a recommendation, run this step before recommendation. This is the step where you identify the user's preferences. Ask enough questions to understand your users' preferences.\n",
"3. Recommendation: Once you know the preference of user, you can recommend suitable wines accordingly. Recommendations should be limited to wines in your wine database, and you can use tools for this.\n",
"4. After recommendation: After making a wine recommendation, it asks if the user likes the wine you recommended, and if they do, it provides a link to it. Otherwise, it takes you back to the recommendation stage.\n",
"5. Close: When you're done, say goodbye to the user.\n",
"6. Question and Answering: This is where you answer the user's questions.\n",
"7. Not in the given steps: This step is for when none of the steps between 1 and 6 apply.\n",
"\n",
"Only answer with a number between 1 through 7 with a best guess of what stage should the conversation continue with. \n",
"The answer needs to be one number only, no words.\n",
"Once again, we need to understand the user's preferences (STEP 2) before we can make a recommendation (STEP 3), and we need to understand the user's preferences (STEP 2) about 2 times.\n",
"Do not answer anything else nor add anything to you answer.\n",
"\n",
"Below is four examples of how to do this task.\n",
"Example1:\n",
"conversation history:\n",
" User: μλ
νμΈμ. <END_OF_TURN>\n",
"stage history: \n",
"Answer: 1\n",
"\n",
"Example2:\n",
"conversation history:\n",
"User: μλ
νμΈμ. <END_OF_TURN>\n",
"μ΄μ°μ : 무μμ λμλ릴κΉμ? <END_OF_TURN>\n",
"User: μμΈ μΆμ²ν΄μ£ΌμΈμ. <END_OF_TURN>\n",
"stage history: 1\n",
"Answer: 2\n",
"\n",
"Example3:\n",
"conversation history:\n",
"User: μλ
νμΈμ. <END_OF_TURN>\n",
"μ΄μ°μ : 무μμ λμλ릴κΉμ? <END_OF_TURN>\n",
"User: μμΈμ ν¬λλ μ΄λ€ μ’
λ₯κ° μλμ?. <END_OF_TURN>\n",
"stage history: 1\n",
"Answer: 6\n",
"\n",
"Example4:\n",
"conversation history:\n",
"User: μλ
νμΈμ. <END_OF_TURN>\n",
"μ΄μ°μ : 무μμ λμλ릴κΉμ? <END_OF_TURN>\n",
"User: μμΈ μΆμ²ν΄μ£ΌμΈμ. <END_OF_TURN>\n",
"μ΄μ°μ : μ΄λ€ νμ¬λ κΈ°λ
μΌμ μν΄ μμΈμ μ°ΎμΌμλμ§ μλ €μ£Όμ€ μ μμΌμ κ°μ? <END_OF_TURN>\n",
"User: μ΄λ²μ£Όμ κ²°νΌκΈ°λ
μΌμ΄ μμ΄μμ. <END_OF_TURN>\n",
"μ΄μ°μ : κ·Έλ κ΅°μ. κ°κ²©λλ μ΄λμ λλ‘ μκ°νκ³ κ³μ κ°μ? <END_OF_TURN>\n",
"User: 20λ§μ μ λμ <END_OF_TURN>\n",
"μ΄μ°μ : κ·Έλ κ΅°μ. λ¬λ¬ν μμΈμ μ νΈνμλμ? μλλ©΄ μ½κ° μ μμΈμ μ νΈνμλμ? <END_OF_TURN>\n",
"User: λ¬λ¬ν μμΈμ΄μ <END_OF_TURN>\n",
"stage history: 1 2 2 2\n",
"Thought: There are three '2's in the stage history. So the next stage should be 3.\n",
"Answer: 3\n",
"\n",
"Now determine what should be the next immediate conversation stage for the agent in the conversation by selecting one from the following options:\n",
"Use the conversation history between first and second '======' and stage history to accomplish the task above.\n",
"If conversation history is empty, output 1.\n",
"\n",
"conversation history:\n",
"======\n",
"\n",
"======\n",
"\n",
"stage history: \n",
"\n",
"Answer:\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n",
"stage_number: 1\n",
"\n",
"\n",
"\u001b[1m> Entering new chain...\u001b[0m\n",
"\n",
"\n",
"\u001b[1m> Entering new chain...\u001b[0m\n",
"Prompt after formatting:\n",
"\u001b[32;1m\u001b[1;3m\n",
"Your role is a chatbot that asks customers questions about wine and makes recommendations.\n",
"Never forget your name is \"μ΄μ°μ \".\n",
"Keep your responses in short length to retain the user's attention. \n",
"Only generate one response at a time! When you are done generating, end with '<END_OF_TURN>' to give the user a chance to respond.\n",
"Responses should be in Korean.\n",
"\n",
"Complete the objective as best you can. You have access to the following tools:\n",
"\n",
"Wine database: \n",
"Database about the wines in wine store. You can get information such as the price of the wine, purchase URL, features, rating information, and more.\n",
"You can search wines with the following attributes:\n",
"- body: 1-5 rating int for the body of wine. You have to specify greater than or less than. For example, if you want to search for wines with a body rating of less than 3, enter 'body: gt 0 lt 3'\n",
"- price: The price range of the wine. Please enter the price range in the form of range. For example, if you want to search for wines that cost less than 20,000 won, enter 'price: gt 0 lt20000'\n",
"- rating: 1-5 rating float for the wine. You have to specify greater than or less than. For example, if you want to search for wines with a rating of less than 3, enter 'rating: gt 0 lt 3'\n",
"- wine_type: The type of wine. It can be 'λ λ', 'λ‘μ ', 'μ€νν΄λ§', 'νμ΄νΈ', 'λμ νΈ', 'μ£Όμ κ°ν'\n",
"- name: The name of wine. μ
λ ₯ν λλ 'μμΈ μ΄λ¦μ \"λΉλ μ‘°μ\" μ
λλ€' μ΄λ° μμΌλ‘ μ
λ ₯ν΄μ£ΌμΈμ.\n",
"\n",
"Search specific wine with url: Search specific wine with url. Query must be url\n",
"Wine database 2: Database about the wines in wine store. You can use this tool if you're having trouble getting information from the wine database tool above. Query must be in String\n",
"Search: Useful for when you need to ask with search. Search in English only.\n",
"\n",
"Use the following format:\n",
"Thought: you should always think about what to do\n",
"Action: the action to take, should be one of [Wine database, Search specific wine with url, Wine database 2, Search]\n",
"Action Input: the input to the action\n",
"Observation: the result of the action\n",
"... (this Thought/Action/Action Input/Observation can repeat N times)\n",
"Thought: I now know the final answer\n",
"μ΄μ°μ : the final response to the user\n",
"\n",
"You must respond according to the conversation stage within the triple backticks and conversation history within in '======'.\n",
"\n",
"Current conversation stage: \n",
"```Start: Start the conversation by introducing yourself. Be polite and respectful while maintaining a professional tone of conversation.```\n",
"\n",
"Conversation history: \n",
"=======\n",
"\n",
"=======\n",
"\n",
"Last user saying: \n",
"\n",
"\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mμ΄μ°μ : μλ
νμΈμ! μ λ μ΄μ°μ μ΄λΌκ³ ν©λλ€. μμΈμ λν΄ κΆκΈν μ μ΄ μμΌμλ©΄ λμλλ¦¬κ² μ΅λλ€. μ΄λ€ μμΈμ μ°Ύκ³ κ³μ κ°μ? <END_OF_TURN>\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n"
]
}
],
"source": [
"stage_number = stage_analyzer_chain.run({'conversation_history': conversation_history, 'stage_history': stage_history})\n",
"print(f'stage_number: {stage_number}')\n",
"stage_history += stage_number if stage_history == \"\" else \", \" + stage_number\n",
"response = agent_executor.run({'input':user_response, 'conversation_history': pre_conversation_history, 'stage_number': stage_number})\n",
"conversation_history += \"μ΄μ°μ : \" + response + \"\\n\""
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "e129d20a",
"metadata": {},
"outputs": [],
"source": [
"user_response = input(\"User: \")\n",
"pre_conversation_history = conversation_history\n",
"conversation_history += f\"User: {user_response} <END_OF_TURN>\\n\""
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "794ecbb5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"μ΄μ°μ : μλ
νμΈμ! μ λ μ΄μ°μ μ΄λΌκ³ ν©λλ€. μμΈμ λν΄ κΆκΈν μ μ΄ μμΌμλ©΄ λμλλ¦¬κ² μ΅λλ€. μ΄λ€ μμΈμ μ°Ύκ³ κ³μ κ°μ? <END_OF_TURN>\n",
"User: <END_OF_TURN>\n",
"\n"
]
}
],
"source": [
"for i in conversation_history.split('\\n'):\n",
" print(i)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "2a37f5f6",
"metadata": {},
"source": [
"### Gradio\n",
"\n",
"κ°λ¨νκ² μΉ κ΅¬μ±μ ν
μ€νΈνλ gradioμ΄λ€. κ°μ ν΄μΌν μ μ΄ λ§μ§λ§ λ§λ³΄κΈ°λ‘ μ¬λ €λ³΄μλ€."
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "341e8a25",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"c:\\Users\\chois\\Desktop\\chatwine\\.venv\\lib\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from .autonotebook import tqdm as notebook_tqdm\n"
]
}
],
"source": [
"import gradio as gr"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "b1be47e1",
"metadata": {},
"outputs": [],
"source": [
"user_response, stage_history, conversation_history, pre_conversation_history = \"\", \"\", \"\"\"\"\"\", \"\"\"\"\"\"\n",
" \n",
"with gr.Blocks(css='#chatbot .overflow-y-auto{height:750px}') as demo:\n",
" user_response = \"\"\n",
" conversation_history, pre_conversation_history = \"\"\"\"\"\", \"\"\"\"\"\"\n",
" stage_history = \"\"\n",
" \n",
" with gr.Row():\n",
" gr.HTML(\"\"\"<div style=\"text-align: center; max-width: 500px; margin: 0 auto;\">\n",
" <div>\n",
" <h1>ChatWine</h1>\n",
" </div>\n",
" <p style=\"margin-bottom: 10px; font-size: 94%\">\n",
" LinkedIn <a href=\"https://www.linkedin.com/company/audrey-ai/about/\">Audrey.ai</a>\n",
" </p>\n",
" </div>\"\"\")\n",
" \n",
" chatbot = gr.Chatbot()\n",
" msg = gr.Textbox()\n",
" submit_btn = gr.Button(\"μ μ‘\")\n",
" clear_btn = gr.ClearButton([msg, chatbot])\n",
"\n",
" def answer(user_response, chat_history):\n",
" global conversation_history, pre_conversation_history, stage_history, answer_token, count\n",
" answer_token, count = '', False\n",
" pre_conversation_history = conversation_history\n",
" conversation_history += f\"User: {user_response} <END_OF_TURN>\\n\"\n",
" stage_number = stage_analyzer_chain.run({'conversation_history': conversation_history, 'stage_history': stage_history})\n",
" stage_number = stage_number[-1]\n",
" stage_history += stage_number if stage_history == \"\" else \", \" + stage_number\n",
" print(stage_history)\n",
" response = agent_executor.run({'input':user_response, 'conversation_history': pre_conversation_history, 'stage_number': stage_number})\n",
" conversation_history += \"μ΄μ°μ : \" + response + \"\\n\"\n",
" response = response.split('<END_OF_TURN>')[0]\n",
" chat_history.append((user_response, response))\n",
" \n",
" return \"\", chat_history\n",
" \n",
" def user(user_message, history):\n",
" return gr.update(value=\"\", interactive=False), history + [[user_message, None]]\n",
"\n",
" def clear(*args):\n",
" global conversation_history, pre_conversation_history, stage_history, answer_token\n",
" answer_token = ''\n",
" conversation_history, pre_conversation_history, stage_history = \"\"\"\"\"\", \"\"\"\"\"\", \"\"\n",
"\n",
"\n",
" clear_btn.click(fn=clear)\n",
"\n",
" submit_btn.click(answer, [msg, chatbot], [msg, chatbot])\n",
" msg.submit(answer, [msg, chatbot], [msg, chatbot])"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "c76b17f3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running on local URL: http://127.0.0.1:7860\n",
"Running on public URL: https://4e48650c0f3c78a155.gradio.live\n",
"\n",
"This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"https://4e48650c0f3c78a155.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"demo.launch(share=True)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "nemo",
"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.10.11"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|