chat_gpt_api
适用于Flutter应用的Chat GPT封装,使用Dart语言编写。初始版本支持文本补全、代码补全和图像生成
用于 Flutter 应用的 ChatGPT SDK,使用 Dart 语言编写
以下为英文项目原文快照,最新内容请访问 GitHub。
The chatGPT SDK written in dart to access the features of the OpenAI APIs
chat_gpt: 2.0.0
flutter pub get
Create an instance of the ChatGPT
final chatGpt = ChatGPT.builder( token: '<token>');
You can generate the token from https://beta.openai.com/account/api-keys
#Text Completion : The completions endpoint can be used for a wide variety of tasks. More details : https://beta.openai.com/docs/guides/completion
How to write the prompts https://beta.openai.com/docs/guides/completion/prompt-design
Method to do code completion / code completion
const prompt = "Explain Quantum Computing in simple terms";
Completion? completion = await chatGpt.textCompletion(
request: const CompletionRequest(
prompt: prompt,
maxTokens: 256,
),
);
print(completion?.choices);
#Image generation : The image generations endpoint allows you to create an original image given a text prompt. More Details : https://beta.openai.com/docs/guides/images/introduction
Supported Image Generation Types
Sample Code to generate the image
Images? images = await chatGpt.generateImage(
request: const ImageRequest(
prompt: 'A cute baby sea otter',
),
);
print(images?.data);
Catch me up on LinkedIn @Leo Elstin
💙 to Code 👨 🏽💻 Full Stack Mobile Developer [ Flutter, Native, Spring Boot ]