Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add semantic kernel vector store approaches #106

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

milderhc
Copy link
Contributor

@milderhc milderhc commented Dec 4, 2024

Purpose

  • Adding vector store functionality to the Ask and Chat sections. Using hybrid search + semantic ranker, query captions are not available as the semantic kernel maps the documents and returns them without that extra info.
  • Updated Azure AI Search SDK version

Does this introduce a breaking change?

[ ] Yes
[x] No

Pull Request Type

What kind of change does this Pull Request introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

How to Test

  • Get the code
git clone [repo-address]
cd [repo-name]
git checkout [branch-name]
npm install
  • Test the code

What to Check

Verify that the following are valid

  • ...

Other Information

@milderhc milderhc requested a review from brunoborges as a code owner December 4, 2024 22:09
String indexName;

@Value("${openai.chatgpt.deployment}")
private String gptChatDeploymentModelId;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not required. we can delete this

private String gptChatDeploymentModelId;

@Value("${openai.embedding.deployment}")
private String embeddingDeploymentModelId;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not required. we can delete this

@Value("${cognitive.search.index}")
String indexName;
@Value("${openai.chatgpt.deployment}")
private String gptChatDeploymentModelId;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not required. we can delete this.

@Value("${openai.chatgpt.deployment}")
private String gptChatDeploymentModelId;
@Value("${openai.embedding.deployment}")
private String embeddingDeploymentModelId;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not required. we can delete this.

Kernel semanticKernel = buildSemanticKernel();

// STEP 1: Create Azure AI Search client
SearchIndexAsyncClient client = new SearchIndexClientBuilder()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this instance configuration in com.microsoft.openai.samples.rag.config.AzureAISearchConfiguration and let spring initialize it through constructor injection?

Kernel semanticKernel = buildSemanticKernel(options);

// STEP 1: Create Azure AI Search client
SearchIndexAsyncClient client = new SearchIndexClientBuilder()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this instance configuration in com.microsoft.openai.samples.rag.config.AzureAISearchConfiguration and let spring initialize it through constructor injection?

);

// STEP 3: Retrieve relevant documents using keywords extracted from the chat history
String conversationString = ChatGPTUtils.formatAsChatML(questionOrConversation.toOpenAIChatMessages());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a duplication. let's use SK ChatHistory we have in conversation variable at line 72

import java.util.Optional;
import java.util.stream.Collectors;

public class AzureAISearchVectorStoreApproach {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change the class name with something which doesn't create confusion with JavaSemanticKernelWithVector..Approach.java name?.. Maybe something like AzureAISearchVectorStoreUtils ?


private static final String EMBEDDING_FIELD_NAME = "embedding";

public static class MemoryRecord {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if we call this DocumentRecord ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@milderhc what if we make the SK vector store (JavaSemanticKernelWithVectorStoreChatApproach) option the default one for semantic kernel? I think this will provide a better message about simplifying RAG implementation with semantic kernel compared to the one using SK chains. JavaSemanticKernelChainsChatApproach can still be there in repo for exploration purpose but not should not be addressable from the UI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants