v1.0.7 openai with model name and temperature
This commit is contained in:
parent
56ada3c774
commit
cb90c3d68a
@ -1,5 +1,8 @@
|
||||
Workout Test and Diet 4 You Common Util Functions
|
||||
|
||||
Version 1.0.7
|
||||
openai with model name and temperature
|
||||
|
||||
Version 1.0.6
|
||||
membership, customer_membership
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
class Membership {
|
||||
late int membershipId;
|
||||
late String name;
|
||||
late String description;
|
||||
String? description;
|
||||
late int duration;
|
||||
late String durationType;
|
||||
late String durationUnit;
|
||||
@ -12,12 +12,12 @@ class Membership {
|
||||
Membership.fromJson(Map json) {
|
||||
membershipId = json['membershipId'];
|
||||
name = json['name'];
|
||||
description = json['description'];
|
||||
description = json['description'] ?? "";
|
||||
duration = json['duration'];
|
||||
durationUnit = json['durationUnit'];
|
||||
durationType = json['durationType'];
|
||||
trainingPlanId = json['trainingPlanId'];
|
||||
trainingPlanDayIds = json['trainingPlanDayIds'];
|
||||
trainingPlanId = json['trainingPlanId'] ?? 0;
|
||||
trainingPlanDayIds = json['trainingPlanDayIds'] ?? 0;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
|
22
lib/model/openai.dart
Normal file
22
lib/model/openai.dart
Normal file
@ -0,0 +1,22 @@
|
||||
class OpenAI {
|
||||
late String question;
|
||||
late String modelName;
|
||||
late double temperature;
|
||||
|
||||
OpenAI(this.question, this.modelName, this.temperature);
|
||||
|
||||
OpenAI.fromJson(Map json) {
|
||||
question = json['question'];
|
||||
modelName = json['modelName'];
|
||||
temperature = json['temperature'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"question": question,
|
||||
"modelName": modelName,
|
||||
"temperature": temperature,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() => toJson().toString();
|
||||
}
|
@ -7,11 +7,11 @@ class Product {
|
||||
late int sort;
|
||||
late int productSet;
|
||||
late DateTime validFrom;
|
||||
late DateTime? validTo;
|
||||
late String? productIdIos;
|
||||
late String? productIdAndroid;
|
||||
late double? priceIos;
|
||||
late double? priceAndroid;
|
||||
DateTime? validTo;
|
||||
String? productIdIos;
|
||||
String? productIdAndroid;
|
||||
double? priceIos;
|
||||
double? priceAndroid;
|
||||
String? localizedPrice;
|
||||
|
||||
Product.fromJson(Map json) {
|
||||
@ -24,10 +24,10 @@ class Product {
|
||||
productSet = json['productSet'];
|
||||
validFrom = (json['validFrom'] == null ? null : DateTime.parse(json['validFrom']))!;
|
||||
validTo = json['validTo'] == null ? null : DateTime.parse(json['validTo']);
|
||||
productIdIos = json['productIdIos'];
|
||||
productIdAndroid = json['productIdAndroid'];
|
||||
priceIos = json['priceIos'];
|
||||
priceAndroid = json['priceAndroid'];
|
||||
productIdIos = json['productIdIos'] ?? 0.0;
|
||||
productIdAndroid = json['productIdAndroid'] ?? 0.0;
|
||||
priceIos = json['priceIos'] ?? 0.0;
|
||||
priceAndroid = json['priceAndroid'] ?? 0.0;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -1,8 +1,8 @@
|
||||
class Property {
|
||||
late int propertyId;
|
||||
late String propertyName;
|
||||
late String propertyUnit;
|
||||
late String propertyNameTranslation;
|
||||
String? propertyUnit;
|
||||
String? propertyNameTranslation;
|
||||
int? top;
|
||||
int? left;
|
||||
double? value;
|
||||
@ -10,7 +10,7 @@ class Property {
|
||||
Property.fromJson(Map json) {
|
||||
propertyId = json['propertyId'];
|
||||
propertyName = json['propertyName'];
|
||||
propertyUnit = json['propertyUnit'];
|
||||
propertyUnit = json['propertyUnit'] ?? "";
|
||||
propertyNameTranslation =
|
||||
json['translations'] != null && (json['translations']).length > 0
|
||||
? json['translations'][0]['propertyName']
|
||||
|
@ -20,9 +20,9 @@ class TrainingPlan {
|
||||
TrainingPlan.fromJson(Map<String, dynamic> json) {
|
||||
trainingPlanId = json['trainingPlanId'];
|
||||
name = json['name'];
|
||||
type = json['type'];
|
||||
internalName = json['internalName'];
|
||||
description = json['description'];
|
||||
type = json['type'] ?? "";
|
||||
internalName = json['internalName'] ?? "";
|
||||
description = json['description'] ?? "";
|
||||
free = json['free'];
|
||||
active = json['active'];
|
||||
treeId = json['treeId'];
|
||||
|
@ -1,5 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:workouttest_util/model/openai.dart';
|
||||
import 'package:workouttest_util/service/api.dart';
|
||||
import 'package:workouttest_util/util/logging.dart';
|
||||
|
||||
@ -19,4 +21,17 @@ class OpenAIApi with Logging {
|
||||
}
|
||||
return response ?? "";
|
||||
}
|
||||
|
||||
Future<String> getOpenAICompletionWithModel(OpenAI openai) async {
|
||||
String? response;
|
||||
try {
|
||||
String body = const JsonEncoder().convert(openai.toJson());
|
||||
response = await _client.post("openai/completion_with_model", body);
|
||||
} on TimeoutException catch (_) {
|
||||
log("Timeout from OpenAI");
|
||||
} on Exception catch (e) {
|
||||
log(e.toString());
|
||||
}
|
||||
return response ?? "";
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
name: workouttest_util
|
||||
description: Workout Test app and web functions.
|
||||
version: 1.0.6
|
||||
version: 1.0.7
|
||||
homepage:
|
||||
|
||||
environment:
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:workouttest_util/model/cache.dart';
|
||||
import 'package:workouttest_util/model/openai.dart';
|
||||
import 'package:workouttest_util/service/openai_service.dart';
|
||||
|
||||
|
||||
@ -9,11 +10,18 @@ void main() {
|
||||
});
|
||||
|
||||
test('openai response succesful', () async {
|
||||
|
||||
|
||||
var api = OpenAIApi();
|
||||
String response = await api.getOpenAICompletion("Who wrote the song 'yellow submarine'?");
|
||||
print(response);
|
||||
expect(response, matches(RegExp(r'Beatles') ));
|
||||
});
|
||||
|
||||
test('openai with model response succesful', () async {
|
||||
var api = OpenAIApi();
|
||||
String question = "Készíts egy heti egészséges és változatos étrendet egy új felhasználónak az alábbi adatok alapján: férfi, 51 éves. Célja: Le szeretnék fogyni, heti mozgás: Hetente 3-4 alkalom, BMI: 24.784257517393772, BMR: 1723.75. A neve Tibi. Az egyes étkezések különbözőek legyenek, és add meg hozzájuk a mennyiséget és a kalóriatartalmat is. Vedd figyelembe, hogy a napi összes kalóriaérték 200-400 kCal-val kevesebb legyen, mint 1723.75 kCal";
|
||||
var openai = OpenAI(question, "text-davinci-003", 0.5);
|
||||
String response = await api.getOpenAICompletionWithModel(openai);
|
||||
print(response);
|
||||
expect(response, matches(RegExp(r'Tibi') ));
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user