-
-
Notifications
You must be signed in to change notification settings - Fork 6
OpenAI.Request
OpenAI.Request
Protected Class Request
This class represents an API request. Set the appropriate properties of this class to build your request, then pass it to the factory method that corresponds to the API endpoint you want to make the request of.
Most properties are not valid for all endpoints. Refer to the OpenAI documentation for the endpoint you're interacting with to determine which properties are mandatory, which are optional, and which are invalid. If a Request
has invalid properties set then an exception will be raised when it gets rejected by the endpoint.
You may encounter situations where you need to set a request parameter that is either not wrapped by one of this class's properties, or where the property doesn't support the datatype you want to set for the parameter. For example, on some endpoints the Input
parameter can optionally be an array of strings instead of just a single string. In such cases you can use the Set() method to manually set the parameter value. Care must be taken when doing this; the parameter name must be exactly right and the parameter datatype must be something that can be serialized by a JSONItem.
This example builds a ChatCompletion request:
OpenAI.APIKey = "YOUR API KEY"
Dim request As New OpenAI.Request
request.Model = "gpt-4"
Dim chatlog As New OpenAI.ChatCompletionData
chatlog.AddMessage("user", "What is the airspeed velocity of an unladen European swallow?")
request.Messages = chatlog
' the request is now ready to be sent
Dim result As OpenAI.Response = OpenAI.ChatCompletion.Create(request)
Dim answer As String = result.GetResult()
- BatchSize As Integer
- BestOf As Integer
- ClassificationBetas As JSONItem
- ClassificationNClasses As Integer
- ClassificationPositiveClass As String
- ComputeClassificationMetrics As Boolean
- Echo As Boolean
- File As MemoryBlock
- FileMIMEType As String
- FileName As String
- FineTuneID As String
- FrequencyPenalty As Single
- Input As String
- Instruction As String
- Language As String
- LearningRateMultiplier As Single
- LogItBias As JSONItem
- LogProbabilities As Boolean
- MaskImage As Picture
- MaxTokens As Integer
- Messages As JSONItem
- Model As Model
- NumberOfEpochs As Integer
- NumberOfResults As Integer
- PresencePenalty As Single
- Prompt As String
- PromptLossWeight As Single
- Purpose As String
- ResponseFormat As String
- ResultsAsBase64 As Boolean
- ResultsAsJSON As Boolean
- ResultsAsJSON_Verbose As Boolean
- ResultsAsSRT As Boolean
- ResultsAsText As Boolean
- ResultsAsURL As Boolean
- ResultsAsVTT As Boolean
- Size As String
- SourceImage As Picture
- Stop As String
- Suffix As String
- Temperature As Single
- TopLogProbabilities As Integer
- Top_P As Single
- TrainingFile As String
- User As String
- ValidationFile As String
Wiki home | Project page | Bugs | Become a sponsor
Text and code examples are Copyright ©2023-24 Andrew Lambert, offered under the CC BY-SA 3.0 License.