DEV Community

Cover image for Gemini-1.5-pro Function Calling with Java, Spring and HTTP
vishalmysore
vishalmysore

Posted on

2 1 1 1 1

Gemini-1.5-pro Function Calling with Java, Spring and HTTP

Tools4AI, an open-source stands out for integrating AI into Java enterprise applications seamlessly. At its core, it’s a Java-built project that introduces a Large Action Model (LAM) or an LLM agent. This design is perfect for developers looking to add AI features into their Java applications efficiently.

A key feature of Tools4AI is its compatibility with Gemini-1.5-Pro, which is all about making it easier to invoke Java methods, perform REST HTTP calls, or execute shell scripts directly in response to natural language prompts. The beauty of this system lies in its simplicity: by using straightforward annotations, developers can designate which actions the AI should execute in response to specific prompts. Actions are picked automatically by the AI system

@Predict(actionName = "addBook",description = "add new book")
Enter fullscreen mode Exit fullscreen mode

This means you can now have an application that listens to natural language commands and carries out complex tasks, such as calling a particular Java method, making a web service request, or running a script, without the need for cumbersome coding. It’s as straightforward as annotating methods in your codebase, and Tools4AI takes care of understanding the prompts and triggering the correct responses.

  GeminiV2ActionProcessor processor = new GeminiV2ActionProcessor();
        String postABook = "post a book harry poster with id 189 the publish date is 2024-03-22 and the description is about harry who likes poster its around 500 pages  ";
        String result = (String)processor.processSingleAction(postABook);
        Assertions.assertNotNull(result);
        String success = TestHelperOpenAI.getInstance().sendMessage("Look at this message - "+result+" - was it a success? - Reply in true or false only");
        log.debug(success);
        Assertions.assertTrue("True".equalsIgnoreCase(success));
Enter fullscreen mode Exit fullscreen mode

For developers, this translates into a powerful way to make Java applications more interactive and autonomous. Imagine creating an app that processes user requests in plain language to fetch data, run analyses, or even interact with other applications and services, all facilitated by simple annotations. This approach not only makes software development more efficient but also opens up new avenues for creating dynamic, responsive applications that can automate tasks, streamline workflows, and offer users a more intuitive interaction model.

Code for the above example is here

Tools4AI’s support for calling Java methods, making REST calls, and executing shell scripts based on natural language inputs is a game-changer, simplifying the way AI can be utilized within Java environments. It embodies a practical step towards making AI a hands-on tool for developers, enhancing the capabilities of Java applications without adding complexity to the development process.

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more