page_type | languages | products | urlFragment | name | description | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sample |
|
|
azure-search-openai-demo-java |
ChatGPT + Enterprise data (Java) on App Service, Azure Container Apps, and Azure Kubernetes Service |
A Java sample app that chats with your data using OpenAI and AI Search. |
This repo is the Java version of the well known ChatGPT + Enterprise data code sample originally written in python.
It demonstrates best practices for creating ChatGPT-like experiences over your own data using the Retrieval Augmented Generation pattern. It uses Azure OpenAI Service to access the ChatGPT model gpt-35-turbo
, and Azure Azure AI Search for data indexing and retrieval.
This repository includes sample data so it's ready to try end to end. In this sample application we use a fictitious company called Contoso Electronics, and the experience allows its employees to ask questions about the benefits, internal policies, as well as job descriptions and roles.
What this demo application does:
- Chat and Q&A interfaces
- Explores various options to help users evaluate the trustworthiness of responses with citations, tracking of source content, etc.
- Shows possible approaches for data preparation, prompt construction, and orchestration of interaction between model (ChatGPT) and retriever (Azure AI Search)
- Shows possible AI orchestration implementation using the plain Java Open AI sdk or the Java Semantic Kernel sdk
- Settings directly in the UX to tweak the behavior and experiment with options
This sample supports different architectural styles. It can be deployed as standalone app on top of Azure App Service or as a microservice event driven architecture with web frontend, AI orchestration and document ingestion apps hosted by Azure Container Apps or Azure Kubernetes Service.
- For Azure App Service deployment, see here.
- For Azure Container Apps deployment, see here.
- For Azure Kubernetes Service deployment, see here.
This repo is focused to showcase different options to implement "chat with your private documents" scenario using RAG patterns with Java, Azure OpenAI and Semantic Kernel. Below you can find the list of available implementations.
Conversational Style | RAG Approach | Description | Java Open AI SDK | Java Semantic Kernel |
---|---|---|---|---|
One Shot Ask | PlainJavaAskApproach | Use Azure AI Search and Java OpenAI APIs. It first retrieves top documents from search and use them to build a prompt. Then, it uses OpenAI to generate an answer for the user question.Several search retrieval options are available: Text, Vector, Hybrid. When Hybrid and Vector are selected an additional call to OpenAI is required to generate embeddings vector for the question. | ✅ | ❌ |
Chat | PlainJavaChatApproach | Use Azure AI Search and Java OpenAI APIs. It first calls OpenAI to generate a search keyword for the chat history and then answer to the last chat question.Several search retrieval options are available: Text, Vector, Hybrid. When Hybrid and Vector are selected an additional call to OpenAI is required to generate embeddings vector for the chat extracted keywords. | ✅ | ❌ |
One Shot Ask | JavaSemanticKernelWithMemoryApproach | Use Java Semantic Kernel framework with built-in MemoryStore for embeddings similarity search. A semantic function RAG.AnswerQuestion is defined to build the prompt using Memory Store vector search results.A customized version of SK built-in CognitiveSearchMemoryStore is used to map index fields populated by the documents ingestion process. | ❌ | ✅ |
One Shot Ask | JavaSemanticKernelChainsApproach | Use Java Semantic Kernel framework with semantic and native functions chaining. It uses an imperative style for AI orchestration through semantic kernel functions chaining. InformationFinder.SearchFromQuestion native function and RAG.AnswerQuestion semantic function are called sequentially. Several search retrieval options are available: Text, Vector, Hybrid. | ❌ | ✅ |
One Shot Ask | JavaSemanticKernelPlannerApproach | Use Java Semantic Kernel framework with built-in Planner for functions orchestration. It uses a declarative style for AI orchestration through the built-in SequentialPlanner. SequentialPlanner call OpenAI to generate a plan for answering a question using available skills/plugins: InformationFinder and RAG. Several search retrieval options are available: Text, Vector, Hybrid. |
❌ | ✅ |
Chat | JavaSemanticKernelWithMemoryApproach | Use Java Semantic Kernel framework with built-in MemoryStore for embeddings similarity search. A semantic function RAG.AnswerConversation is defined to build the prompt using Memory Store vector search results. A customized version of SK built-in CognitiveSearchMemoryStore is used to map index fields populated by the documents ingestion process. | ❌ | ✅ |
Chat | JavaSemanticKernelChainsApproach | Use Java Semantic Kernel framework with semantic and native functions chaining. It uses an imperative style for AI orchestration through semantic kernel functions chaining. InformationFinder.SearchFromConversation native function and RAG.AnswerConversation semantic function are called sequentially. Several search retrieval options are available: Text, Vector, Hybrid. | ❌ | ✅ |
The plain Java Open AI sdk based implementations are stable. Java Semantic Kernel based implementations are still experimental and it will be consolidated as soon as Java Semantic Kernel GA version will be released. Below a brief description of the SK integration status:
RAG Approach | Status |
---|---|
JavaSemanticKernelWithMemoryApproach | ✅ |
JavaSemanticKernelChainsApproach | ✅ |
JavaSemanticKernelPlannerApproach | ❌ This approach is currently disabled within the UI, pending fixes for this feature |