Git Product home page Git Product logo

chatgpt's Introduction

Java Client for the ChatGPT

Repository size GitHub last commit License GitHub Pull Requests Stargazers Stargazers

This is a Java library that provides a simple way to integrate with the ChatGPT API. ChatGPT is an API that provides a conversational interface powered by GPT-3 to allow developers to build chatbots and conversational apps.

Installation

To use this library in your Java project, you can download it from Maven Central. Add the following dependency to your pom.xml file:

<dependency>
    <groupId>com.jjeanjacques</groupId>
    <artifactId>chatgpt</artifactId>
    <version>1.0.1</version>
</dependency>

Configuration

  1. Set the property chatgpt.apikey in your application.properties file:
chatgpt:
  apikey: <your_api_key>
  1. Enable the @EnableChatGpt annotation in your Spring Boot application:
@SpringBootApplication
@EnableChatGpt
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

Usage

To use the Java client for the ChatGPT, you need to create an instance of the ChatGpt class and provide your ChatGPT API Key (https://platform.openai.com/account/api-keys):

ChatGpt chatGPT = new ChatGpt();

Example of a simple chat:

chatGPT.chat("Hello!").getChoices().stream()
                .forEach(r -> System.out.println(r.getMessage().getContent()));
// Hello there! How can I assist you today?

Example of image creation:

chatGPT.image("A cute dinosaur coding a software")
        .forEach(i -> System.out.println(i.getUrl()));
// https://oaidalleapiprodscus.blob.core.windows.net/private/org-QC0lwWtCkWNqeRzkUrYNkm1S/user-btJ8VtoIdwu85D1FG8P257jy/img-1QxpNWqFsRqEn7cOAC0uuZJV.png?st=2023-03-09T22%3A47%3A25Z&se=2023-03-10T00%3A47%3A25Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-03-09T19%3A40%3A03Z&ske=2023-03-10T19%3A40%3A03Z&sks=b&skv=2021-08-06&sig=1va/vGtJ7MJPMneuoPq8NbSF2UBOvDE5204uhnuHXfY%3D
// https://oaidalleapiprodscus.blob.core.windows.net/private/org-QC0lwWtCkWNqeRzkUrYNkm1S/user-btJ8VtoIdwu85D1FG8P257jy/img-jdNelbeJ5Elwl6tKcjt3vCyK.png?st=2023-03-08T00%3A26%3A52Z&se=2023-03-08T02%3A26%3A52Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-03-07T21%3A42%3A09Z&ske=2023-03-08T21%3A42%3A09Z&sks=b&skv=2021-08-06&sig=Q3IbxDFP4Pp1nf8fCmgxVW9CxCPA00E4TyIKrWpd8fM%3D

Support

If you encounter any issues or have any questions about this library, please open an issue on GitHub.

License

This library is released under the MIT License.

chatgpt's People

Contributors

jjeanjacques10 avatar

Stargazers

João Vidal avatar Lucas Batista da Silva avatar  avatar Larissa Soares avatar Gabriel Petillo avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.