update
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
PERPLEXITY_AI_API = "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"
|
PERPLEXITY_AI_API = "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"
|
||||||
OPENAI_API_KEY = "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"
|
OPENAI_API_KEY = "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"
|
||||||
|
TAVILY_API_KEY = "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"
|
||||||
@@ -0,0 +1,399 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 12,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": [
|
||||||
|
"True"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 12,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"from openai import OpenAI\n",
|
||||||
|
"import os\n",
|
||||||
|
"import requests\n",
|
||||||
|
"from dotenv import load_dotenv\n",
|
||||||
|
"from langchain_openai import ChatOpenAI\n",
|
||||||
|
"from tavily import TavilyClient\n",
|
||||||
|
"from langchain_core.prompts.prompt import PromptTemplate\n",
|
||||||
|
"from langchain_core.output_parsers import StrOutputParser, JsonOutputParser\n",
|
||||||
|
"from loguru import logger\n",
|
||||||
|
"load_dotenv()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"os.environ[\"OPENAI_API_KEY\"] = os.getenv(\"OPENAI_API_KEY\")\n",
|
||||||
|
"llm = ChatOpenAI(model=\"gpt-4o\")"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"API_KEY = os.getenv('PERPLEXITY_AI_API')"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 4,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def perplexity_data(prompt, api_key=API_KEY):\n",
|
||||||
|
" url = \"https://api.perplexity.ai/chat/completions\"\n",
|
||||||
|
"\n",
|
||||||
|
" payload = {\n",
|
||||||
|
" \"model\": \"llama-3.1-sonar-huge-128k-online\",\n",
|
||||||
|
" \"messages\": [\n",
|
||||||
|
" {\n",
|
||||||
|
" \"role\": \"system\",\n",
|
||||||
|
" \"content\": \"Be precise and concise.\"\n",
|
||||||
|
" },\n",
|
||||||
|
" {\n",
|
||||||
|
" \"role\": \"user\",\n",
|
||||||
|
" \"content\": prompt\n",
|
||||||
|
" }\n",
|
||||||
|
" ],\n",
|
||||||
|
" \"temperature\": 0.2,\n",
|
||||||
|
" \"top_p\": 0.9,\n",
|
||||||
|
" \"return_citations\": True,\n",
|
||||||
|
" \"search_domain_filter\": [\"perplexity.ai\"],\n",
|
||||||
|
" \"return_images\": False,\n",
|
||||||
|
" \"return_related_questions\": False,\n",
|
||||||
|
" \"search_recency_filter\": \"month\",\n",
|
||||||
|
" \"top_k\": 0,\n",
|
||||||
|
" \"stream\": False,\n",
|
||||||
|
" \"presence_penalty\": 0,\n",
|
||||||
|
" \"frequency_penalty\": 1\n",
|
||||||
|
" }\n",
|
||||||
|
" \n",
|
||||||
|
" headers = {\n",
|
||||||
|
" \"Authorization\": f\"Bearer {api_key}\",\n",
|
||||||
|
" \"Content-Type\": \"application/json\"\n",
|
||||||
|
" }\n",
|
||||||
|
" \n",
|
||||||
|
" response = requests.post(url, json=payload, headers=headers)\n",
|
||||||
|
" \n",
|
||||||
|
" # Check if the request was successful\n",
|
||||||
|
" if response.status_code == 200:\n",
|
||||||
|
" response_data = response.json()\n",
|
||||||
|
" try:\n",
|
||||||
|
" # Extract the message content\n",
|
||||||
|
" message_content = response_data['choices'][0]['message']['content']\n",
|
||||||
|
" return message_content\n",
|
||||||
|
" except (KeyError, IndexError):\n",
|
||||||
|
" return \"Unexpected response format.\"\n",
|
||||||
|
" else:\n",
|
||||||
|
" return f\"Request failed with status code: {response.status_code}\""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 5,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"product_categories = [\n",
|
||||||
|
" \"Beauty & Skincare\",\n",
|
||||||
|
" \"Fashion & Lifestyle\",\n",
|
||||||
|
" \"Health & Fitness\",\n",
|
||||||
|
" \"Travel & Adventure\",\n",
|
||||||
|
" \"Food & Beverage\",\n",
|
||||||
|
" \"Technology & Gadgets\",\n",
|
||||||
|
" \"Gaming & Esports\",\n",
|
||||||
|
" \"Parenting & Family\",\n",
|
||||||
|
" \"Finance & Business\",\n",
|
||||||
|
" \"Wellness & Mental Health\",\n",
|
||||||
|
" \"Automotive & Motorsports\",\n",
|
||||||
|
" \"Entertainment & Pop Culture\",\n",
|
||||||
|
" \"Photography & Visual Arts\",\n",
|
||||||
|
" \"Education & Learning\",\n",
|
||||||
|
" \"Environmental & Sustainability\"\n",
|
||||||
|
"]"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 6,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"us_states = [\n",
|
||||||
|
" \"Alabama\", \"Alaska\", \"Arizona\", \"Arkansas\", \"California\", \"Colorado\", \"Connecticut\",\n",
|
||||||
|
" \"Delaware\", \"Florida\", \"Georgia\", \"Hawaii\", \"Idaho\", \"Illinois\", \"Indiana\", \"Iowa\",\n",
|
||||||
|
" \"Kansas\", \"Kentucky\", \"Louisiana\", \"Maine\", \"Maryland\", \"Massachusetts\", \"Michigan\",\n",
|
||||||
|
" \"Minnesota\", \"Mississippi\", \"Missouri\", \"Montana\", \"Nebraska\", \"Nevada\", \"New Hampshire\",\n",
|
||||||
|
" \"New Jersey\", \"New Mexico\", \"New York\", \"North Carolina\", \"North Dakota\", \"Ohio\",\n",
|
||||||
|
" \"Oklahoma\", \"Oregon\", \"Pennsylvania\", \"Rhode Island\", \"South Carolina\", \"South Dakota\",\n",
|
||||||
|
" \"Tennessee\", \"Texas\", \"Utah\", \"Vermont\", \"Virginia\", \"Washington\", \"West Virginia\",\n",
|
||||||
|
" \"Wisconsin\", \"Wyoming\"\n",
|
||||||
|
"]"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 7,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"prompt = \"\"\"\n",
|
||||||
|
" Give me a list of the names of the all the beauty and skincare influencers in USA\n",
|
||||||
|
"\"\"\""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 8,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# prompt = \"\"\"\n",
|
||||||
|
"# I'm a business owner in search for influencers to promote my brand.\\n\n",
|
||||||
|
"# My brand falls under this category : \"Beauty & Skincare\" \\n.\n",
|
||||||
|
"# I need your help with getting information for at least the top 30 influencers in Alabama in the USA. \\n\n",
|
||||||
|
"# These are the informations I need regarding each of them: \\n\n",
|
||||||
|
"# 1. Name \\n\n",
|
||||||
|
"# 2. Contact info \\n\n",
|
||||||
|
"# 4. Facebook username\\n\n",
|
||||||
|
"# 5. Instagram username \\n\n",
|
||||||
|
"# 6. Tiktok username \\n\n",
|
||||||
|
"# 7. Youtube username \\n\n",
|
||||||
|
"# 8. Facebook followers \\n\n",
|
||||||
|
"# 9. Instagram followers \\n\n",
|
||||||
|
"# 10 Tiktok followers \\n\n",
|
||||||
|
"# 11. Youtube subscribers \\n \n",
|
||||||
|
"# For cases where you don't know or have the details, just return Null. \\n\n",
|
||||||
|
"# Make sure you return a structured response only. Don't add extra informations. \\n \n",
|
||||||
|
"# I want all the information regarding each of the influencers noted properly. \\n\n",
|
||||||
|
"# Please do this carefully and correctly. \n",
|
||||||
|
"# \"\"\""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 9,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"\n",
|
||||||
|
" Give me a list of the names of the all the beauty and skincare influencers in USA\n",
|
||||||
|
"\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"print(prompt)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 10,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Given the extensive list of influencers across various sources, here is a combined list of beauty and skincare influencers mentioned in the provided search results:\n",
|
||||||
|
"\n",
|
||||||
|
"### From Modash (Top 20 American Beauty Influencers on Instagram)\n",
|
||||||
|
"1. Alexis Tyler (@iamalexistyler)\n",
|
||||||
|
"2. LaShay (@k_bella3)\n",
|
||||||
|
"3. G.H.❤️ RN,BSN👩🏽⚕️ (@_therealparis)\n",
|
||||||
|
"4. Ashanti Camille | HTX Fashion & Lifestyle\n",
|
||||||
|
"5. MaLeaн\n",
|
||||||
|
"6. C J (@hoodspolitic_)\n",
|
||||||
|
"7. 💕🐎COUNTRY BEAUTY🐎💕 (@_escapewithsyd)\n",
|
||||||
|
"8. Beauty Therapist (@ambitiousamb__)\n",
|
||||||
|
"9. Faye Davis (@mz_fae88)\n",
|
||||||
|
"10. Media Queen 👑 (@what_shayna_say)\n",
|
||||||
|
"11. Tee 🤍 | Natural Hair + UGC (@theblushway)\n",
|
||||||
|
"12. (And 8 more influencers listed on the page, but not detailed here due to space constraints)\n",
|
||||||
|
"\n",
|
||||||
|
"### From Feedspot (Top 50 Cruelty Free Beauty Influencers in 2024)\n",
|
||||||
|
"1. Jessica Lyn (@veganbeautyaddict)\n",
|
||||||
|
"2. Cordelia (@phyrra)\n",
|
||||||
|
"3. Jennifer Mathews\n",
|
||||||
|
"4. Sunny Subramanian\n",
|
||||||
|
"5. Vicky (@kabukirune)\n",
|
||||||
|
"6. Bella Fiori\n",
|
||||||
|
"7. Suzana Rose\n",
|
||||||
|
"8. Tashina\n",
|
||||||
|
"9. Mariel (@marielveganbeauty)\n",
|
||||||
|
"10. Danielle (@crueltyfreeveganbeauty)\n",
|
||||||
|
"11. Kasey S (@skinandvelvet)\n",
|
||||||
|
"12. Project Pan (@themakeupfairy_)\n",
|
||||||
|
"13. Caitie Anisman-Reiner (@naturallabeauty)\n",
|
||||||
|
"14. Krisztina Williams (@krisztinawilliams)\n",
|
||||||
|
"15. Dreesa (@flightqueen7)\n",
|
||||||
|
"16. Marissa Jean (@glambyrissaj)\n",
|
||||||
|
"17. Hailee Jones (@haileejonesmua)\n",
|
||||||
|
"18. Kate Audrey (@kateaudreyartistry)\n",
|
||||||
|
"19. Becky Louise (@bottled.blue)\n",
|
||||||
|
"20. (And 30 more influencers listed on the page, but not detailed here due to space constraints)\n",
|
||||||
|
"\n",
|
||||||
|
"### From Amber (Top 20 Beauty Influencers You Must Follow on TikTok)\n",
|
||||||
|
"1. Nikkia Joy\n",
|
||||||
|
"2. Makeup by Analiza\n",
|
||||||
|
"3. Sanny\n",
|
||||||
|
"4. BJ Bushra\n",
|
||||||
|
"5. sarahli\n",
|
||||||
|
"6. Sasha_British\n",
|
||||||
|
"7. chass\n",
|
||||||
|
"8. Ruby Malik\n",
|
||||||
|
"9. Makeup A Murder, INC.\n",
|
||||||
|
"10. (And 10 more influencers listed on the page, but not detailed here due to space constraints)\n",
|
||||||
|
"\n",
|
||||||
|
"### Note:\n",
|
||||||
|
"- The list from Modash and Feedspot focuses on Instagram influencers, while the list from Amber focuses on TikTok influencers.\n",
|
||||||
|
"- The full list of influencers from each source is extensive and includes many more names than those listed here.\n",
|
||||||
|
"- This compilation aims to provide a broad overview of beauty and skincare influencers in the USA, but it is not exhaustive due to the vast number of influencers across various platforms.\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"result = perplexity_data(prompt)\n",
|
||||||
|
"print(result)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 11,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Based on the provided search result, here are the available details for Faye Davis:\n",
|
||||||
|
"\n",
|
||||||
|
"1. **Name**: Faye Davis\n",
|
||||||
|
"2. **Contact info**: Available on Modash, but requires a login or trial to access.\n",
|
||||||
|
"3. **Facebook username**: Not provided in the search results.\n",
|
||||||
|
"4. **Instagram username**: @mz_fae88.\n",
|
||||||
|
"5. **TikTok username**: Not provided in the search results.\n",
|
||||||
|
"6. **YouTube username**: Not provided in the search results.\n",
|
||||||
|
"7. **Facebook followers**: Not provided in the search results.\n",
|
||||||
|
"8. **Instagram followers**: 12.3k.\n",
|
||||||
|
"9. **TikTok followers**: Not provided in the search results.\n",
|
||||||
|
"10. **YouTube subscribers**: Not provided in the search results.\n",
|
||||||
|
"\n",
|
||||||
|
"The information available is limited to what is provided in the search result from Modash, focusing on Instagram influencers. For additional details, you would need to access more comprehensive data or contact Faye Davis directly.\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"prompt = \"\"\"\n",
|
||||||
|
" Give me a the following social details of Faye Davis, a beauty and skincare influencer: \\n\n",
|
||||||
|
" 1. Name \\n\n",
|
||||||
|
" 2. Contact info \\n\n",
|
||||||
|
" 4. Facebook username\\n\n",
|
||||||
|
" 5. Instagram username \\n\n",
|
||||||
|
" 6. Tiktok username \\n\n",
|
||||||
|
" 7. Youtube username \\n\n",
|
||||||
|
" 8. Facebook followers \\n\n",
|
||||||
|
" 9. Instagram followers \\n\n",
|
||||||
|
" 10 Tiktok followers \\n\n",
|
||||||
|
" 11. Youtube subscribers \\n \n",
|
||||||
|
"\"\"\"\n",
|
||||||
|
"result = perplexity_data(prompt)\n",
|
||||||
|
"print(result)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## Solution Implmentation"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "base",
|
||||||
|
"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.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 2
|
||||||
|
}
|
||||||
@@ -480,6 +480,7 @@
|
|||||||
" 6. At the end of your processing you want to return a structured response and also make sure it in the best order as expected by the user. \\n\n",
|
" 6. At the end of your processing you want to return a structured response and also make sure it in the best order as expected by the user. \\n\n",
|
||||||
" \n",
|
" \n",
|
||||||
" Return a structured JSON or dictionary as output. \\n \n",
|
" Return a structured JSON or dictionary as output. \\n \n",
|
||||||
|
" Avoid individual dictionaay per person, but one for al. \\n\n",
|
||||||
" Ensure that the data is properly arranged and in a good format. \\n\n",
|
" Ensure that the data is properly arranged and in a good format. \\n\n",
|
||||||
" Please do this carefully and excellently. \n",
|
" Please do this carefully and excellently. \n",
|
||||||
" \n",
|
" \n",
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user