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

129 lines
11 KiB
Plaintext
Raw Normal View History

2024-11-13 00:41:30 +01:00
§
2024-11-27 20:44:26 +01:00
ó'5g@$ã
óHddlZddlmZddlmZddlmZddlmZddl m
Z
ddl m Z ddl
ZddlZe¦«ejd¦«ejd<ejd ¦«ejd <ejd
¦«ejd
<ed ¬ ¦«Ze¦«Zejd¦«r ejd ¦«rejd
¦«se jd
¦«ed¦«dededededef
2024-11-13 00:41:30 +01:00
dZdededefdZdedededefdZdededefdZdedefdZdedefdZdS)éN)Ú load_dotenv)Ú
ChatOpenAI)Ú TavilyClient)ÚPromptTemplate)ÚJsonOutputParser)ÚloggerÚOPENAI_API_KEYÚTAVILY_API_KEYÚPERPLEXITY_AI_APIzgpt-4o)Úmodelz@One or more API keys are missing from the environment variables.zMissing API keys.Ú social_mediaÚinfluencer_nameÚsocialmedia_nameÚsocialmedia_followersÚreturncó$tjd¦«tdgd¢¬¦«}|tzt ¦«z} | ||||dœ¦«}n3#t $r&}tjd|¦«|ddœcYd}~Sd}~wwxYw|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}
2024-11-27 20:44:26 +01:00
2024-11-13 00:41:30 +01:00
<|eot_id|><|start_header_id|>assistant<|end_header_id|>)r
rrr©ÚtemplateÚinput_variablesz"Error extracting influencer data: )rÚ followers)rÚinforÚllmrÚinvokeÚ ExceptionÚerror)r
2024-11-27 20:44:26 +01:00
rrrÚinitiator_promptÚinitiator_routerÚoutputÚes ú^c:\Users\timmy_3aupohg\Downloads\Manaknight Projects\ds_sabaproject\social_media_collection.pyÚget_influencer_datar"Ý
„KÐ?ð&mÐlð)
ñ
ô
Ðð.(­-Õ0@Ñ0BÔ0BÑðGØ!×(¸ÐZjðEZðn}ð*~ð*~ñôˆˆøÝ ðGðGðGÝŒ Ð=¸>Ø#2ÀÐFøøøøðGøøøð €MsÁAÁ
B
2024-11-13 00:41:30 +01:00
Á'BÂB
2024-11-27 20:44:26 +01:00
ÂB
Úproduct_categorycóÒtj|d¦«d|d|d|d}t|¦«t |d¬¦«}t|¦«tj|d¦«d |d
2024-11-13 00:41:30 +01:00
|d |d }t|¦«t |d¬¦«}t|¦«tjd
|d¦«t |h|||¬¦«}|S)Nz name searchz What is the z
username of ú, this person is a popular ú influencer.é
©ÚqueryÚ max_resultsz followers searchz How many z followers does z have? Note this is a z popular influencer.zFormatting Influencer z Data)r
rrr)rrÚprintÚ
tavily_clientÚ
qna_searchr")r
rr#Ú
name_questionÚnameÚfollowers_questionrÚformat_responses r!Úsocialmedia_detailsr2<sXÝ
„KI IðI¸IðIÐjzðIðIðI€MÝ ˆ-ÑÔÐÝ × #¨-ÀRÐ H€DÝ ˆ$K„K€Kå
„KQ QðQÀ?ðQðQÐjzðQðQðQÐÝ Ð
ÑÔÐÝ×(Ð/AÈrÐR€IÝ ˆ)ÑÔÐå
„KÐÐ)¸ °~ÐWfÐy}ðV_ð`ñ`ô`€OØ ÐóÚ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
2024-11-27 20:44:26 +01:00
You are to return this as a JSON output. The contact and location should be the keys in the JSON
2024-11-13 00:41:30 +01:00
Do not add to the search result, just return the JSON data as expected.
2024-11-27 20:44:26 +01:00
<|eot_id|><|start_header_id|>user<|end_header_id|>
INFLUENCER_NAME: {influencer_name}
2024-11-13 00:41:30 +01:00
CONTACT: {contact}
2024-11-27 20:44:26 +01:00
LOCATION: {location}
2024-11-13 00:41:30 +01:00
2024-11-27 20:44:26 +01:00
<|eot_id|><|start_header_id|>assistant<|end_header_id|>)r4r5rr)rrrrrr)rr4r5rrrs r!Úget_influencer_contactr7MsuÝ
„KÐ?ð$GÐFð'
ñ
ô
2024-11-13 00:41:30 +01:00
Ðð,(­-Õ0@Ñ0BÔ0BÑØ
2024-11-27 20:44:26 +01:00
×
ÀHÐ`oÐ%pÐ%pÑ
2024-11-13 00:41:30 +01:00
q€FØ €Mr3có‚tjd¦«d|d|d}t|¦« t |d¬¦«}n3#t
$r&}tjd|¦«|dd œcYd}~Sd}~wwxYwt|¦«tjd
¦«d |d|d }t|¦« t |d¬¦«}n3#t
$r&}tjd
|¦«|ddœcYd}~Sd}~wwxYwt|¦«tjd¦«t|||¬¦«}|S)z,Fetch and format influencer contact details.zcontact details searchz(What is the contact details or email of r%r&r'r(z Error fetching contact details: N)rr4zLocation details searchzWhat is the location of z) influencer. Check for state and country.z!Error fetching location details: )rr5z%Formatting Influencer contact details)rr4r5)rrr+r,r-rrr7)rr#Úcontact_questionr4r Úlocation_questionr5r1s r!Úcontact_detailsr;iå
„KÐMÀ/ðMðMÐn~ðMðMðMÐÝ Ð
ÑÔÐðEÝ×*Ð1AÈrЈøÝ ðEðEðEÝŒ Ð;¸Ð<Ø#2¸DøøøøðEøøøõ
ˆ'N„N€Nå
„KÐ[°?ð[ð[Ð_oð[ð[ð[ÐÝ Ð
ÑÔÐðFÝ ×+Ð2CÐQSЈøÝ ðFðFðFÝŒ Ð<¸Ð=Ø#2ÀÐEøøøøðFøøøõ
ˆ(O„O€Oå
„KÐ,¸_ÐV]ÐhpÐq€OØ Ðs;®A Á
A;ÁA6Á0A;Á6A;Â:CÃ
DÃ!DÃ<DÄDcótjd¦«td||¬¦«}td||¬¦«}td||¬¦«}td||¬¦«}t||¬¦«}||||||dœ}t j|¦«S) Nz+Getting {influencer_name} social media dataÚFacebook)r
rr#Ú InstagramÚTiktokÚYoutube)rr#)r/ÚfacebookÚ instagramÚtiktokÚyoutuber4)rrr2r;ÚjsonÚdumps)rr#rArBrCrDÚ contact_infoÚresponses r!Úinfluencer_datarIÝ
„KÐ
ÈOÐn~ÐÑÔ€HÝÈoðqAðBñBôB€IÝ
¨hÈÐjzÐ
2024-11-27 20:44:26 +01:00
2024-11-13 00:41:30 +01:00
{€FÝ!¨yÈ/Ðl|Ð}€GÝ"°?ÐUeÐf€Lð Ø
2024-11-27 20:44:26 +01:00
ð€Hõ Œ: Ô Ðr3Ú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©)ÚsubmitrI)Ú.0r/rKÚexecutors €€r!ú
<dictcomp>z+get_all_influencer_data.<locals>.<dictcomp>Ÿs-ø€ÐtÐ[_ §¢µÀÀxÑ PÔ PÐRVÐtr3z generated an exception: ) Ú
concurrentÚfuturesÚThreadPoolExecutorÚ as_completedÚresultÚappendrrr) rJrKÚall_influencers_dataÚfuture_to_influencerÚfutureÚ
influencerÚinfluencer_detailsÚexcrQs ` @r!Úget_all_influencer_datar_sXøø€ØÐõ
Ô × .Ò .Ñ 0Ô 0ð