Skip to content

Fixes prompty pattern matching. Closes #1325 #1326

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

Merged
merged 2 commits into from
Jul 15, 2025

Conversation

waldekmastykarz
Copy link
Collaborator

Fixes prompty pattern matching. Closes #1325

@waldekmastykarz waldekmastykarz requested a review from a team as a code owner July 14, 2025 06:58
@garrytrinder garrytrinder requested a review from Copilot July 14, 2025 08:11
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes prompty pattern matching by generalizing message conversions from arrays to IEnumerable<ChatMessage> and updating the empty‐check logic.

  • Updated ConvertMessages signature in OpenAI and Ollama clients to accept IEnumerable<ChatMessage> instead of ChatMessage[].
  • Updated the abstract ConvertMessages method in BaseLanguageModelClient accordingly.
  • Changed the prompty.Empty check from array‐based (Length == 0) to LINQ’s .Any() on IEnumerable.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
DevProxy.Abstractions/LanguageModel/OpenAILanguageModelClient.cs Changed ConvertMessages parameter from ChatMessage[] to IEnumerable<ChatMessage>.
DevProxy.Abstractions/LanguageModel/OllamaLanguageModelClient.cs Changed ConvertMessages parameter from ChatMessage[] to IEnumerable<ChatMessage>.
DevProxy.Abstractions/LanguageModel/BaseLanguageModelClient.cs Updated abstract ConvertMessages signature and empty‐check from array to IEnumerable with .Any().
Comments suppressed due to low confidence (1)

DevProxy.Abstractions/LanguageModel/BaseLanguageModelClient.cs:107

  • There’s no existing test covering the case when prompty.Prepare(parameters) returns an empty IEnumerable. Adding unit tests for both empty and non-empty prompt scenarios would ensure this change behaves as expected.
        var prompty = Prompt.FromMarkdown(promptContents);

@garrytrinder garrytrinder enabled auto-merge (squash) July 15, 2025 13:17
@garrytrinder garrytrinder merged commit 0f93a9e into dotnet:main Jul 15, 2025
4 checks passed
@waldekmastykarz waldekmastykarz deleted the fix-prompty-prepare-type branch July 15, 2025 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: Errors when generating OpenAPI spec – missing prompt files and invalid 'includeParameters' property
2 participants