chatgpt_client 1.0.0 copy "chatgpt_client: ^1.0.0" to clipboard
chatgpt_client: ^1.0.0 copied to clipboard

Access OpenAI ChatGPT Public API using Dart Language. Supports native Dart project and all Flutter target platforms (iOS, Android, Windows, Linux, Web) It provides streamed and normal response when as [...]

example/main.dart

import 'package:chatgpt_client/chatgpt_client.dart';

void main() async {
  final client = ChatGPTClient(apiKey: "API_KEY");
  final prompt = "what is observable object?";

  /// Standard Response
  print("Standard Response");
  try {
    final text = await client.sendMessage(prompt);
    print(text);
  } catch (exception) {
    print(exception.toString());
  }

  /// Stream Response
  print("Stream Response");
  try {
    var text = "";
    final stream = client.sendMessageStream(prompt);
    await for (final textChunk in stream) {
      text += textChunk;
      print(textChunk);
    }
    print(text);
  } catch (exception) {
    print(exception.toString());
  }

  client.clearHistoryList();
}
15
likes
0
pub points
36%
popularity

Publisher

verified publisheralfianlosari.com

Access OpenAI ChatGPT Public API using Dart Language. Supports native Dart project and all Flutter target platforms (iOS, Android, Windows, Linux, Web) It provides streamed and normal response when asking ChatGPT, the client also stores the converstation list history so it can be used on new prompt to make it aware of previous conversation context.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

http

More

Packages that depend on chatgpt_client