search
HomeTechnology peripheralsAIOh my god, is ChatGPT really going to work for us?

Oh my god, is ChatGPT really going to work for us?

Apr 13, 2023 am 08:19 AM
businesschatgptcode

​Foreword

ChatGPT​ is really very popular recently, and AI services related to ChatGPT are also being researched in full swing. Today we take a look at the application of ChatGPT in coding. Recently we found an IntelliJ IDEA plug-in called "AI Coding Assistant", which integrates ChatGPT technology. Let's see how smart it is and whether it will really work in the future. It is possible that it will replace the work of our programmers.

Plug-in installation

In order to start using the plug-in, you must have an OpenAI token. If you don't know where to find it, you can get it here https://platform.openai.com/account/api-keys on how to register. Baidu and Google have a lot of tutorials.

In addition, download and install the "AI Coding Assistant" plug-in for IntelliJ IDEA:

Oh my god, is ChatGPT really going to work for us?

Figure 1 - "AI Coding Assistant" plug-in in IntelliJ IDEA settings

Try it

  1. Generate the code to print hello world

The first task is a simple one, which is to let it automatically generate and print hello world code.

Oh my god, is ChatGPT really going to work for us?

  1. Generate a pojo

Now you generate a Person class for me.

Oh my god, is ChatGPT really going to work for us?

  1. Now create a function for me to return the generated list of people

Oh my god, is ChatGPT really going to work for us?

  1. After having the person data , we can implement some simple algorithms, such as finding the oldest person in the list, the minimum/maximum/average age of the people in the list

Oh my god, is ChatGPT really going to work for us?

  1. The interesting part of this is that we can ask to update the existing code. Since I know a better way of writing the same algorithm using the Java Stream API, let's try to make it refactor

Oh my god, is ChatGPT really going to work for us?

  1. We can create a function and ask it to generate code based on the meaning of the function name.​

Oh my god, is ChatGPT really going to work for us?

  1. Then you I also added the javadoc

Oh my god, is ChatGPT really going to work for us?

  1. Can you also add comments to my code and explain what this code does? ?​

Oh my god, is ChatGPT really going to work for us?

  1. Finally, let’s take a look at what the final code generated by this AI plug-in looks like?​
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<Person> 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<Person> 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;
}
}

Conclusion

Using AI such as ChatGPT can generate some codes, as shown in the example above, but it is still impossible to face some complex businesses. We can use such tools to help us improve efficiency at work, but don’t worry that they will replace us.

The above is the detailed content of Oh my god, is ChatGPT really going to work for us?. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:51CTO.COM. If there is any infringement, please contact admin@php.cn delete
How to Run LLM Locally Using LM Studio? - Analytics VidhyaHow to Run LLM Locally Using LM Studio? - Analytics VidhyaApr 19, 2025 am 11:38 AM

Running large language models at home with ease: LM Studio User Guide In recent years, advances in software and hardware have made it possible to run large language models (LLMs) on personal computers. LM Studio is an excellent tool to make this process easy and convenient. This article will dive into how to run LLM locally using LM Studio, covering key steps, potential challenges, and the benefits of having LLM locally. Whether you are a tech enthusiast or are curious about the latest AI technologies, this guide will provide valuable insights and practical tips. Let's get started! Overview Understand the basic requirements for running LLM locally. Set up LM Studi on your computer

Guy Peri Helps Flavor McCormick's Future Through Data TransformationGuy Peri Helps Flavor McCormick's Future Through Data TransformationApr 19, 2025 am 11:35 AM

Guy Peri is McCormick’s Chief Information and Digital Officer. Though only seven months into his role, Peri is rapidly advancing a comprehensive transformation of the company’s digital capabilities. His career-long focus on data and analytics informs

What is the Chain of Emotion in Prompt Engineering? - Analytics VidhyaWhat is the Chain of Emotion in Prompt Engineering? - Analytics VidhyaApr 19, 2025 am 11:33 AM

Introduction Artificial intelligence (AI) is evolving to understand not just words, but also emotions, responding with a human touch. This sophisticated interaction is crucial in the rapidly advancing field of AI and natural language processing. Th

12 Best AI Tools for Data Science Workflow - Analytics Vidhya12 Best AI Tools for Data Science Workflow - Analytics VidhyaApr 19, 2025 am 11:31 AM

Introduction In today's data-centric world, leveraging advanced AI technologies is crucial for businesses seeking a competitive edge and enhanced efficiency. A range of powerful tools empowers data scientists, analysts, and developers to build, depl

AV Byte: OpenAI's GPT-4o Mini and Other AI InnovationsAV Byte: OpenAI's GPT-4o Mini and Other AI InnovationsApr 19, 2025 am 11:30 AM

This week's AI landscape exploded with groundbreaking releases from industry giants like OpenAI, Mistral AI, NVIDIA, DeepSeek, and Hugging Face. These new models promise increased power, affordability, and accessibility, fueled by advancements in tr

Perplexity's Android App Is Infested With Security Flaws, Report FindsPerplexity's Android App Is Infested With Security Flaws, Report FindsApr 19, 2025 am 11:24 AM

But the company’s Android app, which offers not only search capabilities but also acts as an AI assistant, is riddled with a host of security issues that could expose its users to data theft, account takeovers and impersonation attacks from malicious

Everyone's Getting Better At Using AI: Thoughts On Vibe CodingEveryone's Getting Better At Using AI: Thoughts On Vibe CodingApr 19, 2025 am 11:17 AM

You can look at what’s happening in conferences and at trade shows. You can ask engineers what they’re doing, or consult with a CEO. Everywhere you look, things are changing at breakneck speed. Engineers, and Non-Engineers What’s the difference be

Rocket Launch Simulation and Analysis using RocketPy - Analytics VidhyaRocket Launch Simulation and Analysis using RocketPy - Analytics VidhyaApr 19, 2025 am 11:12 AM

Simulate Rocket Launches with RocketPy: A Comprehensive Guide This article guides you through simulating high-power rocket launches using RocketPy, a powerful Python library. We'll cover everything from defining rocket components to analyzing simula

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool