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

Open
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

packages/orchestration/src/orchestration-response.ts Outdated Show resolved Hide resolved
@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
packages/orchestration/src/orchestration-response.test.ts Outdated Show resolved Hide resolved
packages/orchestration/src/orchestration-response.ts Outdated Show resolved Hide resolved
packages/orchestration/src/orchestration-response.ts Outdated Show resolved Hide resolved
packages/orchestration/src/orchestration-response.ts Outdated Show resolved Hide resolved
* @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.

packages/orchestration/src/orchestration-response.ts Outdated Show resolved Hide resolved
).map(message =>
this.isMultiChatMessage(message)
? this.handleMultiChatMessage(message as MultiChatMessage)
: this.handleSingleChatMessage(message as SingleChatMessage)
Copy link
Contributor

Choose a reason for hiding this comment

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

[req] I would just return the message from here, because the mapping is not required. The message type is already how you want it to be

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean both the mapping or just handleSingleChatMessage?

Copy link
Contributor

Choose a reason for hiding this comment

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

just handleSingleChatMessage.

: 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

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.

packages/orchestration/src/orchestration-response.ts Outdated Show resolved Hide resolved
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