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

Should OpenAIModelFactory be public? #46

Closed
Blackbaud-TimMcVicker opened this issue Jun 11, 2024 · 2 comments
Closed

Should OpenAIModelFactory be public? #46

Blackbaud-TimMcVicker opened this issue Jun 11, 2024 · 2 comments

Comments

@Blackbaud-TimMcVicker
Copy link

In the initial Azure.Ai.OpenAi versions of this library, we could use AzureOpenAIModelFactory to create objects to use in our mocks, per this issue Azure/azure-sdk-for-net#36462. This was useful when writing tests that mocked out the OpenAIClient.

The new version of that seems to be marked internal instead of public. Is that intentional? If so, what should we be using to create those objects in our mocks?

@KrzysztofCwalina
Copy link
Collaborator

We will be adding an official way to create models for mocking, but for now you can use the following workaround:

        ChatCompletion completion = ModelReaderWriter.Read<ChatCompletion>(BinaryData.FromObjectAsJson(new {
            id = "1234",
            choices = new object[]
            {
                new {
                    finish_reason = "stop",
                    index = 0,
                    message = new {
                        content = "It's a nice day today!",
                        role = "assistant"
                    }
                }
            },
            created = DateTimeOffset.Now.ToUnixTimeSeconds(),
            model = "model",
            system_fingerprint = "N/A",
            @object = "N/A",
            usage = (object)null
        }));

@joseharriaga
Copy link
Collaborator

I have created the following issue to track the work needed to add support for mocking: 🔗 #121

I will close the present issue so that we can follow up in one single place. 😊 Thank you, @Blackbaud-TimMcVicker !

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

No branches or pull requests

3 participants