ChatGPT的5个功能,提升日常工作效

ChatGPT与生活 1年前 (2023) lida
113 0 0

最近,ChatGPT 成为了一个热门话题。这个应用能够在短时间内获得数十亿用户,是最快实现这一目标的应用之一。今天,我想分享五个 ChatGPT 的功能,以帮助我们提高日常工作和代码质量。1. 文本生成ChatGPT 可以生成各种类型的文本,包括新闻报道、文章、电子邮件和聊天对话等。这可以为我们提供新的创意和思路,帮助我们提高工作效率。2. 对话管理ChatGPT 可以管理对话,包括添加文本、删除文本、更改文本内容和回复文本等。这可以帮助我们更好地组织对话,并确保对话的连贯性和流畅性。3. 代码调试ChatGPT 可以识别代码中的错误,并提供相应的建议和解决方案。这可以帮助我们更快地修复代码中的错误,并提高代码质量。4. 文本分类ChatGPT 可以对文本进行分类,包括新闻、文章、电子邮件和聊天对话等。这可以帮助我们更好地了解文本内容,并找到相关的信息。5. 语言模型评估ChatGPT 可以评估语言模型的性能,包括准确性、召回率和准确率等。这可以帮助我们更好地了解我们的模型,并改进模型的性能。ChatGPT 是一个非常强大的工具,可以帮助我们提高工作效率、提高代码质量和更好地管理对话。我们可以利用 ChatGPT 的这五个功能来更好地完成我们的日常工作和开发。

ChatGPT的5个功能,提升日常工作效

ChatGPT的出现,彻底改变了开发代码的方式。但是目前为止,大多数软件开发人员和数据专业人员仍然没有习惯使用 ChatGPT 来改进和简化自己的工作。

这就是为什么我在这里概述了5个不同的功能,以提高日常工作的速度和质量。

下面让我们一起探索如何在日常工作中使用它们

❝ ⚠️ 警告:我们不应在 ChatGPT 中使用关键代码或信息。

1.生成编码框架

ChatGPT 是我们从头开始构建新项目的秘密武器。只需几个提示,它就可以生成我们所需的代码框架,以及所选择的技术、框架和版本。它不仅每次为我们节省了至少一个小时左右的工作时间,而且有助于保持文档(或团队的文档)的有效组织和更新。这就像团队中多了一双手,一双勤劳的手!

例如,我们想使用一些外部API,可以请 ChatGPT 为我们起草一个初始代码结构。

问:Generate boiler plate code that integrates an extern API using Python.

ChatGPT的5个功能,提升日常工作效

或者我们甚至可以要求这个框架使用 Selenium 抓取 LinkedIn

ChatGPT 的输出如下:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

# Initialize the web driver
driver = webdriver.Firefox()

# Navigate to LinkedIn
driver.get(“https://www.linkedin.com/”)

# Find the email and password input fields
email = driver.find_element_by_id(“username”)
password = driver.find_element_by_id(“password”)

# Enter your credentials
email.send_keys(“YOUR_EMAIL”)
password.send_keys(“YOUR_PASSWORD”)

# Click the login button
driver.find_element_by_xpath(“//button[@type=submit]”).click()

# Wait for the page to load
time.sleep(5)

# Navigate to the profile of the desired user
driver.get(“https://www.linkedin.com/in/USER_PROFILE_NAME”)

# Extract the information you want from the page
name = driver.find_element_by_xpath(“//span[@class=inline t-24 t-black t-normal break-words]”).text
location = driver.find_element_by_xpath(“//span[@class=t-16 t-black t-normal inline-block]”).text

print(name)
print(location)

# close the browser
driver.quit()

很简单对吧?尝试用我们能想象的任何项目去挑战 ChatGPT 吧。

2.研究和比较

决定如何实施某件事可能是很困难的,特别是当有多种情况可供选择时。我的方法是为每种选择创建一个基本的概念模型,然后比较它们。这种方法可以帮助我做出更明智的决定,并确保我不会做出错误的选择。

但是,在 ChatGPT 的帮助下,这个过程变得简单多了。

我们现在可以直接向它征求专家级别的意见,以确定哪种选项或库最适合我们的代码开发。这节省了我们在决策过程中的时间和精力,并确保使用了最佳的工具。

好的,让我们想象一下,我想使用地理空间数据,但我不确定是否应该使用 GeoStandard 或 Plotly。我们可以要求 ChatGPT 进行比较,它立即回答了两个库之间的主要区别。

ChatGPT的5个功能,提升日常工作效

如果想要抓取网站,就可以询问 ChatGPT 是否认为 Python 中最流行的 web 抓取库是最好的。

ChatGPT的5个功能,提升日常工作效

我们可以询问想要抓取的网站的最佳方式是什么,尽管 ChatGPT 可能会警告我们这样做将违反该网站的内容政策,但我们必须小心,因为这样做可能会带来麻烦。

问:What’s the best option to scrape a social network?

ChatGPT的5个功能,提升日常工作效

3.理解代码

在日常工作当中,我们时常需要阅读和理解非自己编写的代码库。面对一个复杂且组织不良的代码库,浏览起来可能会是一项令人崩溃的任务。

使用 ChatGPT 后,我对新的代码库的理解变得容易多了。现在,我可以简单地要求 ChatGPT 解释代码的功能,而不必浪费宝贵的时间和精力来破译写得不好的代码。

想象一下,当我们正在尝试抓取 Linkedin 时,在互联网上发现了一个样例代码,该代码可以滚动 Linkedin 招聘网站。

问:What does the following code do? [insert code here]

#We find how many jobs are offered.
jobs_num = driver.find_element(By.CSS_SELECTOR,”h1>span”).get_attribute(“innerText”)
if len(jobs_num.split(,)) > 1:
jobs_num = int(jobs_num.split(,)[0])*1000
else:
jobs_num = int(jobs_num)

jobs_num = int(jobs_num)

#Here I choose manually a number of jobs, so it wont take that long:
jobs_num = 1000;

#We create a while loop to browse all jobs.
i = 2
while i <= int(jobs_num/2)+1:
#We keep scrollind down to the end of the view.
driver.execute_script(“window.scrollTo(0, document.body.scrollHeight);”)
i = i + 1
print(“Current at: “, i, “Percentage at: “, ((i+1)/(int(jobs_num/2)+1))*100, “%”,end=”\r”)
try:
#We try to click on the load more results buttons in case it is already displayed.
infinite_scroller_button = driver.find_element(By.XPATH, “.//button[@aria-label=Load more results]”)
infinite_scroller_button.click()
time.sleep(0.1)
except:
#If there is no button, there will be an error, so we keep scrolling down.
time.sleep(0.1)
pass

ChatGPT 立即对上面的代码进行了非常详细的解释。我们甚至要求在代码的给定部分提供更多的细节。

ChatGPT的5个功能,提升日常工作效

4.向代码添加注释

ChatGPT 还可以帮助提高代码的质量和可维护性。通过要求它逐行添加注释,可以使得其他人更容易理解和使用我们的代码。

ChatGPT 可以显著提高可读性、可维护性以及与他人的协作。

让我们假设下面的代码根本没有注释。我们可以要求 ChaGPT 直接向其添加注释。

问:Add comments to the following code [insert code here]

# Find the number of jobs offered on the website
jobs_num = driver.find_element(By.CSS_SELECTOR,”h1>span”).get_attribute(“innerText”)

# Check if the number of jobs contains a , and if so, convert it to number * 1000
if len(jobs_num.split(,)) > 1:
jobs_num = int(jobs_num.split(,)[0])*1000
else:
jobs_num = int(jobs_num)

# Convert jobs_num to an integer
jobs_num = int(jobs_num)

# Set the number of jobs to scrape to 1000
jobs_num = 1000;

# Initialize a counter variable to scroll through the jobs
i = 2

# Start a while loop to scroll through the jobs
while i <= int(jobs_num/2)+1:
# Scroll to the bottom of the page
driver.execute_script(“window.scrollTo(0, document.body.scrollHeight);”)
# Increment the counter variable
i = i + 1
# Print the current number of jobs scrolled through and the percentage of completion
print(“Current at: “, i, “Percentage at: “, ((i+1)/(int(jobs_num/2)+1))*100, “%”,end=”\r”)
try:
# Try to locate the “Load more results” button and click on it
infinite_scroller_button = driver.find_element(By.XPATH, “.//button[@aria-label=Load more results]”)
infinite_scroller_button.click()
# Sleep for 0.1 seconds
time.sleep(0.1)
except:
# If the button is not present, sleep for 0.1 seconds and continue scrolling
time.sleep(0.1)
pass

5.使用某种样式重写代码

ChatGPT 不仅是理解不熟悉代码的宝贵工具,还可以帮助我们确保自己的代码符合行业标准和惯例。通过要求它纠正我们的代码以符合 Pep-8 约定,甚至为我们的编码风格创建一个自定义约定,我们可以避免在合并来自不同 repo 或团队的代码时进行昂贵且耗时的重构。这样,我们就可以更好地管理代码,提高代码质量和可维护性。

ChatGPT 是一个多功能工具,可以提高代码库的质量和可维护性,简化协作流程,从而提高工作效率。

如果我们要求 ChatGPT 使用 Pep-8 标准编写以前的代码,它将直接为我们提供重构的代码。

问:Can you rewrite the following code using Pep8 standard [Insert code here]

ChatGPT的5个功能,提升日常工作效

今天,我们介绍了 ChatGPT 的 5 个功能,这些功能可以大大提高日常工作的效率。这些功能可以帮助用户自动化文本生成、文本分类、对话管理、文本摘要和语言模型训练等任务。这些功能的出现,使得 ChatGPT 成为聊天机器人领域的一个里程碑。

关键词:ChatGPT、代码质量、日常工作、功能、帮助、Python。

版权声明:lida 发表于 2023年3月15日 pm2:43。
转载请注明:ChatGPT的5个功能,提升日常工作效 | ChatGPT资源导航

相关文章