ChatGPTClient class
A class to interact with OpenAI ChatGPT Completions API Support various models such as gpt-3.5-turbo, gpt-4, etc
Constructors
- ChatGPTClient({required String apiKey, String model = "gpt-3.5-turbo", String systemPrompt = "You are a helpful assistant", double temperature = 0.5})
- Initializer, API key is required
Properties
- apiKey → String
-
OpenAI API Key which you can get from https://openai.com/api
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- model → String
-
GPT Model (gpt-3.5-turbo, gpt-4, etc) default to gpt-3.5-turbo
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- systemPrompt → String
-
System prompt, default to "You're a helpful assistant"
final
- temperature → double
-
Temperature, default to 0.5
final
- url → Uri
-
OpenAI ChatGPT Completions API Endpoint URL
final
Methods
-
clearHistoryList(
) → void - Clear history list array
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
sendMessage(
String text) → Future< String> - Send message to ChatGPT to a prompt asynchronously
-
sendMessageStream(
String text) → Stream< String> -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited