|
|
@@ -14,6 +14,7 @@ import '../../utils/sse_parse_util.dart';
|
|
|
import '../api/atmob_api.dart';
|
|
|
import '../api/atmob_stream_api.dart';
|
|
|
import '../api/request/intimacy_analyze_request.dart';
|
|
|
+import '../api/request/intimacy_generate_character_request.dart';
|
|
|
import '../api/request/intimacy_reply_analyze_request.dart';
|
|
|
import '../api/request/intimacy_reply_chat_request.dart';
|
|
|
import '../api/response/intimacy_analyze_chat_config_response.dart';
|
|
|
@@ -107,34 +108,36 @@ class IntimacyAnalyzeRepository {
|
|
|
}
|
|
|
|
|
|
/// 对话分析(SSE流式)
|
|
|
- Future<Stream<Message>> intimacyChatAnalyze(IntimacyChatAnalyzeRequest request) {
|
|
|
+ Future<Stream<Message>> intimacyChatAnalyze(
|
|
|
+ IntimacyChatAnalyzeRequest request,
|
|
|
+ ) {
|
|
|
return atmobStreamApi
|
|
|
.intimacyChatAnalyze(request)
|
|
|
.then((response) async {
|
|
|
- List<String>? contentType = response.headers['Content-Type'];
|
|
|
- if (contentType != null) {
|
|
|
- for (var value in contentType) {
|
|
|
- if (value.contains('text/event-stream')) {
|
|
|
- return response.stream;
|
|
|
- } else if (value.contains('application/json')) {
|
|
|
- BaseResponse<String> baseResponse = BaseResponse.fromJson(
|
|
|
- jsonDecode(
|
|
|
- await response.stream
|
|
|
- .map((bytes) => utf8.decoder.convert(bytes))
|
|
|
- .toList()
|
|
|
- .then((value) => value.join()),
|
|
|
- ),
|
|
|
+ List<String>? contentType = response.headers['Content-Type'];
|
|
|
+ if (contentType != null) {
|
|
|
+ for (var value in contentType) {
|
|
|
+ if (value.contains('text/event-stream')) {
|
|
|
+ return response.stream;
|
|
|
+ } else if (value.contains('application/json')) {
|
|
|
+ BaseResponse<String> baseResponse = BaseResponse.fromJson(
|
|
|
+ jsonDecode(
|
|
|
+ await response.stream
|
|
|
+ .map((bytes) => utf8.decoder.convert(bytes))
|
|
|
+ .toList()
|
|
|
+ .then((value) => value.join()),
|
|
|
+ ),
|
|
|
(json) => json as String,
|
|
|
- );
|
|
|
- throw ServerErrorException(
|
|
|
- baseResponse.code,
|
|
|
- baseResponse.message,
|
|
|
- );
|
|
|
+ );
|
|
|
+ throw ServerErrorException(
|
|
|
+ baseResponse.code,
|
|
|
+ baseResponse.message,
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- throw Exception('Invalid content type');
|
|
|
- })
|
|
|
+ throw Exception('Invalid content type');
|
|
|
+ })
|
|
|
.then((stream) => SSEParseUtil.parse(stream));
|
|
|
}
|
|
|
|
|
|
@@ -153,35 +156,46 @@ class IntimacyAnalyzeRepository {
|
|
|
return atmobApi.getIntimacyAnalyze(request).then(HttpHandler.handle(true));
|
|
|
}
|
|
|
|
|
|
+ /// 生成亲密度人设
|
|
|
+ Future<void> intimacyCharacterGenerate(
|
|
|
+ IntimacyGenerateCharacterRequest request,
|
|
|
+ ) {
|
|
|
+ return atmobApi
|
|
|
+ .intimacyCharacterGenerate(request)
|
|
|
+ .then(HttpHandler.handle(true));
|
|
|
+ }
|
|
|
+
|
|
|
/// 识图回复(SSE流式)
|
|
|
- Future<Stream<Message>> intimacyReplyAnalyze(IntimacyReplyAnalyzeRequest request) {
|
|
|
+ Future<Stream<Message>> intimacyReplyAnalyze(
|
|
|
+ IntimacyReplyAnalyzeRequest request,
|
|
|
+ ) {
|
|
|
return atmobStreamApi
|
|
|
.intimacyReplyAnalyze(request)
|
|
|
.then((response) async {
|
|
|
- List<String>? contentType = response.headers['Content-Type'];
|
|
|
- if (contentType != null) {
|
|
|
- for (var value in contentType) {
|
|
|
- if (value.contains('text/event-stream')) {
|
|
|
- return response.stream;
|
|
|
- } else if (value.contains('application/json')) {
|
|
|
- BaseResponse<String> baseResponse = BaseResponse.fromJson(
|
|
|
- jsonDecode(
|
|
|
- await response.stream
|
|
|
- .map((bytes) => utf8.decoder.convert(bytes))
|
|
|
- .toList()
|
|
|
- .then((value) => value.join()),
|
|
|
- ),
|
|
|
+ List<String>? contentType = response.headers['Content-Type'];
|
|
|
+ if (contentType != null) {
|
|
|
+ for (var value in contentType) {
|
|
|
+ if (value.contains('text/event-stream')) {
|
|
|
+ return response.stream;
|
|
|
+ } else if (value.contains('application/json')) {
|
|
|
+ BaseResponse<String> baseResponse = BaseResponse.fromJson(
|
|
|
+ jsonDecode(
|
|
|
+ await response.stream
|
|
|
+ .map((bytes) => utf8.decoder.convert(bytes))
|
|
|
+ .toList()
|
|
|
+ .then((value) => value.join()),
|
|
|
+ ),
|
|
|
(json) => json as String,
|
|
|
- );
|
|
|
- throw ServerErrorException(
|
|
|
- baseResponse.code,
|
|
|
- baseResponse.message,
|
|
|
- );
|
|
|
+ );
|
|
|
+ throw ServerErrorException(
|
|
|
+ baseResponse.code,
|
|
|
+ baseResponse.message,
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- throw Exception('Invalid content type');
|
|
|
- })
|
|
|
+ throw Exception('Invalid content type');
|
|
|
+ })
|
|
|
.then((stream) => SSEParseUtil.parse(stream));
|
|
|
}
|
|
|
}
|