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

chore: Improve UX for Orchestration chat scenario #543

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

shibeshduw
Copy link
Contributor

Context

Closes SAP/ai-sdk-js-backlog#228.

What this PR does and why it is needed

Copy link
Member

@MatKuhr MatKuhr left a comment

Choose a reason for hiding this comment

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

Otherwise lgtm

@shibeshduw shibeshduw marked this pull request as ready for review February 13, 2025 09:44
@shibeshduw shibeshduw changed the title feat: Add helper functions to improve Orchestration UX chore: Improve UX for Orchestration chat scenario Feb 13, 2025
* @returns A list of all messages.
*/
getAllMessages(choiceIndex = 0): ChatMessages {
const messages = (this.data.module_results.templating ?? []).map(
Copy link
Contributor

Choose a reason for hiding this comment

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

[q] Why the transformation? Everything you get from the templating results can be passed as it is in message history right?

Copy link
Contributor Author

@shibeshduw shibeshduw Feb 18, 2025

Choose a reason for hiding this comment

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

Yes that is true but if the user would use this convenience for anything else, they would have to handle complex objects when dealing with MultiChatMessage.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I am not quite sure I understand. What else would the user use this for?
I thought the main idea here is to pass the existing templating messages and the new response message back as history. The template should be assignable as it is, since the types are same. This will also not handle tool_calls.

: this.handleSingleChatMessage(message as SingleChatMessage)
);

const content = this.getChoices().find(c => c.index === choiceIndex)
Copy link
Contributor

Choose a reason for hiding this comment

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

[q] How do we handle cases when the assistant response has empty content and tool_calls? It should retain that structure.

Copy link
Contributor Author

@shibeshduw shibeshduw Feb 18, 2025

Choose a reason for hiding this comment

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

I updated this to take the entire message instead of just content. So the response will also include tool_calls.

Copy link
Contributor

@KavithaSiva KavithaSiva left a comment

Choose a reason for hiding this comment

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

Mostly looks good, but I would prefer a test added with the a sample multiChat response.

* @param choiceIndex - The index of the choice to parse.
* @returns A list of all messages.
*/
getAllMessages(choiceIndex = 0): ChatMessages {
Copy link
Contributor

Choose a reason for hiding this comment

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

[req] Could you please add an additional test in orchestration-client.test.ts with the a sample response json file with a multiChatMessage response?

I wasn't able to understand the code without looking at a sample response from the Java repo, so I think this would be beneficial for us too.

Comment on lines +81 to +89
role: multiChatMessage.role,
content: multiChatMessage.content
.map(content =>
content.type === 'text'
? content.text
: JSON.stringify({
url: content.image_url.url,
detail: content.image_url.detail
})
Copy link
Contributor

Choose a reason for hiding this comment

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

[q] Are other content types possible? Is this documented somewhere that only text and image_url are allowed for now? I feel it is better to also check if the type is image_url before stringifying.

@shibeshduw shibeshduw marked this pull request as draft February 25, 2025 09:13
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.

5 participants