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

CLIENTS: Discuss Using Fluent API for Building Completion Requests #91

Open
hassanhabib opened this issue Mar 20, 2023 · 1 comment
Open
Labels
CLIENTS Exposure layer for external consumers

Comments

@hassanhabib
Copy link
Owner

#73

@jodendaal
Copy link

jodendaal commented Mar 21, 2023

I like using fluent assertions they are useful for building complex objects.

My only observation , which is not to do with fluent syntax directly, is how the consumer knows which properties are required when initializing a TextCompletion, it's not obvious.

Is it a rule in the Standard to only use anemic models? (I need to read it all, got to find some time with all he bits I'm working on at the moment). I much prefer something like below, as it's obvious to me that prompt and model are required, other properties are optional. I would eventually figure it out by trial and error on anemic model, but it's not a great developer experience.

The same applies for the Fluent Assertions, they are great but should start with required parameters being mandatory(if thats possible), then allow you to chain the additional properties you want.

This forces the correct consumption/usage

public class TextCompletionRequest
{
    public TextCompletionRequest(string[] prompt, string model)
    { 
        this.Prompt = prompt;
        this.Model = model;
    }

    public string Model { get; set; }
    public string[] Prompt { get; set; }

}

Or an alternative so you still have anemic model, but method to create it with required defaults.

public class TextCompletionRequest
{
    private TextCompletionRequest()
    { 
    }

    public string Model { get; set; }
    public string[] Prompt { get; set; }

   public static TextCompletionRequest Create(string[] prompt, string model)
   {
      var textCompletionRequest = new TextCompletion();
            textCompletionRequest.Prompt = prompt;
            textCompletionRequest.Model= model;
      return textCompletionRequest;
   }

}

Then you can do

var textCompletionRequest = TextCompletionRequest.Create(prompt,model);
      textCompletionRequest.Echo = true;
      textCompletionRequest.Temperature = 0.1;
      ...

@hassanhabib hassanhabib added the CLIENTS Exposure layer for external consumers label Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLIENTS Exposure layer for external consumers
Projects
None yet
Development

No branches or pull requests

2 participants