-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ Add ] added more examples to reproduce in the example/ folder
- Loading branch information
Showing
9 changed files
with
107 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:dart_openai/openai.dart'; | ||
import 'package:dotenv/dotenv.dart'; | ||
|
||
Future<void> main() async { | ||
// Load the .env file | ||
DotEnv env = DotEnv()..load([".env"]); | ||
|
||
// Set the OpenAI API key from the .env file. | ||
OpenAI.apiKey = env['OPEN_AI_API_KEY']!; | ||
|
||
// Creates The Completion | ||
OpenAICompletionModel completion = await OpenAI.instance.completion.create( | ||
model: "text-davinci-003", | ||
prompt: 'Flutter is ', | ||
maxTokens: 100, | ||
temperature: 0.8, | ||
); | ||
|
||
// Prints the completion text. | ||
print(completion.choices.first.text); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:dart_openai/openai.dart'; | ||
import 'package:dotenv/dotenv.dart'; | ||
|
||
Future<void> main() async { | ||
// Load the .env file | ||
DotEnv env = DotEnv()..load([".env"]); | ||
|
||
// Set the OpenAI API key from the .env file. | ||
OpenAI.apiKey = env['OPEN_AI_API_KEY']!; | ||
|
||
// Creates the Edit | ||
OpenAIEditModel edit = await OpenAI.instance.edit.create( | ||
model: "text-davinci-edit-001", | ||
input: | ||
"Flutter is a cross-platform UI toolkit that is designed to allow code reuse across operating systems such as iOS and Android, while also allowing applications to interface directly with underlying platform services.", | ||
instruction: "summarize the input to 50 tokens at maximum", | ||
temperature: 0.8, | ||
n: 4, | ||
); | ||
|
||
// Prints the choices. | ||
for (int index = 0; index < edit.choices.length; index++) { | ||
print(edit.choices[index].text); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:dart_openai/openai.dart'; | ||
import 'package:dotenv/dotenv.dart'; | ||
|
||
Future<void> main() async { | ||
// Load the .env file | ||
DotEnv env = DotEnv()..load([".env"]); | ||
|
||
// Set the OpenAI API key from the .env file. | ||
OpenAI.apiKey = env['OPEN_AI_API_KEY']!; | ||
|
||
// Creates the Image Variation | ||
OpenAIImageVariationModel variation = await OpenAI.instance.image.variation( | ||
image: File("example.png"), | ||
n: 1, | ||
size: OpenAIImageSize.size256, | ||
responseFormat: OpenAIResponseFormat.b64Json, | ||
); | ||
|
||
// Prints the result. | ||
print(variation.data.first.url); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'package:dart_openai/openai.dart'; | ||
import 'package:dotenv/dotenv.dart'; | ||
|
||
Future<void> main() async { | ||
// Load the .env file | ||
DotEnv env = DotEnv()..load([".env"]); | ||
|
||
// Set the OpenAI API key from the .env file. | ||
OpenAI.apiKey = env['OPEN_AI_API_KEY']!; | ||
|
||
// Creates the moderation. | ||
OpenAIModerationModel moderation = await OpenAI.instance.moderation.create( | ||
input: 'I hate you, I will kill you', | ||
); | ||
|
||
// prints the result | ||
print(moderation.results.first.categories); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters