GithubHelp home page GithubHelp logo

luanldt / chatgpt-spring-boot-starter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from flashvayne/chatgpt-spring-boot-starter

0.0 0.0 0.0 24 KB

a chatgpt starter based on Openai Official Apis.

License: MIT License

Java 100.00%

chatgpt-spring-boot-starter's Introduction

Maven central

中文版文档

chatgpt-spring-boot-starter

Use chatgpt in springboot project easily.
This starter is based on Openai Official Apis.

Usage

1.Add maven dependency.

<dependency>
    <groupId>io.github.flashvayne</groupId>
    <artifactId>chatgpt-spring-boot-starter</artifactId>
    <version>1.0.1</version>
</dependency>

2.Set chatgpt properties in your application.yml

chatgpt:
  api-key: xxxxxxxxxxx   #your api-key. It can be generated in the link https://platform.openai.com/account/api-keys
# some properties as below have default values. Of course, you can change them.
#  max-tokens: 300           # The maximum number of tokens to generate in the completion.The token count of your prompt plus max_tokens cannot exceed the model's context length. Most models have a context length of 2048 tokens (except for the newest models, which support 4096).
#  model: text-davinci-003   # GPT-3 models can understand and generate natural language. We offer four main models with different levels of power suitable for different tasks. Davinci is the most capable model, and Ada is the fastest.
#  temperature: 0.0          # What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer.We generally recommend altering this or top_p but not both.
#  top-p: 1.0                # An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.We generally recommend altering this or temperature but not both.

3.Inject bean ChatgptService anywhere you require it, and invoke its method to send message to chatgpt and get the response.

@Autowired
private ChatgptService chatgptService;

public void test(){
    String responseMessage = chatgptService.sendMessage("how are you");
    System.out.print(responseMessage); //I'm doing well, thank you. How about you?
}

Demo project:

demo-chatgpt-spring-boot-starter

Demo online experience

https://vayne.cc/chat/

*This demo does not work now, because my account's request times quota is exceeded.
You can use your own account api-key to let your demo work.

Author Info

Email: [email protected]

Blog: https://vayne.cc

chatgpt-spring-boot-starter's People

Contributors

flashvayne 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.