-
Notifications
You must be signed in to change notification settings - Fork 1
PR for rocker tong #tSk6tXH26miJ99EEHL3h #648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Logging: initLogging: initLogging: on_chain_startSerialized:{ inputs:{ Logging: on_chat_model_startSerialized:{ message:[[SystemMessage(content='You are a helpful AI assistant.', additional_kwargs={}), HumanMessage(content='You can use the ability with id Logging: on_llm_endgenerations=[[ChatGeneration(text='', generation_info={'finish_reason': 'function_call'}, message=AIMessage(content='', additional_kwargs={'function_call': {'name': 'run_ability', 'arguments': '{\n "ability_id": "gpt_engineer",\n "ability_args": "从donews平台上抽取最新科技新闻发送到[email protected]邮箱里面"\n}'}}, example=False))]] llm_output={'token_usage': <OpenAIObject at 0x7f579c611eb0> JSON: { Logging: on_agent_actionTool used:run_ability Tool input:{ Additional log:Invoking: Logging: on_chat_model_startSerialized:{ message:[[SystemMessage(content='You are a helpful AI assistant.', additional_kwargs={}), HumanMessage(content='You can use the ability with id Logging: on_llm_endgenerations=[[ChatGeneration(text='', generation_info={'finish_reason': 'function_call'}, message=AIMessage(content='', additional_kwargs={'function_call': {'name': 'run_ability', 'arguments': '{\n "ability_id": "8x5joFx3uMt4CcLnoc8s",\n "ability_args": "从donews平台上抽取最新科技新闻发送到[email protected]邮箱里面"\n}'}}, example=False))]] llm_output={'token_usage': <OpenAIObject at 0x7f579c613470> JSON: { Logging: on_agent_actionTool used:run_ability Tool input:{ Additional log:Invoking: Logging: on_chat_model_startSerialized:{ message:[[SystemMessage(content='You are a helpful AI assistant.', additional_kwargs={}), HumanMessage(content='You can use the ability with id Logging: on_llm_endgenerations=[[ChatGeneration(text="Based on the task, we will need to create a Python script that will scrape the Donews website for technology news and then send the news to a specified email address. We will use the BeautifulSoup library for web scraping and the smtplib library for sending emails.\n\nHere are the core classes, functions, and methods that will be necessary:\n\n1. Logging: on_agent_finishReturn values:{ Additional logs:Based on the task, we will need to create a Python script that will scrape the Donews website for technology news and then send the news to a specified email address. We will use the BeautifulSoup library for web scraping and the smtplib library for sending emails. Here are the core classes, functions, and methods that will be necessary:
Now, let's write the code for each of these classes and functions. news_scraper.py from bs4 import BeautifulSoup
import requests
class NewsScraper:
def __init__(self, url):
self.url = url
def get_news(self):
response = requests.get(self.url)
soup = BeautifulSoup(response.text, 'html.parser')
news = soup.find_all('div', class_='news-item')
news_text = [item.text for item in news]
return '\n'.join(news_text)email_sender.py import smtplib
class EmailSender:
def __init__(self, sender_email, sender_password, receiver_email):
self.sender_email = sender_email
self.sender_password = sender_password
self.receiver_email = receiver_email
def send_email(self, subject, body):
message = f'Subject: {subject}\n\n{body}'
with smtplib.SMTP('smtp.163.com', 587) as server:
server.login(self.sender_email, self.sender_password)
server.sendmail(self.sender_email, self.receiver_email, message)main.py from news_scraper import NewsScraper
from email_sender import EmailSender
def main():
news_scraper = NewsScraper('http://www.donews.com/news/')
news = news_scraper.get_news()
email_sender = EmailSender('sender_email', 'sender_password', '[email protected]')
email_sender.send_email('Daily Technology News', news)
if __name__ == '__main__':
main()requirements.txt Please replace 'sender_email' and 'sender_password' with your 163.com email address and password. Also, make sure to install the required packages by running |
You can use the ability with id
gpt_engineeras an AI software engineer, theability_argsfor this ability must be non-empty. Just pass in your request for a software feature as a string toability_args(but you have to escape certain special characters such as'and"becauseability_argsare passed in a Linux command line terminal). Keep in mind that thisgpt_engineerability does not have access to the information that you have, so you must provide it with all the necessary information inability_args.You can use the ability with id
8x5joFx3uMt4CcLnoc8sas an AI software company that has numerous roles and can accomplish any SaaS-related tasks, theability_argsfor this ability must be non-empty. Just pass in your request for a software feature as a string toability_args(but you have to escape certain special characters such as'and"becauseability_argsare passed in a Linux command line terminal). Keep in mind that this8x5joFx3uMt4CcLnoc8sability does not have access to the information that you have, so you must provide it with all the necessary information inability_args.When you try to accomplish a given task, you should always do the following two steps in order:
gpt_engineerto write out the source code.8x5joFx3uMt4CcLnoc8sto first design the software of the product.mdfiles andmmd(nmermaid) files.Now do the following task:
从donews平台上抽取最新科技新闻发送到[email protected]邮箱里面
Gothub's Answer: Based on the task, we will need to create a Python script that will scrape the Donews website for technology news and then send the news to a specified email address. We will use the BeautifulSoup library for web scraping and the smtplib library for sending emails.
Here are the core classes, functions, and methods that will be necessary:
NewsScraper: This class will be responsible for scraping the Donews website for technology news. It will have the following methods:__init__: This method will initialize theNewsScraperobject.get_news: This method will scrape the Donews website for technology news and return the news as a string.EmailSender: This class will be responsible for sending the news to a specified email address. It will have the following methods:__init__: This method will initialize theEmailSenderobject.send_email: This method will send an email with the news to a specified email address.main: This function will create aNewsScraperobject, use it to get the news, create anEmailSenderobject, and use it to send the news to a specified email address.Now, let's write the code for each of these classes and functions.
news_scraper.py
email_sender.py
main.py
requirements.txt
Please replace 'sender_email' and 'sender_password' with your 163.com email address and password. Also, make sure to install the required packages by running
pip install -r requirements.txt.```bashpython3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python main.py