v1.0.2 open AI support
This commit is contained in:
parent
9782a1ca46
commit
837eda2997
File diff suppressed because one or more lines are too long
43
README.md
43
README.md
@ -1,39 +1,10 @@
|
||||
<!--
|
||||
This README describes the package. If you publish this package to pub.dev,
|
||||
this README's contents appear on the landing page for your package.
|
||||
Workout Test and Diet 4 You Common Util Functions
|
||||
|
||||
For information about how to write a good package README, see the guide for
|
||||
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages).
|
||||
Version 1.0.2
|
||||
Open AI API support
|
||||
|
||||
For general information about developing packages, see the Dart guide for
|
||||
[creating packages](https://dart.dev/guides/libraries/create-library-packages)
|
||||
and the Flutter guide for
|
||||
[developing packages and plugins](https://flutter.dev/developing-packages).
|
||||
-->
|
||||
Version 1.0.1
|
||||
changes from aitrainer_app 1.1.29 working copy
|
||||
|
||||
TODO: Put a short description of the package here that helps potential users
|
||||
know whether this package might be useful for them.
|
||||
|
||||
## Features
|
||||
|
||||
TODO: List what your package can do. Maybe include images, gifs, or videos.
|
||||
|
||||
## Getting started
|
||||
|
||||
TODO: List prerequisites and provide or point to information on how to
|
||||
start using the package.
|
||||
|
||||
## Usage
|
||||
|
||||
TODO: Include short and useful examples for package users. Add longer examples
|
||||
to `/example` folder.
|
||||
|
||||
```dart
|
||||
const like = 'sample';
|
||||
```
|
||||
|
||||
## Additional information
|
||||
|
||||
TODO: Tell users more about the package: where to find more information, how to
|
||||
contribute to the package, how to file issues, what response they can expect
|
||||
from the package authors, and more.
|
||||
Version 1.0.0
|
||||
outsourced from aitrainer_app 1.1.28
|
22
lib/service/openai_service.dart
Normal file
22
lib/service/openai_service.dart
Normal file
@ -0,0 +1,22 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:workouttest_util/service/api.dart';
|
||||
import 'package:workouttest_util/util/logging.dart';
|
||||
|
||||
|
||||
class OpenAIApi with Logging {
|
||||
final APIClient _client = APIClient();
|
||||
|
||||
Future<String> getOpenAICompletion(String question) async {
|
||||
String? response;
|
||||
try {
|
||||
final body = await _client.post("openai/completion", question);
|
||||
response = 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.1
|
||||
version: 1.0.2
|
||||
homepage:
|
||||
|
||||
environment:
|
||||
|
19
test/openai_test.dart
Normal file
19
test/openai_test.dart
Normal file
@ -0,0 +1,19 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:workouttest_util/model/cache.dart';
|
||||
import 'package:workouttest_util/service/openai_service.dart';
|
||||
|
||||
|
||||
void main() {
|
||||
setUp(() {
|
||||
Cache().setLocalBaseUrl();
|
||||
});
|
||||
|
||||
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')));
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user