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

Improve parsing of responses from the AI #18201

Open
wants to merge 1 commit into
base: feature/llm
Choose a base branch
from

Conversation

PankajBhojwani
Copy link
Contributor

Summary of the Pull Request

Instead of manually parsing out code blocks from the response we receive, use the cmark library.

Validation Steps Performed

Responses are parsed as expected.

PR Checklist

  • Closes #xxx
  • Tests added/passed
  • Documentation updated
    • If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema updated (if necessary)

@PankajBhojwani
Copy link
Contributor Author

PankajBhojwani commented Nov 15, 2024

I initially wanted to directly use the RichTextBlock we get from MarkdownToXaml::Convert added in #17585, but because we want to allow the user to click individual code blocks to send it to the shell we cannot just present one RichTextBlock - the palette needs to know which items are code and which items are plaintext and present them individually. The code here uses the same logic though.

Comment on lines +242 to +247
if (!currentRun.empty())
{
const auto chatMsg = winrt::make<ChatMessage>(winrt::to_hstring(currentRun), false, false);
messageParts.push_back(chatMsg);
currentRun.clear();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't like that this is the exact same as lines 227-231 but making a helper function for 3 lines of code seems silly...

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.

1 participant