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

Add support for mocking via the OpenAIModelFactory #121

Open
joseharriaga opened this issue Jul 12, 2024 · 0 comments
Open

Add support for mocking via the OpenAIModelFactory #121

joseharriaga opened this issue Jul 12, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@joseharriaga
Copy link
Collaborator

As of version 2.0.0-beta.7, there is no simple way for users to mock service outputs for testing. Consequently, they currently rely on workarounds such as using ModelReaderWriter.Read<T> to create a mock from JSON as illustrated below:

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
}));

To improve the experience around mocking, we plan to fully implement and expose the OpenAIModelFactory static class

@joseharriaga joseharriaga added the enhancement New feature or request label Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant