Cookie Consent by Free Privacy Policy Generator 📌 How to Build an OpenAI GPT Agent in less than 15 mins


✅ How to Build an OpenAI GPT Agent in less than 15 mins


💡 Newskategorie: Programmierung
🔗 Quelle: dev.to

Overview

Using Tools4AI function calling (tools integration) with OpenAI is simple and efficient. When a user provides a prompt, Tools4AI dynamically determines which group the prompt belongs to, using AI. Then, it calls the action associated with that group. In under 10 minutes, you can kickstart your journey to developing an autonomous agent in Java by leveraging the power of OpenAI. All you need is your OpenAI key and, of course, a refreshing cup of coffee (or tea) .
Let's illustrate this with examples :

Example:

Java Code

These 2 lines of code will take the prompt as input and trigger the action related to the prompt illustrate this with examples :

 OpenAiActionProcessor processor = new OpenAiActionProcessor(gson);
        String result = (String)processor.processSingleAction(prompt,new LoggingHumanDecision(),new LogginggExplainDecision());

Configuring actions :
Actions can be http rest calls

{
  "endpoints" : [
    {
      "swaggerurl": "https://fakerestapi.azurewebsites.net/swagger/v1/swagger.json",
      "group": "Books and Authors",
      "description": "Actions related to books, authors, photos, and users",
      "baseurl": "https://fakerestapi.azurewebsites.net/",
      "id": "fakerestapi"
    },
    {
      "swaggerurl": "https://petstore3.swagger.io/api/v3/openapi.json",
      "baseurl": "https://petstore3.swagger.io/",
      "group": "Pets",
      "description": "Actions related to pets",
      "id": "petstore"
    }
  ]
}

How it Works:

User Prompt: A user submits a prompt, such as "Recommend a book on artificial intelligence."
Group Identification: Tools4AI analyzes the prompt using AI. It dynamically determines which group the prompt belongs to based on its content. For example, it identifies the prompt as related to books and authors. and there are http rest calls associated with it.
Action Invocation: Once the group is identified (e.g., "Books and Authors"), Tools4AI calls the corresponding action associated with that group. (all the rest calls associated associated in that group are eligible for function calling ) In this case, it might call a GET action to recommend a book on artificial intelligence. Tools4AI would execute the appropriate HTTP REST call associated with this group, such as "getBook" or "getAuthor," with parameters tailored to the request, which could be either simple parameters in the request or more complex JSON requests.
**Parameter Derivation: **Tools4AI extracts any necessary details from the prompt itself. For instance, it identifies "artificial intelligence" as the topic for the book recommendation.

To read about Kubernetes and AI integration click here

Java Actions:
Actions can be written in Java

@Predict(groupName = "customer support", groupDescription = "actions related to customer support")
public class ComplexAction  {

    @Action
    public String computerRepair(Customer customer) {
        return customer.toString();
    }
}

Actions can be categorized in groups

@Predict( groupName = "customer support", groupDescription = "actions related to customer support")
public class CustomerQueryAction {

   @Action
    public String customerQuery(String query) {
        // Process the customer query and provide assistance
        return "Thank you for reaching out! Here's some assistance with your query: " + query;
    }
} 

Additional information can shared with annotations

 public String computerRepairWithDetails(Customer customer, @Prompt(dateFormat = "yyyy-MM-dd") Date dateOfComp , @Prompt(describe = "this is customer complaint") String query) {
        return customer.toString();
    }

Annotations can be applied to parameters, method or class , above annotations tells AI to put the customer complaint in the query parameter ( this is optional if the name is not very clear

public class Customer {
    private String firstName;
    private String lastName;
    private String reasonForCalling;
    private String location;
    @Prompt(dateFormat = "yyyy-MM-dd")
    private Date dateJoined;
} 

The above annotation will tell AI to convert the date from prompt into specific format

  • @Prompt(dateFormat = "yyyy-MM-dd") Date dateOfComp: This parameter is annotated with @Prompt, indicating special processing is required to populate this argument. The dateFormat attribute suggests that any date information extracted from the prompt should be formatted according to the specified pattern ("yyyy-MM-dd"). The type of the parameter is Date, implying that the extracted text should represent a date.

  • @Prompt(describe = "this is customer complaint") String query: Another use of the @Prompt annotation, this time without a specific format but with a description hinting at its purpose. The parameter is expected to hold the customer's complaint or query about their computer issue. The describe attribute could be used for documentation or to assist in parsing logic, indicating that the content of this string is the customer's complaint.

Explanation:

  • This new Java class CustomerQueryAction is annotated with @Predict, indicating that it represents an action within the "customer support" group.
  • The customerQuery method within this class accepts a String parameter representing the customer's query.
  • Inside the customerQuery method, the query is processed, and assistance is provided accordingly.
  • Upon receiving a prompt related to customer queries, Tools4AI will dynamically call the customerQuery method within the CustomerQueryAction class.
  • With this additional class, you now have another action within the "customer support" group, allowing for more comprehensive support functionalities within your Java application powered by Tools4AI .

Spring integration click here

Creating Different Action Group

@Predict( groupName = "recipe generator", groupDescription = "actions related to recipe generation")
public class RecipeGenerationAction  {

  @Action
    public String generateRecipe(String cuisine, int servings) {
        // Generate a recipe based on the provided cuisine and servings
        return "Here's a delicious " + cuisine + " recipe for " + servings + " servings: ...";
    }
}

Explanation:

  • Java class RecipeGenerationAction is annotated with @Predict, indicating that it represents an action within the "recipe generator" group.
  • The generateRecipe method within this class accepts parameters such as the desired cuisine and servings.
  • Inside the generateRecipe method, a recipe is generated based on the provided cuisine and servings.
  • Upon receiving a prompt related to recipe generation, Tools4AI will dynamically call the generateRecipe method within the RecipeGenerationAction class.

Now, you have an action within the "recipe generator" group, allowing you to dynamically generate recipes based on user preferences within your Java application powered by Tools4AI.

Generate a recipe for Italian cuisine for 4 servings.

This prompt specifies the cuisine ("Italian") and the number of servings ("4"). When Tools4AI processes this prompt, it would recognize it as a request for recipe generation and call the generateRecipe method within the RecipeGenerationAction class, passing "Italian" as the cuisine and 4 as the number of servings. The action would then generate a recipe tailored to Italian cuisine for 4 servings and return the result to the user

Script Configuration Example:
Actions could be scripts ( shell, python , groovy)

groups:
  - name: Employee Actions
    description: This includes actions for all new employees
    scripts:
      - scriptName: "test_script.cmd"
        actionName: saveEmployeeInformation
        parameters: employeeName, employeeLocation
        description: This command saves employee information

      - scriptName: "C:\\another\\path\\to\\ps_issue.cmd"
        actionName: raiseTicketForProductionIssue
        parameters: applicationName, typeOfIssue, issueDetails
        description: This script raises a ticket for a production issue in an application

  - name: Enterprise Actions
    description: This includes actions for all enterprise-related applications
    scripts:
      - scriptName: "D:\\scripts\\run_backup.sh"
        actionName: runBackup
        parameters: backUpReason, typeOfBackup, details, personWhoInitiated
        description: This script performs a backup of the database

Explanation:
Groups: Scripts are organized into different groups based on their intended purposes.

  • Employee Actions:
  • Enterprise Actions: Key Features: Organization: Scripts are organized into meaningful groups based on their functionalities, making it easier for developers to locate and manage them. Description: Each group and script is accompanied by a description, providing additional context and clarity about their purposes. Parameter Specification: Scripts specify the parameters they require, allowing for clear communication of input expectations.

In summary, Tools4AI enables the organization and management of shell scripts into different groups, facilitating the seamless integration of shell-based actions into various workflows within the enterprise environment.

...

✅ How to Build an OpenAI GPT Agent in less than 15 mins


📈 69.2 Punkte

✅ OpenAI Debuts GPT-4 Turbo That's 'More Powerful' and Less Expensive Than GPT-4


📈 42.57 Punkte

✅ OpenAI: Keine Suche, kein GPT-5, aber GPT-4o für ChatGPT und GPT-4


📈 35.82 Punkte

✅ OpenAI teases updated GPT-4 Turbo, less “lazy” than before; other new models and lower pricing


📈 33.3 Punkte

✅ GPT-6 SHOCKS Everyone With NEW ABILITIES! (GPT5, GPT-6, GPT-7) Document Reveals ALL!


📈 27.82 Punkte

✅ What does GPT stand for? Understanding GPT 3.5, GPT 4, and more


📈 27.82 Punkte

✅ Updates für GPT-3 und GPT-4: GPT im Geschwindigkeitsrausch


📈 27.82 Punkte

✅ 10 Secret GPT-4 Tips And Tricks (How To Use GPT-4)(GPT-4 Tutorial)


📈 27.82 Punkte

✅ Build a Documentation Website with Gatsby in 10 Mins


📈 26.93 Punkte

✅ OpenAI unveils a 'less lazy' GPT-4 Turbo, price drops, plus new and updated models


📈 26.84 Punkte

✅ GPT-Auslese: Die besten Tools aus dem OpenAI GPT Store


📈 26.55 Punkte

✅ OpenAI slashes GPT-3.5 Turbo's cost as it prepares to ship GPT-4 Turbo with vision


📈 26.55 Punkte

✅ OpenAI's GPT Store Is NOW LIVE (GPT Store Tutorial)


📈 26.55 Punkte

✅ Gemini Ultra vs GPT 4: How Google Gemini beats OpenAI GPT-4 in most benchmarks


📈 26.55 Punkte

✅ Azure OpenAI Service gain GPT-4 Turbo and GPT-3.5 Turbo


📈 26.55 Punkte

✅ OpenAI is training GPT-4's successor. Here are 3 big upgrades to expect from GPT-5


📈 26.55 Punkte

✅ OpenAI’s GPT Builder: 4 Step How To + Top 10 GPT AI Apps 2023


📈 26.55 Punkte

✅ OpenAI is training a GPT-4 successor (GPT-5?) and establish a safety committee


📈 26.55 Punkte

✅ Sam Altman zu GPT-5: OpenAI trainiert derzeit keinen GPT-4-Nachfolger


📈 26.55 Punkte

✅ OpenAI’s GPT-4 is now available with significant improvements from GPT-3.5


📈 26.55 Punkte

✅ OpenAI zeigt Omnimodel: Keine Suche, kein GPT-5, aber GPT-4o für ChatGPT


📈 26.55 Punkte

✅ Using a JSON Agent with LangChain, LangSmith and OpenAI’s GPT-4o


📈 26.26 Punkte

✅ Multi AI Agent Systems using OpenAI's new GPT-4o Model


📈 26.26 Punkte

✅ Apple To Charge Developers 15% Less If Their App Earns Less Than $1M


📈 25.58 Punkte

✅ Custom GPTs: How to create a GPT for your SaaS in less than 20 minutes


📈 25.29 Punkte

✅ Build your AI Travel Agent with GPT-4o using Python


📈 23.24 Punkte











matomo

Datei nicht gefunden!