Skip to content

Commit

Permalink
chatbot added
Browse files Browse the repository at this point in the history
  • Loading branch information
Saumya-28 committed Jun 12, 2024
1 parent 1fc7c5a commit ffe44cc
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 25 deletions.
19 changes: 13 additions & 6 deletions lib/ChatBotPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:google_generative_ai/google_generative_ai.dart';


const apiKey = 'Your Api Key';
const apiKey = 'put-gemini-api-key';


class ChatBotPage extends StatefulWidget {
Expand Down Expand Up @@ -39,12 +39,14 @@ class _ChatBotPageState extends State<ChatBotPage> {
if (_controller.text.isEmpty) return;




setState(() {
_messages.add({"sender": "user", "text": _controller.text});
_messages.add({"sender": "user", "text": "${_controller.text}"});
});


final prompt = _controller.text;
final prompt = _controller.text + "don't give answer in markdown format";
_controller.clear();


Expand Down Expand Up @@ -85,12 +87,17 @@ class _ChatBotPageState extends State<ChatBotPage> {
borderRadius: BorderRadius.circular(10.0),
),
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (!isUser) const CircleAvatar(child: Icon(Icons.android)),
if (!isUser) const SizedBox(width: 5.0),
Flexible(
child: Text(message["text"] ?? ''),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(message["text"] ?? ''),
],
),
),
if (isUser) const SizedBox(width: 5.0),
if (isUser) const CircleAvatar(child: Icon(Icons.person)),
Expand Down
Loading

0 comments on commit ffe44cc

Please sign in to comment.