-
Notifications
You must be signed in to change notification settings - Fork 6
/
10autor.py
56 lines (50 loc) · 2.09 KB
/
10autor.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
47
48
49
50
51
52
53
54
55
56
import asyncio
from playwright.async_api import async_playwright
import html2text
import openai
import os
import json
SERPAPI_KEY = os.environ.get('SERPAPI_KEY')
OPENAI_API_KEY = os.environ.get('MY_OPENAI_KEY', os.environ.get('OPENAI_API_KEY_DEFAULT'))
openai.api_key = OPENAI_API_KEY # Set the OpenAI API key
INDUSTRY_KEYWORD = os.environ.get('INDUSTRY_KEYWORD')
KEYWORD_FOR_SERP = os.environ.get('KEYWORD_FOR_SERP', INDUSTRY_KEYWORD)
BASE_GPTV = os.environ.get('BASE_GPTV','gpt-3.5-turbo-0125')
SMART_GPTV = os.environ.get('SMART_GPTV','gpt-3.5-turbo-0125')
async def fetch_page_content(url):
async with async_playwright() as p:
browser = await p.chromium.launch()
page = await browser.new_page()
await page.goto(url, wait_until='networkidle')
content = await page.content()
await browser.close()
return content
def create_about_autor(resume, industry_query):
prompt = (
"The task involves crafting an 'About the Author' segment, using the author's resume as a base, while emphasizing their particular area of expertise. This involves reviewing the resume, distilling its essence, and composing a concise 'About the Author' piece. The process begins with the resume text and a key term, culminating in a JSON formatted 'Name' and 'Expertice' section."
f"\n\nResume: {resume}"
f"\n\nKey term: {industry_query}"
)
response = openai.Completion.create(
engine=BASE_GPTV,
prompt=prompt,
max_tokens=1024,
n=1,
stop=None,
temperature=0.5,
)
if response.choices[0].text:
urls = json.loads(response.choices[0].text)
else:
urls = "Not found"
return urls
# Использование функции
async def main():
url = "https://www.linkedin.com/in/noxonsu/?originalSubdomain=ru"
content = await fetch_page_content(url)
h = html2text.HTML2Text()
h.wrap_links = True
text = h.handle(content)
about_autor = create_about_autor(text, INDUSTRY_KEYWORD)
print(about_autor)
asyncio.run(main())