fecc82 / spring-openai-bot

Spring Boot + OpenAI sample application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spring Boot OpenAI Bot

Sample application showing how to use Spring Boot with OpenAI's GPT-3 API.

This is a fully reactive application that uses Spring WebFlux and the OpenAI streaming API, that can be packaged as a GraalVM native image.

Features

  • Spring Boot 3
  • Fully reactive with Spring WebFlux and Spring WebClient
  • OpenAI streaming API
  • Native image with GraalVM
  • Deployment to Azure Container Apps

Getting Started

Prerequisites

  • Java 17
  • Access to OpenAI's GPT-3 API

Installation

./mvnw package

Quickstart

You will need to set the following environment variables to access OpenAI's API:

export APPLICATION_OPENAI_KEY=<your-openai-api-key>
export APPLICATION_OPENAI_URL=<your-openai-url>

Demo

./mvnw spring-boot:run

Resources

To customize the OpenAI prompt, you can check the following resource:

About

Spring Boot + OpenAI sample application

License:MIT License


Languages

Language:Java 61.6%Language:Shell 32.4%Language:Dockerfile 5.9%