chat_bot_llm 0.0.8-prerelease.2 chat_bot_llm: ^0.0.8-prerelease.2 copied to clipboard
A Flutter plugin to integrate ChatBot LLM. This Plugin provides a chat interface to interact with the ChatBot LLM.
import 'package:chat_bot_llm/chat_bot_llm.dart';
import 'package:example/assistant_constants.dart';
import 'package:fimber/fimber.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:uuid/uuid.dart';
part 'color_schemes.g.dart';
const String appName = "ChatBot Example";
void main() async {
await ChatBotLlm.initialize(
"com.chatbotllm.example", appName, ASSISTANT_ID, ASSISTANT_NAME, false,
appLogo: "assets/delete.png");
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return GetMaterialApp(
title: appName,
theme: ThemeData.from(colorScheme: lightColorScheme, useMaterial3: true),
darkTheme:
ThemeData.from(colorScheme: darkColorScheme, useMaterial3: true),
themeMode: ThemeMode.system,
home: const MyHomePage(title: appName),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: const Center(child: Text(appName)),
floatingActionButton: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
FloatingActionButton.extended(
heroTag: "all_chats",
onPressed: () async {
// Open Conversations page
if (!ChatBotLlm.isInitialised()) {
Fimber.d("Initializing ChatBotLlm");
await ChatBotLlm.initialize("com.chatbotllm.example", appName,
ASSISTANT_ID, ASSISTANT_NAME, false);
}
String userId = Uuid().v4();
await ChatBotLlm.openAllChatsScreen(context, userId);
},
tooltip: "All Chats",
icon: const Icon(Icons.list),
label: const Text("All Chats"),
),
const SizedBox(height: 16),
FloatingActionButton.extended(
heroTag: "chat",
onPressed: () async {
// Open Chat page
if (!ChatBotLlm.isInitialised()) {
Fimber.d("Initializing ChatBotLlm");
await ChatBotLlm.initialize("com.chatbotllm.example", appName,
ASSISTANT_ID, ASSISTANT_NAME, false);
}
String userId = Uuid().v4();
await ChatBotLlm.openConversationScreen(context, userId);
},
tooltip: "Open Chat",
icon: const Icon(Icons.message),
label: const Text("Open Chat"),
),
],
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}