forked from AppFlowy-IO/AppFlowy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43e64d8
commit 148643a
Showing
55 changed files
with
2,532 additions
and
2,746 deletions.
There are no files selected for viewing
81 changes: 0 additions & 81 deletions
81
frontend/appflowy_flutter/integration_test/shared/mock/mock_openai_repository.dart
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,17 @@ | ||
import 'package:appflowy_backend/protobuf/flowy-ai/protobuf.dart'; | ||
import 'package:appflowy_result/appflowy_result.dart'; | ||
|
||
import 'ai_entities.dart'; | ||
import 'error.dart'; | ||
import 'text_completion.dart'; | ||
|
||
abstract class AIRepository { | ||
Future<void> getStreamedCompletions({ | ||
required String prompt, | ||
required Future<void> Function() onStart, | ||
required Future<void> Function(TextCompletionResponse response) onProcess, | ||
required Future<void> Function() onEnd, | ||
required void Function(AIError error) onError, | ||
String? suffix, | ||
int maxTokens = 2048, | ||
double temperature = 0.3, | ||
bool useAction = false, | ||
}); | ||
|
||
Future<void> streamCompletion({ | ||
String? objectId, | ||
required String text, | ||
PredefinedFormat? format, | ||
required CompletionTypePB completionType, | ||
required Future<void> Function() onStart, | ||
required Future<void> Function(String text) onProcess, | ||
required Future<void> Function() onEnd, | ||
required void Function(AIError error) onError, | ||
}); | ||
|
||
Future<FlowyResult<List<String>, AIError>> generateImage({ | ||
required String prompt, | ||
int n = 1, | ||
}); | ||
} |
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,89 @@ | ||
import 'package:appflowy/generated/flowy_svgs.g.dart'; | ||
import 'package:appflowy/generated/locale_keys.g.dart'; | ||
import 'package:appflowy_backend/protobuf/flowy-ai/protobuf.dart'; | ||
import 'package:easy_localization/easy_localization.dart'; | ||
import 'package:equatable/equatable.dart'; | ||
|
||
class PredefinedFormat extends Equatable { | ||
const PredefinedFormat({ | ||
required this.imageFormat, | ||
required this.textFormat, | ||
}); | ||
|
||
const PredefinedFormat.auto() | ||
: imageFormat = ImageFormat.text, | ||
textFormat = TextFormat.auto; | ||
|
||
final ImageFormat imageFormat; | ||
final TextFormat? textFormat; | ||
|
||
PredefinedFormatPB toPB() { | ||
return PredefinedFormatPB( | ||
imageFormat: switch (imageFormat) { | ||
ImageFormat.text => ResponseImageFormatPB.TextOnly, | ||
ImageFormat.image => ResponseImageFormatPB.ImageOnly, | ||
ImageFormat.textAndImage => ResponseImageFormatPB.TextAndImage, | ||
}, | ||
textFormat: switch (textFormat) { | ||
TextFormat.auto => ResponseTextFormatPB.Paragraph, | ||
TextFormat.bulletList => ResponseTextFormatPB.BulletedList, | ||
TextFormat.numberedList => ResponseTextFormatPB.NumberedList, | ||
TextFormat.table => ResponseTextFormatPB.Table, | ||
_ => null, | ||
}, | ||
); | ||
} | ||
|
||
@override | ||
List<Object?> get props => [imageFormat, textFormat]; | ||
} | ||
|
||
enum ImageFormat { | ||
text, | ||
image, | ||
textAndImage; | ||
|
||
bool get hasText => this == text || this == textAndImage; | ||
|
||
FlowySvgData get icon { | ||
return switch (this) { | ||
ImageFormat.text => FlowySvgs.ai_text_s, | ||
ImageFormat.image => FlowySvgs.ai_image_s, | ||
ImageFormat.textAndImage => FlowySvgs.ai_text_image_s, | ||
}; | ||
} | ||
|
||
String get i18n { | ||
return switch (this) { | ||
ImageFormat.text => LocaleKeys.chat_changeFormat_textOnly.tr(), | ||
ImageFormat.image => LocaleKeys.chat_changeFormat_imageOnly.tr(), | ||
ImageFormat.textAndImage => | ||
LocaleKeys.chat_changeFormat_textAndImage.tr(), | ||
}; | ||
} | ||
} | ||
|
||
enum TextFormat { | ||
auto, | ||
bulletList, | ||
numberedList, | ||
table; | ||
|
||
FlowySvgData get icon { | ||
return switch (this) { | ||
TextFormat.auto => FlowySvgs.ai_paragraph_s, | ||
TextFormat.bulletList => FlowySvgs.ai_list_s, | ||
TextFormat.numberedList => FlowySvgs.ai_number_list_s, | ||
TextFormat.table => FlowySvgs.ai_table_s, | ||
}; | ||
} | ||
|
||
String get i18n { | ||
return switch (this) { | ||
TextFormat.auto => LocaleKeys.chat_changeFormat_text.tr(), | ||
TextFormat.bulletList => LocaleKeys.chat_changeFormat_bullet.tr(), | ||
TextFormat.numberedList => LocaleKeys.chat_changeFormat_number.tr(), | ||
TextFormat.table => LocaleKeys.chat_changeFormat_table.tr(), | ||
}; | ||
} | ||
} |
File renamed without changes.
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
Oops, something went wrong.