Files
ds_sabaproject/__pycache__/social_media_collection.cpython-311.pyc
T

116 lines
9.6 KiB
Plaintext
Raw Normal View History

2024-11-13 00:41:30 +01:00
§
¶"g< ã
óºddlZddlZddlmZddlmZddlmZddlm Z ddl
m Z m Z ddl
mZddlZddlZe¦«ejd¦«ejd<ejd ¦«ejd <ejd
¦«ejd
<ed ¬ ¦«Ze¦«Zd
ededededef
dZd
ededefdZdedededefdZdedefdZdedefdZdedefdZdS)éN)Ú load_dotenv)Ú
ChatOpenAI)Ú TavilyClient)ÚPromptTemplate)ÚStrOutputParserÚJsonOutputParser)ÚloggerÚOPENAI_API_KEYÚTAVILY_API_KEYÚPERPLEXITY_AI_APIzgpt-4o)ÚmodelÚ social_mediaÚinfluencer_nameÚsocialmedia_nameÚsocialmedia_followersÚreturncóºtjd¦«tdgd¢¬¦«}|tzt ¦«z}| ||||dœ¦«}|S)Formatting Influencer Dataa<|begin_of_text|><|start_header_id|>system<|end_header_id|>
You are a Influencer Data Extractor AI Agent tasked with extracting information from a search result
You are provided with three informations:
1. The social media name
2. The influencer social media name search result
3. The influencer social media followers/subscribers search results
Your job is to extract the influencer social media name, and social media followers or subscriber.
You are to return this as a JSON output. Two data should be there, the influencer social media name, and social media followers or subscribers.
Do this decently and properly. If the search result isn't showing the social media name or social media folloers/subscribers, return the data as NULL.
Don not add to the search result, just return the JSON data as expected. Also rmember to replace social media with the given social media name in the JSON output.
<|eot_id|><|start_header_id|>user<|end_header_id|>
SOCIALMEDIA: {social_media}
INFLUENCER_NAME: {influencer_name}
SOCIALMEDIA_NAME: {socialmedia_name}
SOCIALMEDIA_FOLLOWERS: {socialmedia_followers}
<|eot_id|><|start_header_id|>assistant<|end_header_id|>)rrrr©ÚtemplateÚinput_variables©r ÚinforÚllmrÚinvoke)rrrrÚinitiator_promptÚinitiator_routerÚoutputs ú^c:\Users\timmy_3aupohg\Downloads\Manaknight Projects\ds_sabaproject\social_media_collection.pyÚget_influencer_datar sÝ
„KÐ?ð&mÐlð)
ñ
ô
Ðð.(­-Õ0@Ñ0BÔ0BÑØ
×
$°\ÐVfðAVðjyð&zð&zñ{ô{€FØ €MóÚproduct_categorycóÖtj|d¦«d|d|d|d}t|¦«t |dd¬¦«}t|¦«tj|d ¦«d
|d |d |d
}t|¦«t |dd¬¦«}t|¦«tjd|d¦«t |h|||¬¦«}|S)Nz name searchz What is the z
username of ú, this person is a popular ú influencer.Úadvancedé
©ÚqueryÚ search_depthÚ max_resultsz followers searchz How many z followers does z have? Note this is a z popular influencer.zFormatting Influencer z Data)rrrr)r rÚprintÚ
tavily_clientÚ
qna_searchr )rrr"Ú
name_questionÚnameÚfollowers_questionÚ followersÚformat_responses rÚsocialmedia_detailsr44s_Ý
„KI IðI¸IðIÐjzðIðIðI€MÝ ˆ-ÑÔÐÝ × #¨-ÀjÐ^`Ð a€DÝ ˆ$K„K€Kå
„KQ QðQÀ?ðQðQÐjzðQðQðQÐÝ Ð
ÑÔÐÝ×(Ð/AÐPZÐhjÐk€IÝ ˆ)ÑÔÐå
„KÐÐ)¸ °~ÐWfÐy}ðV_ð`ñ`ô`€OØ Ðr!ÚcontactÚlocationcó¸tjd¦«tdgd¢¬¦«}|tzt ¦«z}| |||dœ¦«}|S)Nr<|begin_of_text|><|start_header_id|>system<|end_header_id|>
You are a Influencer Data Extractor AI Agent tasked with extracting information from a search result
You are provided with three informations:
1. The social media name
2. The influencer contact info search result
3. The influencer location or state search results
Your job is to extract the influencer's contact info, and location. Make sure things are properly filtered and good.
Pick relevalt info, that can be useful for reaching the influencer
You are to return this as a JSON output. The contact and location should be the keys in the JSON
Do not add to the search result, just return the JSON data as expected.
<|eot_id|><|start_header_id|>user<|end_header_id|>
INFLUENCER_NAME: {influencer_name}
CONTACT: {contact}
LOCATION: {location}
<|eot_id|><|start_header_id|>assistant<|end_header_id|>)r5r6rrr)rr5r6rrrs rÚget_influencer_contactr8EsuÝ
„KÐ?ð$GÐFð'
ñ
ô
Ðð,(­-Õ0@Ñ0BÔ0BÑØ
×
ÀHÐ`oÐ%pÐ%pÑ
q€FØ €Mr!có²tjd¦«d|d|d}t|¦«t |dd¬¦«}t|¦«tjd¦«d |d|d
}t|¦«t |dd¬¦«}t|¦«tjd ¦«t |||¬ ¦«}|S)
Nzcontact details searchz(What is the contact details or email of r$r%r&r'r(zLocation details searchzWhat is the location of z) influencer. Check for state and country.z%Formatting Influencer contact details)rr5r6)r rr,r-r.r8)rr"Úcontact_questionr5Úlocation_questionr6r3s rÚcontact_detailsr<asÝ
„KÐMÀ/ðMðMÐn~ðMðMðMÐÝ Ð
ÑÔÐÝ×&Ð-=ÈJÐdfÐg€GÝ ˆ'N„N€Nå
„KÐ[°?ð[ð[Ð_oð[ð[ð[ÐÝ Ð
ÑÔÐÝ×'Ð.?ÈjÐfhÐi€HÝ ˆ(O„O€Oå
„KÐ,¸_ÐV]ÐhpÐq€OØ Ðr!cótjd¦«td||¬¦«}td||¬¦«}td||¬¦«}td||¬¦«}t||¬¦«}||||||dœ}t j|¦«S) Nz+Getting {influencer_name} social media dataÚFacebook)rrr"Ú InstagramÚTiktokÚYoutube)rr")r0ÚfacebookÚ instagramÚtiktokÚyoutuber5)r rr4r<ÚjsonÚdumps)rr"rBrCrDrEÚ contact_infoÚresponses rÚinfluencer_datarJtÝ
„KÐ
ÈOÐn~ÐÑÔ€HÝÈoðqAðBñBôB€IÝ
¨hÈÐjzÐ
{€FÝ!¨yÈ/Ðl|Ð}€GÝ"°?ÐUeÐf€Lð Ø
ð€Hõ Œ: Ô Ðr!Úinfluencer_namesÚcategorycó¢g}tj ¦«5Šˆˆfd|D¦«}tj |¦«D]d}||} | ¦«}| |¦«Œ5#t $r#}tj|d|¦«Yd}~Œ]d}~wwxYw ddd¦«n #1swxYwY|S)NcóJi|]} t|¦«|Œ S©)ÚsubmitrJ)Ú.0r0rLÚexecutors €€rú
<dictcomp>z+get_all_influencer_data.<locals>.<dictcomp>Žs-ø€ÐtÐ[_ §¢µÀÀxÑ PÔ PÐRVÐtr!z generated an exception: ) Ú
concurrentÚfuturesÚThreadPoolExecutorÚ as_completedÚresultÚappendÚ Exceptionr Úerror) rKrLÚall_influencers_dataÚfuture_to_influencerÚfutureÚ
influencerÚinfluencer_detailsÚexcrRs ` @rÚget_all_influencer_datarbˆsXøø€ØÐõ
Ô × .Ò .Ñ 0Ô 0ð