Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rsn601kri/gemini-chatbot
Chatbot using The chatbot leverages the capabilities of large language models to engage in meaningful conversations and provide responses to user queries. The guide covers the setup of your development environment, coding the Streamlit application, and deploying the chatbot on Streamlit
https://github.com/rsn601kri/gemini-chatbot
ai llm ml pycharm python streamlit-webapp
Last synced: 4 days ago
JSON representation
Chatbot using The chatbot leverages the capabilities of large language models to engage in meaningful conversations and provide responses to user queries. The guide covers the setup of your development environment, coding the Streamlit application, and deploying the chatbot on Streamlit
- Host: GitHub
- URL: https://github.com/rsn601kri/gemini-chatbot
- Owner: RSN601KRI
- Created: 2024-08-04T14:32:43.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2024-08-05T13:25:57.000Z (5 months ago)
- Last Synced: 2024-10-31T14:22:52.846Z (about 2 months ago)
- Topics: ai, llm, ml, pycharm, python, streamlit-webapp
- Language: Python
- Homepage: https://geminichatbotx.streamlit.app/
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Here’s a sample `README.md` file for your project:
---
# Chatbot with Google’s Gemini Pro and Streamlit
## Overview
This project demonstrates how to build a chatbot using Google’s Gemini Pro API and deploy it with Streamlit. The chatbot leverages the capabilities of large language models to engage in meaningful conversations and provide responses to user queries. The guide covers the setup of your development environment, coding the Streamlit application, and deploying the chatbot on Streamlit Cloud.
## Table of Contents
- [Introduction](#introduction)
- [Getting Started](#getting-started)
- [Setting Up the Development Environment](#setting-up-the-development-environment)
- [Writing the Streamlit Application](#writing-the-streamlit-application)
- [Testing the Application Locally](#testing-the-application-locally)
- [Deploying Your Chatbot on Streamlit Cloud](#deploying-your-chatbot-on-streamlit-cloud)
- [Contributing](#contributing)
- [License](#license)## Introduction
Large Language Models (LLMs) like Google’s Gemini Pro can understand and generate human-like text, making them ideal for chatbot development. Streamlit allows for easy creation of interactive web applications. This guide will help you integrate these technologies to build and deploy a functional chatbot.
## Getting Started
1. **Obtain an API Key from Google Gemini Pro:**
- Visit [Google AI Studio](https://ai.google).
- Create a new project.
- Generate an API key.
- Save the API key securely.2. **Set Up Your Development Environment:**
- Install Python on your machine.
- Set up a virtual environment using `venv`.
- Install necessary libraries with `pip`.## Setting Up the Development Environment
Create a project structure with the following files:
- `main.py`: The main application file.
- `requirements.txt`: Lists all dependencies.
- `.env`: Stores your API key.Install the required libraries:
```bash
pip install streamlit python-dotenv google-generative-ai
```Link Demo: https://vimeo.com/995034103/ff144ac6da
## Writing the Streamlit Application
1. **Import Required Libraries**:
```python
import streamlit as st
import os
from dotenv import load_dotenv
from google.generative_ai import ChatGPT
```2. **Load Environment Variables**:
```python
load_dotenv()
API_KEY = os.getenv("GOOGLE_API_KEY")
```3. **Configure the Streamlit App**:
```python
st.set_page_config(page_title="Chat with Gemini Pro", page_icon="🧠", layout="centered")
```4. **Create Chat Functionality**:
```python
def get_response(prompt):
response = ChatGPT.generate_response(prompt, api_key=API_KEY)
return response
```5. **Maintain Chat History**:
```python
if "history" not in st.session_state:
st.session_state.history = []
```6. **Display Chat Messages**:
```python
for msg in st.session_state.history:
st.write(msg)
```7. **Create User Input Field**:
```python
user_input = st.text_input("Ask Gemini Pro:")
if user_input:
response = get_response(user_input)
st.session_state.history.append(f"You: {user_input}")
st.session_state.history.append(f"Gemini Pro: {response}")
```## Testing the Application Locally
Run your application locally with:
```bash
streamlit run main.py
```Navigate to the provided local URL in your web browser to interact with your chatbot.
## Deploying Your Chatbot on Streamlit Cloud
1. **Create a Public Repository on GitHub:**
- Upload your project files.
- Ensure the `.env` file is configured correctly.2. **Deploy on Streamlit Cloud:**
- Sign in to Streamlit Cloud using your GitHub account.
- Create a new app and link it to your GitHub repository.
- Deploy the app and wait for the process to complete.After deployment, you will receive a URL to access your chatbot online.
## Contributing
Feel free to contribute to this project by submitting issues or pull requests. Your feedback and suggestions are welcome.
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.