mirror of
https://github.com/foss42/apidash.git
synced 2025-12-01 10:17:47 +08:00
Integrated AI Chatbot Widget
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:apidash/providers/providers.dart';
|
||||
import 'package:apidash/widgets/widgets.dart';
|
||||
import 'package:apidash/consts.dart';
|
||||
import '../widgets/chatbot_widget.dart';
|
||||
import 'common_widgets/common_widgets.dart';
|
||||
import 'envvar/environment_page.dart';
|
||||
import 'home_page/home_page.dart';
|
||||
@@ -124,6 +125,19 @@ class Dashboard extends ConsumerWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
// Add this to your DashboardScreen's build method:
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
builder: (context) => const Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: ChatbotWidget(),
|
||||
),
|
||||
),
|
||||
child: const Icon(Icons.help_outline),
|
||||
),
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@ class ResponseDetails extends ConsumerWidget {
|
||||
.watch(selectedRequestModelProvider.select((value) => value?.message));
|
||||
final responseModel = ref.watch(selectedRequestModelProvider
|
||||
.select((value) => value?.httpResponseModel));
|
||||
final ollamaService = ref.watch(ollamaServiceProvider);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
ResponsePaneHeader(
|
||||
@@ -67,6 +69,25 @@ class ResponseDetails extends ConsumerWidget {
|
||||
const Expanded(
|
||||
child: ResponseTabs(),
|
||||
),
|
||||
if (responseModel?.body != null) // Show button only if a response exists
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ElevatedButton(
|
||||
onPressed: () async {
|
||||
final explanation = await ollamaService.explainApiResponse(
|
||||
responseModel!.body as Map<String, dynamic>, // Pass the actual response data
|
||||
);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Explanation'),
|
||||
content: Text(explanation),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const Text('Explain Response'),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user