Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 11, 2025

All namespaces have model factory types, e.g. OpenAIModelFactory

Reviews the model factory methods to make sure that all output models can be created and initialized. If some cannot, i.e. there is no model factory, the type does not have public ctor, or settable public properties, add a model factory method for this model type.

Copilot AI changed the title [WIP] [FEATURE REQ] Add ChatModelFactory class to the OpenAI namespace Add ChatModelFactory class to OpenAI namespace for easier mocking Jul 11, 2025
Copilot AI requested a review from KrzysztofCwalina July 11, 2025 15:50
Copilot finished work on behalf of KrzysztofCwalina July 11, 2025 15:50
Copy link
Contributor Author

Copilot AI commented Jul 11, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • download.visualstudio.microsoft.com
    • Triggering command: wget REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from KrzysztofCwalina July 11, 2025 16:01
Copilot finished work on behalf of KrzysztofCwalina July 11, 2025 16:01
@KrzysztofCwalina KrzysztofCwalina marked this pull request as ready for review July 11, 2025 16:12
@KrzysztofCwalina KrzysztofCwalina enabled auto-merge (squash) July 11, 2025 16:14
{
/// <summary> Initializes a new instance of <see cref="OpenAI.Chat.ChatCompletion"/>. </summary>
/// <returns> A new <see cref="OpenAI.Chat.ChatCompletion"/> instance for mocking. </returns>
public static ChatCompletion ChatCompletion(
Copy link
Collaborator

Choose a reason for hiding this comment

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

@KrzysztofCwalina - I was wondering, why do we have to write the model factory methods manually? Shouldn't these be generated by the code gen?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure. Josh would know

Copy link
Collaborator

Choose a reason for hiding this comment

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

@JoshLove-msft / @jorgerangel-msft / @joseharriaga - Do you know why model factory methods aren't being generated for these types?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The implementation is calling into a different model factory overload? Isn't that one being generated? What is the purpose of this new overload?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, this is a namespace specific model factory. The generator doesn't support this currently. There is one model factory per library.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Wait, maybe the PR I was going before the last GA merged? I thought we punted it and this was the attempt to restart. Let's me investigate

Copy link
Collaborator

Choose a reason for hiding this comment

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

For reference, some of these custom methods are already being generated in the root namespace: https://github.com/openai/openai-dotnet/blob/main/src/Generated/OpenAIModelFactory.cs#L296

Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot, dont add model factory methods (or classes) if they aready exist. Only if they don't as in this PR description

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're correct. I've removed the entire ChatModelFactory class since OpenAIChatModelFactory already provides all the necessary factory methods for Chat-related types. Commit ea57bbc removes the redundant factory class and its associated tests.

@KrzysztofCwalina KrzysztofCwalina marked this pull request as draft July 11, 2025 17:09
{
/// <summary> Initializes a new instance of <see cref="OpenAI.Chat.ChatCompletion"/>. </summary>
/// <returns> A new <see cref="OpenAI.Chat.ChatCompletion"/> instance for mocking. </returns>
public static ChatCompletion ChatCompletion(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wait, maybe the PR I was going before the last GA merged? I thought we punted it and this was the attempt to restart. Let's me investigate

{
/// <summary> Initializes a new instance of <see cref="OpenAI.Chat.ChatCompletion"/>. </summary>
/// <returns> A new <see cref="OpenAI.Chat.ChatCompletion"/> instance for mocking. </returns>
public static ChatCompletion ChatCompletion(
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot, dont add model factory methods (or classes) if they aready exist. Only if they don't as in this PR description

Copilot AI requested a review from KrzysztofCwalina July 11, 2025 17:17
Copilot finished work on behalf of KrzysztofCwalina July 11, 2025 17:17
@KrzysztofCwalina
Copy link
Collaborator

It seems like the other PR went in before GA

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