Skip to content

An example application that demonstrates how use Retrieval Augmented Generation with Azure OpenAI

Notifications You must be signed in to change notification settings

rd-1-2022/ai-azure-retrieval-augmented-generation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring AI Retrieval Augmented Generation with Azure OpenAI

This project contains a web service that will accept HTTP GET requests at http://localhost:8080/ai/rag

There is optional message parameter whose default value is "What bike is good for city commuting?".

The response to the request is from the Azure OpenAI Service.

Building and running

./mvnw spring-boot:run

Access the endpoint

To get a response to the default request of "What bike is good for city commuting?"

http http://localhost:8080/ai/rag

A sample response is

{
  "info": {},
  "text": "Both the SwiftRide Hybrid and the AgileEon 9X are good options for city commuting, as they are designed for daily commutes and recreational rides. They both have efficient electric assist, integrated lights, and components that provide a comfortable and reliable cycling experience. Ultimately, the choice depends on your personal preferences and needs."
}

Now using the message request parameter to ask about a specific bike.

$  http GET localhost:8080/ai/rag message=="Tell me some details about the SwiftRide Hybrid"

A sample response is

{
    "info": {},
    "text": "The SwiftRide Hybrid is a versatile and efficient bike designed for riders who want a smooth and enjoyable ride on various terrains. It features a lightweight and durable aluminum frame, a powerful electric motor that offers a speedy assist, a removable and fully-integrated 500Wh battery, a 10-speed Shimano drivetrain, hydraulic disc brakes for precise stopping power, wide puncture-resistant tires for stability, and integrated lights for enhanced visibility. The bike is priced at $3999.99."
}

Prerequisite

Obtain your Azure OpenAI endpoint and api-key from the Azure OpenAI Service section on Azure Portal

The Spring AI project defines a configuration property named spring.ai.azure.openai.api-key that you should set to the value of the API Key obtained from Azure

Exporting an environment variables is one way to set these configuration properties.

export SPRING_AI_AZURE_OPENAI_API_KEY=<INSERT KEY HERE>
export SPRING_AI_AZURE_OPENAI_ENDPOINT=<INSERT ENDPOINT URL HERE>

About

An example application that demonstrates how use Retrieval Augmented Generation with Azure OpenAI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published