Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

milderhc
Copy link

Purpose

Adding chat using Semantic Kernel.

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

Other Information

@dantelmomsft dantelmomsft self-requested a review October 27, 2023 09:58
Copy link
Collaborator

@dantelmomsft dantelmomsft left a comment

Choose a reason for hiding this comment

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

Can you rebase this with the new commits on the main. Furthermore make sure to synchronize with the last UI changes from john Oliver PR #44.

Other comments are inline.

@milderhc milderhc marked this pull request as ready for review October 30, 2023 17:32
@milderhc milderhc requested a review from brunoborges as a code owner October 30, 2023 17:32
Copy link
Collaborator

@dantelmomsft dantelmomsft left a comment

Choose a reason for hiding this comment

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

PR looks good. 2 additional comments:

  1. I think you lost chat.tsx UI changes when you merged the last commits from main on your branch.
  2. Could you also add the streaming support

@milderhc milderhc requested a review from dantelmomsft October 31, 2023 17:37
@dantelmomsft
Copy link
Collaborator

dantelmomsft commented Oct 31, 2023 via email

@brunoborges brunoborges marked this pull request as draft November 1, 2023 17:01
@milderhc milderhc marked this pull request as ready for review November 1, 2023 19:04
@brunoborges
Copy link
Member

Hey @dantelmomsft , can you please review this carefuly?

@milderhc
Copy link
Author

milderhc commented Nov 1, 2023

I added streaming to SK implementation, but as we don't support streaming on the SKFunctions, I'm returning the whole response in the runStreaming method. The only one to implement proper streaming at the moment would be using the same approach I initially added (57272e5), with String replacement to create chat instructions in the code, this is becuase OpenAIChatCompletion supports streaming.

Let me know if this is okay or would like to implement runStreaming the other way.

Copy link
Collaborator

@dantelmomsft dantelmomsft left a comment

Choose a reason for hiding this comment

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

1 java unit tests is failing:
image

String question = ChatGPTUtils.getLastUserQuestion(questionOrConversation.getMessages());

Kernel semanticKernel = buildSemanticKernel(options);

Copy link
Collaborator

Choose a reason for hiding this comment

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

getSourcesFromCOnversation is missing. See what you've done here:
https://github.com/Azure-Samples/azure-search-openai-demo-java/pull/47/files#diff-b6597742f55dcf06e09eb19c789531ec2b2273fb3b56bd97fd929afbc451e5d5R77

Consider to refactor to one common method used both by the JavaSemanticKernelChainsChatApproach and JavaSemanticKernelWithMemoryChatApproach

Copy link
Collaborator

@dantelmomsft dantelmomsft Nov 6, 2023

Choose a reason for hiding this comment

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

get sources using extract keywords is still missing in the new commit. Please review the previous comment.

Copy link
Author

@milderhc milderhc Nov 7, 2023

Choose a reason for hiding this comment

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

Thanks! Extracting keywords by using getSourcesFromConversation only applies to SK with memory approach, as it only uses semantic functions. SK chaining uses both, native and semantic functions, so I instead added a new native function to CognitiveSearchPlugin to search the keywords using that function. I moved the plugin to the retrieval package as well.

Let me know what you think

app/frontend/src/pages/chat/Chat.tsx Show resolved Hide resolved
app/frontend/src/pages/chat/Chat.tsx Outdated Show resolved Hide resolved
@dantelmomsft
Copy link
Collaborator

I added streaming to SK implementation, but as we don't support streaming on the SKFunctions, I'm returning the whole response in the runStreaming method. The only one to implement proper streaming at the moment would be using the same approach I initially added (57272e5), with String replacement to create chat instructions in the code, this is becuase OpenAIChatCompletion supports streaming.

Let me know if this is okay or would like to implement runStreaming the other way.

I was not aware java SK didn't support streaming.. in this case I would just leave it as "Not Implemented" for the time being. .@johnoliver WDYT ?

Copy link
Collaborator

@dantelmomsft dantelmomsft left a comment

Choose a reason for hiding this comment

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

If you agree with the strategy I've shared in my last comment, we should at least add a dedicated production environment and deploy the tagged release. After that we can start use CI + scheduled daily build pipelines on the current dev environment. Please bring back the infra validation CI pipeline.

@milderhc
Copy link
Author

milderhc commented Nov 6, 2023

@dantelmomsft I disabled streaming for SK approaches. I am also not sure if you meant the last comment for this PR.

@milderhc milderhc requested a review from dantelmomsft November 6, 2023 06:53
import java.util.stream.Collectors;

/**
* Simple chat-read-retrieve-read java implementation, using the Cognitive Search and OpenAI APIs directly.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please review the description looking at the the JavaSemanticKernelChainsApproach.
Please add this new approach to the implementations table in the README: https://github.com/Azure-Samples/azure-search-openai-demo-java/blob/main/README.md#rag-implementation-options

Copy link
Author

Choose a reason for hiding this comment

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

I'll update it once you agree with the last changes I added.

String question = ChatGPTUtils.getLastUserQuestion(questionOrConversation.getMessages());

Kernel semanticKernel = buildSemanticKernel(options);

Copy link
Collaborator

@dantelmomsft dantelmomsft Nov 6, 2023

Choose a reason for hiding this comment

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

get sources using extract keywords is still missing in the new commit. Please review the previous comment.

@dantelmomsft
Copy link
Collaborator

@milderhc PR approved. before merging can you make sure to update the README with the new approaches as mentioned in my last comment. thanks and great work.

@dantelmomsft dantelmomsft merged commit ae612e9 into Azure-Samples:main Nov 8, 2023
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.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.