SEOSEO News

ChatGPT-4 Capabilities: The Magic of AI / Blogs / Perficient


Openai Avatar

Introduction

If you haven’t heard, OpenAI released ChatGPT-4, the successor in a computational sense to GPT-3. Although slower at the moment, its capabilities have improved immensely. How much, you may ask? Well that is what I’m here to tell you. For context, I will be throwing some of the same questions at it I threw at GPT-3 in my previous blog post, so check that out if you’re curious. Starting just like last time, hey GPT! Describe yourself and how you could help consultants.

ME: Hey GPT, how would you explain yourself to a consulting agency in 4 sentences, focusing on how you could add value to technical and business consultants?

— GPT-3 —

Hello! I am a large language model trained by OpenAI. I am able to generate human-like text based on a given prompt or context. I can assist technical and business consultants by providing accurate and relevant information on a wide range of topics, as well as by generating reports, summaries, and other written materials. Additionally, I can help with data analysis and research, allowing consultants to save time and focus on their core competencies. Overall, I can add value to consulting agencies by providing high-quality, reliable support for their work.

— GPT-4 —

As a cutting-edge AI language model, I can quickly and accurately analyze large volumes of data and generate actionable insights, significantly increasing consultants’ efficiency and effectiveness. My ability to understand complex concepts and communicate them in simple, digestible terms enables consultants to deliver high-quality presentations and reports to clients. Furthermore, I can automate routine tasks such as data entry, research, and scheduling, allowing consultants to focus on strategic problem-solving and relationship-building. My versatility, scalability, and continuous learning capabilities can help your consulting agency stay ahead of the curve, adapt to industry trends, and deliver superior value to clients.

Notice first that GPT-4 is following my exact instructions. GPT-3 gave me 5 sentences, 6 if you count “Hello!”. GPT-4 got straight to the point, and only output 4. It also sounds like a consultant already!

GPT-4 Codes Anything

I asked GPT-3 to tell us about a for-loop. It gave an excellent description and examples that were accurate and useful. GPT-4 will be able to do something far more incredible. GPT-3 was limited in that it could only remember about 3,000 words. GPT-4 can remember 25,000. This means that you could paste large swaths of a project into it, and get back highly specific and relevant results for additional queries. Additionally, GPT-4 is much better at complex reasoning. So watch this:

ME: What version of Next.js are you familiar with?

GPT-4: At the time of my last training update in September 2021, Next.js 11 was the latest stable version.

ME: So you don’t know about the App directory, or server components.

GPT-4: React server components, in the experimental phase during my training, allow server-rendered architecture for better performance and lower bundle sizes. The App directory refers to the folder structure in React or Next.js projects, organizing components, pages, and resources.

While it has a hunch about how Next.js will enable server-side components, it has no clue about the App directory, giving us a generic description of what an app folder might contain if it was in a project. So watch this right here. I now paste the entire documentation for the app directory, plus the blog announcement for Next 13 into the chat. And then I ask this:

ME: So what is the app directory and what are server side components in next 13

GPT-4: In Next.js 13, the app directory is introduced to improve the organization of your application and make it easier to adopt Server Components. All components inside the app directory are React Server Components by default. This allows you to automatically adopt Server Components with no extra work and achieve great performance out of the box.

React Server Components allow developers to better leverage server infrastructure. With Server Components, the initial page load is faster, and the client-side JavaScript bundle size is reduced. They enable you to keep large dependencies, sensitive information, and direct access to backend resources on the server side, resulting in improved performance for your application.

Server Components make writing a React application feel similar to PHP or Ruby on Rails but with the power and flexibility of React for templating UI. When a route is loaded with Next.js, the initial HTML is rendered on the server and then progressively enhanced in the browser. This allows the client to take over the application and add interactivity by asynchronously loading the Next.js and React client-side runtime.

In summary, the app directory is a new way to organize your Next.js application, making it easier to adopt Server Components, which are components that leverage server infrastructure for improved performance and flexibility.

Incredible. It was able to read and summarize the blog and documentation to answer my question.

Advanced Comprehension

Movie Summary

The best but perhaps most subtle change in GPT-4 is how well it can understand context and connect similar ideas. I pasted the Wikipedia entry on a movie released in 2022 and ask them to summarize it. I asked them both beforehand and confirmed: they did not train on this movie.

ME: Summarize the plot of Doctor Strange: Multiverse of Madness

GPT-3: In Doctor Strange: Multiverse of Madness, America Chavez and a version of Stephen Strange travel through different universes searching for the Book of Vishanti while being pursued by demons. They end up on Earth-616 where they seek the help of Wanda Maximoff, who is revealed to be behind the attacks. Maximoff has been using the Darkhold to control Chavez’s powers in order to reunite with her children, but Strange and Chavez team up to stop her, resulting in a multiverse-shaking showdown. The film ends with the surviving sorcerers continuing to train and Strange developing a third eye as a result of using the Darkhold.

This summary reveals one of GPT-3’s biggest weaknesses: relevance. That America had been traveling with another Doctor Strange is true, but impacts the story in almost no capacity. Additionally, it is confusing to mention Earth-616 as a destination they reach when that is actually our earth, the one where all movies have taken place so far. Let’s look at what GPT-4 said.

GPT-4: Doctor Strange: Multiverse of Madness follows the journey of America Chavez and Doctor Strange as they navigate the multiverse, seeking the Book of Vishanti to counter the destructive effects of the Darkhold. Along the way, they face a powerful and misguided Wanda Maximoff, who seeks to control Chavez’s powers in order to reunite with her children. Strange and Chavez, with the help of allies, manage to confront and redeem Maximoff, ultimately destroying all copies of the Darkhold across the multiverse. The film ends with the surviving sorcerers rebuilding Kamar-Taj and continuing their training, while Strange faces new challenges in the form of an impending incursion.

Even if you have not seen this movie, I can tell you this summary is much better. Besides being more technically accurate, this summary also gives a sense of the true character tension and struggle that the film will show. It also mentions details that actual matter, and leaves out ones that do not, like Doctor Strange developing a third eye.

PBI Writing

How about a more pertinent example? You need to write up a PBI. There is a component that shifts the page content when hovered over and it should not. Additionally, the component cannot be reached by the keyboard, it seems to get skipped over. Even worse, your WCAG developer is out for the week, and the rest of the team typically struggles to know where to start on ADA issues.

ME: I need a PBI written up. There is a component that shifts page content when hovered over it, and it should not. It also is not reachable by keyboard navigation. Write up the problem, and include acceptance criteria phrased in questions that can be answered with yes or no. Also, include in the description some possible reasons it may not be keyboard accessible. This will help investigation into solving the issue.

GPT-3:

Problem:

When hovering over a component on the page, the page content shifts, which is an unintended behavior. Additionally, the component is not reachable by keyboard navigation.

Description:

The component is likely not keyboard accessible because it may be missing an appropriate tabindex attribute, or the role attribute may not be set to a proper value. Another possibility is that the component is implemented using non-semantic markup such as div or span elements instead of using the appropriate semantic elements such as button or input.

Acceptance Criteria:

  1. Does the component stay in place when hovered over? (Yes/No)
  2. Is the component reachable by keyboard navigation? (Yes/No)
  3. Does the component have a proper tabindex attribute? (Yes/No)
  4. Is the component implemented using the appropriate semantic markup such as button or input? (Yes/No)
  5. Does the component have a proper role attribute set? (Yes/No)

This is…a start. I’d say this probably saves you only seconds of time, and AC #3 is concerned about implementation, which was not a specified concern and oversteps our ask.

GPT-4:

Title: Fix Component Hover-Shift Behavior and Ensure Keyboard Accessibility

Problem Description: We have identified a component within our application that exhibits an undesired behavior: when a user hovers their cursor over it, the page content shifts unexpectedly. In addition to this, the component is not reachable through keyboard navigation, which raises accessibility concerns.

Possible reasons for the lack of keyboard accessibility could include:

  1. The component might not have a proper tabindex value assigned, or it might have a negative tabindex, causing it to be skipped during tabbing.
  2. The component may be implemented using a non-interactive element (e.g., a div or span), which does not receive focus by default.
  3. The component’s JavaScript event handlers might not be listening for or correctly handling keyboard events, such as ‘keydown’ or ‘keyup’.
  4. There might be a CSS rule that is inadvertently hiding the component or making it non-interactive when accessed through keyboard navigation.

Acceptance Criteria: The following questions should be answered with a ‘yes’ or ‘no’ to determine whether the issue has been resolved:

  1. Does the component no longer cause the page content to shift when the user hovers their cursor over it?
  2. Is the component now reachable and interactive through keyboard navigation, specifically by using the ‘Tab’ key?
  3. Can the user interact with the component using the ‘Enter’ and/or ‘Space’ keys, as appropriate for the type of component?
  4. Does the component exhibit a visible focus state when accessed via keyboard navigation, indicating that it is currently the active element?

Upon addressing the issues described, the component should no longer exhibit any undesired shifting behavior and should be fully accessible through keyboard navigation.

Oh my. I might just paste this straight in and send the PBI off! Not only is the language much more professional and detailed, GPT-4 even comprehends proper accessibility rules and incorporates them in the AC. Notice too, how GPT-4 provides a title as well, which even though I did not request it, is obviously going to be part of any PBI.

GPT-4, The Sitecore Architect

I once built a client a custom field that involved lots of custom Javascript, HTML, and styling. Figuring out a way to inject the whole thing into a page item in Sitecore took some time. While I wrote a blog on that whole process here, why not ask GPT and see what happens? Given a vague and rather open-ended query, GPT-3 responded:

ME: I want to inject a custom javascript/html component into the fields section on a page item in sitecore. I’ll write some custom functionality using javascript, and when the user is done interacting with it I want it to save the data to a text field when the user presses a button. How would I go about doing this?

GPT-3

To inject a custom JavaScript/HTML component into a Sitecore page item’s fields section, you will need to create a custom field type in Sitecore. Here are the steps to create a custom field type:

  1. Create a new Sitecore item under the /sitecore/system/Field types node in the content tree. This item will represent your custom field type.
  2. In the item’s Control field, specify the path to your JavaScript/HTML component.
  3. Create a new class that inherits from the Sitecore.Data.Fields.FieldControl class. This class will be responsible for rendering your custom component in the fields section.
  4. Override the GetControl() method to return an instance of your JavaScript/HTML component.
  5. Implement the necessary logic in your JavaScript code to interact with the Sitecore API and save the data to the text field when the user clicks the save button.
  6. Finally, add your custom field type to the template of the page item where you want to use it.

Once you have completed these steps, your custom field type should be available in the fields section of the page item, and the data entered by the user should be saved to the text field when the user clicks the save button.

That’s…doing something. It certainly isn’t the whole thing, and I’m not sure where exactly the Javascript I talked about went. Well, GPT-4 saves me a week:

GPT-4

To inject a custom JavaScript/HTML component into the fields section on a page item in Sitecore, you need to create a custom Sitecore field type. Here’s a step-by-step guide to help you achieve this:

  1. Create a new class for the custom field type:

Create a new class that inherits from Sitecore.Shell.Applications.ContentEditor.Text, which represents a text field in Sitecore. Add a reference to Sitecore.Kernel.dll if required.

using Sitecore.Shell.Applications.ContentEditor;

public class CustomJSComponentField : Text
{
     // We will add the implementation here.
}

 

  1. Override the DoRender method:

Override the DoRender method to add your custom HTML and JavaScript to the field rendering.

protected override void DoRender(HtmlTextWriter output)
{
    // Call the base DoRender method to render the default text field.
    base.DoRender(output);// Add your custom HTML/JS component.
    output.Write("<div id='custom-component'></div>");
    output.Write("<script src="
}

 

  1. Register the custom field type:

In your Sitecore solution, find the /App_Config/FieldTypes.config file, and add the new custom field type to the <fieldTypes> section.

xml

<fieldType name="CustomJSComponentField" type="YourNamespace.CustomJSComponentField, YourAssembly" />

Replace “YourNamespace” and “YourAssembly” with the appropriate values for your solution.

  1. Create a new Template Field:

In Sitecore, create a new template field and set its type to CustomJSComponentField. This will make your custom field type available for use in your templates.

  1. Implement the custom JavaScript functionality:

Create a custom-script.js file with your custom functionality. For example:

document.addEventListener("DOMContentLoaded", function () {
     const textField = document.querySelector(".scContentControl");
     const customComponent = document.getElementById("custom-component");
     const saveButton = document.createElement("button");saveButton.innerText = "Save";
     customComponent.appendChild(saveButton);// Add your custom logic here.

     saveButton.addEventListener("click", function () {
          // Save the data to the text field.
          textField.value = "Your data to save";
      });
});

 

This script adds a “Save” button to your custom component, and when the user clicks on it, it saves the data to the text field. Update the script to include your custom functionality as needed.

Once you’ve completed these steps, the custom JavaScript/HTML component should be injected into the fields section on a page item in Sitecore. When the user interacts with your custom component and presses the “Save” button, the data will be saved to the text field.

If you don’t have time to read the other blog I’ll tell you — it is correct about these steps, it’s almost exactly what I had to do. All of that, based on one paragraph. It’s magic.

Closing

GPT-3 was already an incredible and world-changing tool, GPT-4 continues along that path. The additional complexity of tasks and context it can handle allow for even more improvements in daily workflow. If you don’t use it yet, I cannot recommend it enough.

Bonus Round

I’ve pasted in this article into GPT-4, and I’ve asked it to give me a meta description and focus key phrase.

Meta Description: Discover the impressive capabilities of ChatGPT-4, the successor to GPT-3, and see how its improved performance is nearly magical

Focus Key phrase: ChatGPT-4 Capabilities

And yes, I used them. That’s all for now, check back in for my next post on more tricks and efficiencies with ChatGPT!





Source link

Related Articles

Back to top button
error

Enjoy Our Website? Please share :) Thank you!