Skip to content

Commit

Permalink
feat: enable logs
Browse files Browse the repository at this point in the history
  • Loading branch information
drochetti committed Oct 31, 2023
1 parent 6792a45 commit 4472cb9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
19 changes: 11 additions & 8 deletions lib/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,20 @@ class FalClient implements Client {
onEnqueue(requestId);
}

return _pollForResult(id,
requestId: requestId,
pollInterval: pollInterval,
onQueueUpdate: onQueueUpdate,
timeout: timeout);
return _pollForResult(
id,
requestId: requestId,
logs: logs,
pollInterval: pollInterval,
timeout: timeout,
onQueueUpdate: onQueueUpdate,
);
}

Future<Map<String, dynamic>> _pollForResult(
String id, {
required String requestId,
required bool logs,
required int pollInterval,
required int timeout,
Function(QueueStatus)? onQueueUpdate,
Expand All @@ -93,7 +97,8 @@ class FalClient implements Client {
message: 'Request timed out after \$timeout milliseconds.',
status: 408);
}
final queueStatus = await queue.status(id, requestId: requestId);
final queueStatus =
await queue.status(id, requestId: requestId, logs: logs);

if (onQueueUpdate != null) {
onQueueUpdate(queueStatus);
Expand All @@ -106,5 +111,3 @@ class FalClient implements Client {
}
}
}

// final fal = FalClient(config: DEFAULT_CONFIG);
9 changes: 6 additions & 3 deletions lib/queue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ abstract class QueueStatus {
}

class InProgressStatus extends QueueStatus {
List<RequestLog> logs;
List<RequestLog>? logs;

InProgressStatus({
required String responseUrl,
Expand All @@ -67,7 +67,7 @@ class InProgressStatus extends QueueStatus {
}

class CompletedStatus extends QueueStatus {
List<RequestLog> logs;
List<RequestLog>? logs;

CompletedStatus({
required String responseUrl,
Expand Down Expand Up @@ -135,7 +135,10 @@ class QueueClient implements Queue {
final result = await sendRequest(id,
config: config,
method: 'get',
path: '/fal/queue/requests/$requestId/status');
path: '/fal/queue/requests/$requestId/status',
input: {
'logs': logs ? '1' : '0',
});
return QueueStatus.fromMap(result);
}

Expand Down
11 changes: 11 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ name: fal_client
description: A client library for fal.ai ML APIs
version: 0.1.0
homepage: fal.ai
topics:
- machine learning
- artificial intelligence
- ml
- ai
- stable-diffusion
- sdxl
- whisper
- text-to-image
- image-to-text
- speech-to-text

environment:
sdk: '>=3.1.5 <4.0.0'
Expand Down
2 changes: 1 addition & 1 deletion sample_app/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void main() {
expect(find.text('1'), findsNothing);

// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.tap(find.byIcon(Icons.play_arrow_rounded));
await tester.pump();

// Verify that our counter has incremented.
Expand Down

0 comments on commit 4472cb9

Please sign in to comment.