Skip to content

Commit

Permalink
add new docs
Browse files Browse the repository at this point in the history
  • Loading branch information
redevrx committed Feb 1, 2024
1 parent f4f615d commit 930355a
Show file tree
Hide file tree
Showing 14 changed files with 208 additions and 106 deletions.
202 changes: 159 additions & 43 deletions README.md

Large diffs are not rendered by default.

17 changes: 1 addition & 16 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,7 @@ class _TranslateScreenState extends State<TranslateScreen> {

await openAI.onChatCompletion(request: request);
}

void createAssistant() async {
final assistant = Assistant(
model: Gpt4AModel(),
name: 'Math Tutor',
instructions:
'You are a personal math tutor. When asked a question, write and run Python code to answer the question.',
tools: [
{
"type": "code_interpreter",
}
],
);
await openAI.assistant.create(assistant: assistant);
}


@override
void initState() {
openAI = OpenAI.instance.build(
Expand Down
3 changes: 2 additions & 1 deletion lib/chat_gpt_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export 'src/model/chat_complete/request/chat_complete_text.dart';
export 'src/model/chat_complete/response/chat_ct_response.dart';
export 'src/model/edits/request/edit_request.dart';
export 'src/model/edits/response/edit_response.dart';
export 'src/model/gen_image/request/edit_file.dart';
export 'src/model/gen_image/request/file_info.dart';
export 'src/model/gen_image/request/variation.dart';
export 'src/model/embedding/request/embed_request.dart';
export 'src/model/embedding/response/embed_data.dart';
Expand Down Expand Up @@ -70,3 +70,4 @@ export 'src/model/run/response/create_thread_and_run_data.dart';
export 'src/model/run/response/list_run.dart';
export 'src/model/run/response/message_creation.dart';
export 'src/model/run/response/step_detail.dart';
export 'src/model/audio/request/speech_request.dart';
2 changes: 1 addition & 1 deletion lib/src/edit.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:chat_gpt_sdk/src/model/cancel/cancel_data.dart';
import 'package:chat_gpt_sdk/src/model/edits/request/edit_request.dart';
import 'package:chat_gpt_sdk/src/model/edits/response/edit_response.dart';
import 'package:chat_gpt_sdk/src/model/gen_image/request/edit_file.dart';
import 'package:chat_gpt_sdk/src/model/gen_image/request/file_info.dart';
import 'package:chat_gpt_sdk/src/model/gen_image/response/gen_img_response.dart';
import 'package:chat_gpt_sdk/src/utils/constants.dart';

Expand Down
4 changes: 2 additions & 2 deletions lib/src/model/audio/request/audio_request.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import 'dart:io';

import 'package:chat_gpt_sdk/src/model/audio/enum/audio_format.dart';
import 'package:chat_gpt_sdk/src/model/gen_image/request/edit_file.dart';
import 'package:chat_gpt_sdk/src/model/gen_image/request/file_info.dart';
import 'package:dio/dio.dart';

class AudioRequest {
///The audio file to transcribe, in one of
/// these formats: mp3, mp4, mpeg, mpga,
/// m4a, wav, or webm.[file]
final EditFile file;
final FileInfo file;

///The language of the input audio.
/// Supplying the input language in
Expand Down
4 changes: 2 additions & 2 deletions lib/src/model/file/request/upload_file.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import 'dart:io';

import 'package:chat_gpt_sdk/src/model/gen_image/request/edit_file.dart';
import 'package:chat_gpt_sdk/src/model/gen_image/request/file_info.dart';
import 'package:dio/dio.dart';

class UploadFile {
///Name of the JSON Lines file to be uploaded.
///If the is set to "fine-tune",
///each line is a JSON record with "prompt" and "completion"
/// fields representing your training examples.purpose. [file]
final EditFile file;
final FileInfo file;

///The intended purpose of the uploaded documents.
///Use "fine-tune" for Fine-tuning.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import 'package:chat_gpt_sdk/src/model/gen_image/enum/image_size.dart';
import 'package:dio/dio.dart';
import 'package:http_parser/http_parser.dart';

class EditFile {
class FileInfo {
final String path;
final String name;

EditFile(this.path, this.name);
FileInfo(this.path, this.name);

@override
String toString() => "[$path,$name]";
Expand All @@ -20,14 +20,14 @@ class EditImageRequest {
/// and square. If mask is not provided, image must have transparency,
/// which will be used as the mask.[image]
/// file name is image
final EditFile image;
final FileInfo image;

///An additional image whose fully transparent areas
/// (e.g. where alpha is zero) indicate where should be edited.
/// Must be a valid PNG file, less than 4MB, and have
/// the same dimensions as image. [mask]
/// file name is mask
final EditFile? mask;
final FileInfo? mask;

///A text description of the desired image(s).
/// The maximum length is 1000 characters.[prompt]
Expand Down
4 changes: 2 additions & 2 deletions lib/src/model/gen_image/request/variation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:io';

import 'package:chat_gpt_sdk/src/model/gen_image/enum/format.dart';
import 'package:chat_gpt_sdk/src/model/gen_image/enum/image_size.dart';
import 'package:chat_gpt_sdk/src/model/gen_image/request/edit_file.dart';
import 'package:chat_gpt_sdk/src/model/gen_image/request/file_info.dart';
import 'package:dio/dio.dart';
import 'package:http_parser/http_parser.dart';

Expand All @@ -11,7 +11,7 @@ class Variation {
/// and square. If mask is not provided, image must have transparency,
/// which will be used as the mask.[image]
/// file name is image
final EditFile image;
final FileInfo image;

///The number of images to generate. Must be between 1 and 10.[n]
final int n;
Expand Down
8 changes: 4 additions & 4 deletions test/model/audio/request/audio_request_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import 'package:test/test.dart';
void main() {
group('audio request test', () {
test('audio request test set edit file', () {
final request = AudioRequest(file: EditFile("path", "name"));
final request = AudioRequest(file: FileInfo("path", "name"));

expect(request.file.name, 'name');
expect(request.file.path, 'path');
expect(request.toJson(), isA<Future<FormData>>());
});
test('audio request test set language', () {
final request =
AudioRequest(file: EditFile("path", "name"), language: "en");
AudioRequest(file: FileInfo("path", "name"), language: "en");

expect(request.file.name, 'name');
expect(request.file.path, 'path');
Expand All @@ -23,7 +23,7 @@ void main() {
});
test('audio request test set format', () {
final request = AudioRequest(
file: EditFile("path", "name"),
file: FileInfo("path", "name"),
language: "en",
responseFormat: AudioFormat.verboseJson,
);
Expand All @@ -36,7 +36,7 @@ void main() {
});
test('audio request test set temperature', () {
final request = AudioRequest(
file: EditFile("path", "name"),
file: FileInfo("path", "name"),
language: "en",
responseFormat: AudioFormat.verboseJson,
temperature: 1,
Expand Down
2 changes: 1 addition & 1 deletion test/model/file/request/upload_file_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:test/test.dart';
void main() {
group('upload file test', () {
test('upload file test get from', () {
final upload = UploadFile(file: EditFile("path", 'name'));
final upload = UploadFile(file: FileInfo("path", 'name'));

expect(upload.getForm(), isA<Future<FormData>>());
});
Expand Down
4 changes: 2 additions & 2 deletions test/model/gen_image/request/edit_file_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:test/test.dart';
void main() {
group('edit file test', () {
test('edit file test', () async {
final e = EditFile('path', 'name');
final e = FileInfo('path', 'name');
final edit = await EditImageRequest(
image: e,
prompt: 'prompt',
Expand All @@ -21,7 +21,7 @@ void main() {
});

test('edit file test', () {
final e = EditFile('path', 'name');
final e = FileInfo('path', 'name');
e.toString();
final json = EditImageRequest(
image: e,
Expand Down
4 changes: 2 additions & 2 deletions test/model/gen_image/request/variation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ void main() {
group('variation test', () {
test('variation test from json', () async {
final variation = await Variation(
image: EditFile('path', 'name'),
image: FileInfo('path', 'name'),
size: ImageSize.size1024,
responseFormat: Format.url,
user: 'user',
Expand All @@ -17,7 +17,7 @@ void main() {
});
test('variation test to json', () {
final json = Variation(
image: EditFile('path', 'name'),
image: FileInfo('path', 'name'),
size: ImageSize.size1024,
responseFormat: Format.url,
user: 'user',
Expand Down
Loading

0 comments on commit 930355a

Please sign in to comment.