Skip to content

Commit

Permalink
improvements in main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
senzanome75 committed Sep 30, 2023
1 parent 8dfc710 commit 390505d
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,32 +200,6 @@ def what_language_is_it_written_in(prompt, model="gpt-4", temperature=0.5, max_t
return response["choices"][0]["message"]["content"].lower()


def search_google(query, query_language):
try:
# Search on Google
results = search(query, num_results=10, advanced=True, lang=query_language)
return results

except Exception as e:
return False


def extract_text_from_html_page(url):
# Request to webpage
response = requests.get(url)

# Create a BeautifulSoup object to parse the HTML of the page
soup = BeautifulSoup(response.text, "html5lib")

# Use html2text to convert HTML to Markdown
text_maker = html2text.HTML2Text()
# text_maker.ignore_links = True

markdown_text = text_maker.handle(soup.prettify())

return markdown_text


def it_contains_url(prompt, model="gpt-4", temperature=0.5, max_tokens=2048, top_p=1, frequency_penalty=0, presence_penalty=0):
prompt = "Does this text contain a URL? Reply exclusively with yes or no.\n" + prompt

Expand Down Expand Up @@ -272,6 +246,32 @@ def contains_url(prompt, model="gpt-4", temperature=0.5, max_tokens=2048, top_p=
return response["choices"][0]["message"]["content"]


def search_google(query, query_language):
try:
# Search on Google
results = search(query, num_results=10, advanced=True, lang=query_language)
return results

except Exception as e:
return False


def extract_text_from_html_page(url):
# Request to webpage
response = requests.get(url)

# Create a BeautifulSoup object to parse the HTML of the page
soup = BeautifulSoup(response.text, "html5lib")

# Use html2text to convert HTML to Markdown
text_maker = html2text.HTML2Text()
# text_maker.ignore_links = True

markdown_text = text_maker.handle(soup.prettify())

return markdown_text


### The script starts here ###
# Input the task
task = input("Please enter the task to be performed: ")
Expand Down

0 comments on commit 390505d

Please sign in to comment.