Nandha Bot's Channel
1.47K subscribers
101 photos
50 videos
15 files
171 links
🗣️ Discussion Group - @NandhaSupport
📢 Network Channel - @NandhaNetwork
🛒 Market Shop - @NandhaMarket

Owner: @Nandha

ℹ️ GitHub Account:
https://github.com/nandhaxd

ℹ️ GitHub Organization: https://github.com/Nandhabots
Download Telegram
GROQ_API_KEY = "" 

❤️ Get your Groq Api key from
https://www.groq.com/

from groq import Groq # ( pip install groq )

async def get_groq_response(user_prompt, system_prompt):
try:
client = Groq(api_key=GROQ_API_KEY)
chat_completion = client.chat.completions.create(
messages=[
{
"role": "system",
"content": system_prompt,
},
{
"role": "user",
"content": user_prompt,
}
],
model="llama3-8b-8192",
)
return chat_completion.choices[0].message.content
except Exception as e:
print(f"Getting error in Groq response: {e}")
return "Error getting Groq response."

Info: Using groq as your custom AI bot assistant 😀

#NandhaBots #Groq #AI
Please open Telegram to view this post
VIEW IN TELEGRAM
👍2
An example of making custom AI chatbot using Python-Telegram-Bot library but raw bot YouTube video

https://youtu.be/pee02cApGzk?si=JWxsnmD9wHhbTpPv

Subscribe and Support [CODE] link in Description Page 👎
Please open Telegram to view this post
VIEW IN TELEGRAM
👍3
async def get_trendings(country: str):
base_url = "https://getdaytrends.com"
url = base_url + f'/{country}'
headers = {"user-agent": get_ua()}

# func for extract data from table
def get_result(data):
tags = data.table.find_all('tr')
results = []
for tr in tags:
src = tr.td
title = src.get_text()
link = base_url + src.a.get('href')
results.append({'title': title, 'url': link})
return results

async with aiohttp.ClientSession() as session:
try:
async with session.get(url, headers=headers) as response:
if response.status != 200:
return {'error': response.reason}
content = await response.text()
soup = BeautifulSoup(content, 'html.parser')
tables = soup.select("div[class^='inset']")
return {
'now_hashtags': get_result(tables[0]),
'today_hashtags': get_result(tables[1]),
'top_hashtags': get_result(tables[2])
}

except Exception as e:
return {'error': str(e)}

Scrapper for get top tweets tags that are trending now, today, and top in a country #NandhaBots
👍1