-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
46 lines (35 loc) · 1.24 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import requests
import openai
from bs4 import BeautifulSoup
url = "https://t.me/uniannet/136771"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36"
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
page_content = response.text
soup = BeautifulSoup(page_content, 'html.parser')
# Find the meta tags with og:description property
description_tags = soup.find_all('meta', attrs={'property': 'og:description'})
# Extract the value of the first tag (if it exists).
if description_tags:
description = "Here should be AI descriptor " + description_tags[0].get('content')
#print(description)
else:
print("Description tag not found")
else:
print("Error:", response.status_code)
openai.api_type = "open_ai"
openai.api_base = "http://localhost:1234/v1"
openai.api_key = "Whatever"
response = openai.ChatCompletion.create(
model='gpt-4',
messages=[
{'role': 'system', 'content': 'you are a helpful assistant'},
{'role': 'user', 'content': description}
],
temperature=0.5,
max_tokens=1024
)
#print(response)
print(response.choices[0].message.content)