v1.0.25
This commit is contained in:
parent
ec2f6bc907
commit
391551f57b
@ -1,5 +1,10 @@
|
|||||||
Workout Test and Diet 4 You Common Util Functions
|
Workout Test and Diet 4 You Common Util Functions
|
||||||
|
|
||||||
|
### Version 1.0.25
|
||||||
|
|
||||||
|
- http get utf8
|
||||||
|
- gpt4 model
|
||||||
|
|
||||||
### Version 1.0.24
|
### Version 1.0.24
|
||||||
|
|
||||||
http get utf8
|
http get utf8
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
class OpenAIChat {
|
class OpenAIChat {
|
||||||
int id = 0;
|
int id = 0;
|
||||||
late String messages; // JSON of ChatMessage
|
late String messages; // JSON of ChatMessage
|
||||||
String modelName = "gpt-3.5-turbo";
|
late String modelName;
|
||||||
double temperature = 0.1;
|
late double temperature;
|
||||||
|
|
||||||
OpenAIChat(this.messages, {String? modelName, double? temperature});
|
OpenAIChat(this.messages, {String? modelName, double? temperature}) {
|
||||||
|
this.modelName = modelName ?? "gpt-3.5-turbo";
|
||||||
|
this.temperature = temperature ?? 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
OpenAIChat.fromJson(Map json) {
|
OpenAIChat.fromJson(Map json) {
|
||||||
id = json["id"];
|
id = json["id"];
|
||||||
|
@ -7,6 +7,10 @@ import 'package:workouttest_util/service/api.dart';
|
|||||||
import 'package:workouttest_util/util/logging.dart';
|
import 'package:workouttest_util/util/logging.dart';
|
||||||
|
|
||||||
class OpenAIApi with Logging {
|
class OpenAIApi with Logging {
|
||||||
|
final String modelDavinci = "text-davinci-003";
|
||||||
|
final String modelGpt35 = "gpt-3.5-turbo";
|
||||||
|
final String modelGpt4 = "gpt-4-32k";
|
||||||
|
final String modelAda = "text-embedding-ada-002";
|
||||||
final APIClient _client = APIClient();
|
final APIClient _client = APIClient();
|
||||||
|
|
||||||
Future<String> getOpenAICompletion(String question) async {
|
Future<String> getOpenAICompletion(String question) async {
|
||||||
|
@ -111,7 +111,7 @@ class APIWebClient with Common, Logging {
|
|||||||
|
|
||||||
log(" ------------get response code: ${result.statusCode}");
|
log(" ------------get response code: ${result.statusCode}");
|
||||||
if (result.statusCode == 200) {
|
if (result.statusCode == 200) {
|
||||||
return utf8.decode(result.bodyBytes);
|
return result.body;
|
||||||
} else if (result.statusCode == 404) {
|
} else if (result.statusCode == 404) {
|
||||||
throw const NotFoundException(message: "Not Found");
|
throw const NotFoundException(message: "Not Found");
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: workouttest_util
|
name: workouttest_util
|
||||||
description: Workout Test app and web functions.
|
description: Workout Test app and web functions.
|
||||||
version: 1.0.24
|
version: 1.0.25
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.18.6 <3.0.0"
|
sdk: ">=2.18.6 <3.0.0"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:workouttest_util/model/cache.dart';
|
import 'package:workouttest_util/model/cache.dart';
|
||||||
import 'package:workouttest_util/model/openai.dart';
|
import 'package:workouttest_util/model/openai.dart';
|
||||||
@ -7,7 +8,8 @@ import 'package:workouttest_util/service/openai_service.dart';
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
setUp(() {
|
setUp(() async {
|
||||||
|
await dotenv.load(fileName: "assets/.env");
|
||||||
Cache().setDietTestBaseUrl();
|
Cache().setDietTestBaseUrl();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -49,7 +51,7 @@ void main() {
|
|||||||
"Te a Diet4You applikáció asszisztense vagy. Add meg ennek az ételnek a kalória és tápanyagadatait: 'Whopper'. A válasz ez az objektum JSON alakított formája legyen: Meal [mealName: string, calMin: double,calMax: double, chMin: double,chMax: double, fatMin: double,fatMax: double, proteinMin: double,proteinMax: double, sugar: double, portion: double, unit: string]. A portion paraméter azt tartalmazza, hogy ebből az ételből hány gramm v. ml az átlagos adag. A unit paraméter a 'portion' mennyiségi egysége";
|
"Te a Diet4You applikáció asszisztense vagy. Add meg ennek az ételnek a kalória és tápanyagadatait: 'Whopper'. A válasz ez az objektum JSON alakított formája legyen: Meal [mealName: string, calMin: double,calMax: double, chMin: double,chMax: double, fatMin: double,fatMax: double, proteinMin: double,proteinMax: double, sugar: double, portion: double, unit: string]. A portion paraméter azt tartalmazza, hogy ebből az ételből hány gramm v. ml az átlagos adag. A unit paraméter a 'portion' mennyiségi egysége";
|
||||||
OpenAIChatMessage message = OpenAIChatMessage(ChatRole.user, content);
|
OpenAIChatMessage message = OpenAIChatMessage(ChatRole.user, content);
|
||||||
String json = jsonEncode([message]);
|
String json = jsonEncode([message]);
|
||||||
var openai = OpenAIChat(json);
|
var openai = OpenAIChat(json, modelName: OpenAIApi().modelGpt4, temperature: 0.0);
|
||||||
|
|
||||||
String response = await api.getOpenAIChatCompletion(openai);
|
String response = await api.getOpenAIChatCompletion(openai);
|
||||||
print(response);
|
print(response);
|
||||||
|
Loading…
Reference in New Issue
Block a user