您好,欢迎访问一九零五行业门户网

天啊,ChatGPT真的要代替我们工作了吗?

前言最近这段chatgpt​真的非常火,和chatgpt​相关的ai 服务也是各种如火如荼的研究中。今天我们来看下chatgpt​在编码方面的应用,最近发现一个叫做“ai coding assistant​” 的intellij idea​插件,它就是集合了chatgpt的技术,我们来看看有多么的智能,是否以后真的有可能会代替我们程序员的工作。
插件安装为了开始使用该插件,必须要有一个 openai​ 的令牌。如果你不知道在哪里可以找到它,可以在https://platform.openai.com/account/api-keys这里获取,关于如何注册。百度谷歌教程一大堆。
此外,下载并安装intellij idea的ai coding assistant”插件:
图一——intellij idea 设置中的 “ai coding assistant”插件
尝试一下生成打印hello world的代码​第一个任务先来个简单的,就是让它自动生成打印hello world的代码。
生成一个pojo现在你给我生成一个person类。
现在给我创建一个函数来返回生成的人员列表​
有了person数据以后,我们可以实现一些简单的算法,比如找到列表中最年长的人,列表中人的最小/最大/平均年龄​
其中有趣的部分是我们可以要求更新现有代码。因为我知道使用 java stream api 编写相同算法的更好方法,所以让我们尝试让它进行重构
我们可以创建一个函数并要求它根据函数名的意思生成代码。​
然后你在给我把javadoc也补充了把
那你还能给我的代码添加注释吗,解释下这段代码是干嘛的吗?​
最后我们来看看通过这个ai插件生成的最终的代码长啥样?​import java.util.arraylist; import java.util.arrays; import java.util.comparator; import java.util.intsummarystatistics; import java.util.list; import java.util.nosuchelementexception; public class main { public static void main(string[] args) { system.out.println(hello world); final list people = generatepeople(); // find oldest person in the list person oldestperson = people.stream() .max(comparator.comparing(person::getage)) .orelsethrow(nosuchelementexception::new); system.out.println(oldest person is: + oldestperson.getname()); // find max,min,avg age of the people intsummarystatistics stats = people.stream() .maptoint(person::getage) .summarystatistics(); system.out.println(max age: + stats.getmax()); system.out.println(min age: + stats.getmin()); system.out.println(avg age: + stats.getaverage()); } public static list generatepeople() { return arrays.aslist( new person(john, 25), new person(jane, 30), new person(jack, 20), new person(jill, 35) ); } /** * capitalizes the first letter of a given string and lowercases the rest. * * @param s the string to capitalize * @return the capitalized string */ public static string capitalize(string s) { /* this code checks if the length of the string s is 0. if it is, it returns the string. if not, it returns the first character of the string in uppercase and the rest of the characters in lowercase. */ if (s.length() == 0) return s; return s.substring(0, 1).touppercase() + s.substring(1).tolowercase(); } } // class person with name and age class person { private string name; private int age; public person(string name, int age) { this.name = name; this.age = age; } public string getname() { return name; } public int getage() { return age; } }
结论利用chatgpt这样的ai可以生成一些代码,如上面的例子所示,但是面对一些复杂的业务还是做不到的。我们可以借助这样的工具,帮助我们提高工作上的效率,但是也不用担心他们会取代我们。
以上就是天啊,chatgpt真的要代替我们工作了吗?的详细内容。
其它类似信息

推荐信息