Coder Social home page Coder Social logo

java-openai's Introduction

OpenAI with Java

The project demonstrate the integration with Azure OpenAI text-davinci-003 model, Azure Storage Queue using JAVA. The purpose of this repository is to provide a reference point with the Azure OpenAI "text-davinci-003" model serving as an example POC to build a java WebJob or for an independent local run test.

Demo App Architecture

alternativetext

Pre-requisite

  • Azure Open AI service created and text-davinci-003 model deployed
  • Have a Azure Storage source and destination queues created
  • Acquire the below config information and have the needed environment variables setup

How to Run

Build

  • Clone the repo locally
  • Navigate to the cloned directory
  • run "mvn compile" then "mvn package"
  • Running "mvn package" would generate the jar file "openapi-javaapp-1.0.0.jar" under \target directory

Running jar locally

  • Have these environment variable configured that contains the configuration for the azure open AI, azure storage queue
    • AZURE_STORAGE_CONNECTION_STRING
    • AZURE_STORAGE_SOURCE_QUEUE_NAME
    • AZURE_STORAGE_DESTINATION_QUEUE_NAME
    • AZURE_OPEN_API_KEY
    • AZURE_OPEN_API_ENDPOINT
    • AZURE_OPEN_API_MODEL_DEPLOYMENT_NAME
  • Run the jar using "java -jar target\openapi-javaapp-1.0.0.jar", if there's no error and run completes and exits, then the jar content is all good to be deployed as webjob in azure.
  • To see the content of the jar file run "jar -tf target\openapi-javaapp-1.0.0.jar" or extract the jar content locally

Running As WebJob in Azure

Currently EastUSEUAP2 has the code deployed that enables running webjobs on Linux.

  • Create a Java Linux container webapp, please make sure the container, custom or blessed image based have Java 17 + in it, JAVA_HOME environment variables configured, and WEBSITES_ENABLE_APP_SERVICE_STORAGE environment variable set to true for the web app
  • Have the above mentioned environment varialbes configured as app settings
  • Please zip these files "openai-java-webjob-start.sh", "settings.job" and "openapi-javaapp-1.0.0.jar". And deploy the zip file as continuous webjob, either by zip deployment or by calling webjob PUT API, details here https://github.com/projectkudu/kudu/wiki/WebJobs-API

java-openai's People

Contributors

satishranjan avatar jeremywphelps avatar tulikac 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.