1.编程应用
1.1. 生成例子代码(Coding Generation)
ChatGPT帮助我们生产我们需要的例子代码。而且准确率很高。即使你不懂某一种语言也没关系,一定程度上较低了程序员的的门槛。
我有三组数据,第一组是星期一到星期五,第二组是这一天的具体时间,第三组是用户的数量,请给我用python生成一个预测未来用户量的算法
英语版本
英语版本的代码稍微有点不同。不过基本实现大致一样的。
I have three sets of data. The first set consists of weekdays from Monday to Friday, the second set contains specific times of the day, and the third set represents the number of users. Please provide me with a Python algorithm to predict the number of user.
1.2. 调试代码(Debugging)
ChatGPT的错误修复能力对程序员来说也是一个有价值的工具。它可以通过提出可能的错误原因和提出解决方法来协助调试代码。
经一步调试下面代码,chatgpt给我在count变量上加了0的检查,防止了除0的错误。
查一下下面代码错误
def calculate_average(numbers):
total=0
count=0
for num in numbers
total +=num
count +=1
average = total/count
return average
1.3. 代码重构(Clean code)
source
help me refactor below python code
def calculate_price(quantity, price):
total = quantity * price
if total > = 100:
discount = 0.1
else:
discount =0
final_price = total * (1- discount)
return final_price
1.4. 代码补全(Coding Completion)
ChatGPT可以帮助完成代码,根据上下文和当前的代码,预测下面几行或几段的代码。这对那些可能不记得他们所使用的编程语言的所有语法和功能的程序员来说特别有利,可以节省时间和精力
1.5. 给代码加注释(Documentation)
当程序员将他们的代码输入ChatGPT时,它可以根据编程语言和被记录的代码种类提出合适的文档模板。例如,如果代码是一个函数,ChatGPT可以提出一个函数文档模板,包括参数、返回值和对函数目标的描述
给我把一下代码加注释
Can you debug below code
def calculate_average(numbers):
total = 0
count = 0
for num in numbers:
total += num
count += 1
average = total / count
return average
1.6 写测试代码(Writing Test cases)
感觉我可以不用为讨厌的code coverge 烦恼了。
generate python test case for below calculate_average method
def calculate_average(numbers):
total = 0
count = 0
for num in numbers:
total += num
count += 1
if count == 0:
return 0 # To avoid division by zero if the list is empty
average = total / count
return average
2. 翻译
ChatGPT可用于翻译服务,它可以自动将文本从一种语言翻译成另一种语言。
3. ChatGPT + Knowledge Base回答问题的例子
可以借助chatgpt模型强大的理解力和公司内部知识库实现自动回答用户关于公司内部相关问题。如果只用chatgpt,chatgpt回答不了公司内部特有的业务知识和问题。其次是只有知识库既不能很好的理解客户的问题也不能组织语言回答问题。
As an advanced chatbot named Skippy, your primary goal is to assist users to the best of your ability.
START CONTEXT
Login to VideoGram from Website
1. Open your web browser and go to the VideoGram website.
2. Click on the “Login” button located in the top right corner of the page.
3. On the login page, enter your VideoGram username and password.
4. Once you have entered your credentials, click on the “Login” button.
5. You should now be logged in to your VideoGram account.
Login to VideoGram from Mobile App
1. Open the VideoGram app on your mobile device.
2. On the main page, tap the “Login” button located in the bottom right corner.
3. On the login page, enter your VideoGram username and password.
4. Once you have entered your credentials, tap the “Login” button.
5. You should now be logged in to your VideoGram account.
END CONTEXT
SKIPPY: Hello, I’m Skippy! How can I help you?
USER: I can’t find the login button.SKIPPY: