{ "cells": [ { "cell_type": "code", "execution_count": 6, "id": "1a305246-59d9-453e-9903-ca462611f1eb", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
ProductReview
0Queen Size sheet SetI ordered a king size set.
1Waterproof Phone PcuchI loved the waterproof sac
2Luxury Air MattressThis mattress had a small hole in the top
3Pillows Insertthis is the best pillow filters on amazon
4Milk Frother Handheld\\nmI loved this product But they only seem to I
\n", "
" ], "text/plain": [ " Product Review\n", "0 Queen Size sheet Set I ordered a king size set.\n", "1 Waterproof Phone Pcuch I loved the waterproof sac\n", "2 Luxury Air Mattress This mattress had a small hole in the top\n", "3 Pillows Insert this is the best pillow filters on amazon\n", "4 Milk Frother Handheld\\nm I loved this product But they only seem to I" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import openai\n", "import os\n", "\n", "from dotenv import load_dotenv, find_dotenv\n", "_ = load_dotenv(find_dotenv())\n", "import pandas as pd\n", "\n", "df = pd.read_csv('Data.csv')\n", "df.head()\n" ] }, { "cell_type": "code", "execution_count": 7, "id": "8f75bedd-2b00-466a-a00f-bc7c47f2f7a8", "metadata": {}, "outputs": [], "source": [ "from langchain.chat_models import ChatOpenAI\n", "from langchain.prompts import ChatPromptTemplate\n", "from langchain.chains import LLMChain" ] }, { "cell_type": "code", "execution_count": 8, "id": "edc76aa3-1d1f-41d2-93a9-8297268817ea", "metadata": {}, "outputs": [], "source": [ "llm = ChatOpenAI(temperature=0.9)" ] }, { "cell_type": "code", "execution_count": 9, "id": "27f2d3c9-9601-4b31-8d35-bae9538ee2a0", "metadata": {}, "outputs": [], "source": [ "prompt = ChatPromptTemplate.from_template(\"what is the best name to describe a company that make {product}\")" ] }, { "cell_type": "code", "execution_count": 10, "id": "03ef9080-77ba-4406-a402-e4d5b889be47", "metadata": {}, "outputs": [], "source": [ "chain = LLMChain(llm=llm, prompt=prompt)" ] }, { "cell_type": "code", "execution_count": 11, "id": "0a172ea1-18ce-407b-bcd9-b4146c5f5610", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\"1. Royal Rest\\n2. Majestic Beddings\\n3. Luxurio Linens\\n4. Queen's Haven\\n5. Dreamy Slumber\\n6. Palace Sheets\\n7. Regal Comfort\\n8. Crowned Beddings\\n9. Serene Sleep\\n10. Imperial Linens\"" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "product = \"Queen Size Sheet Set\"\n", "chain.run(product)" ] }, { "cell_type": "code", "execution_count": null, "id": "b0ff950c-1c09-4ba5-8661-626fb69b24ca", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.11.4" } }, "nbformat": 4, "nbformat_minor": 5 }