From 1169b028ba1fe75784f85175e43b1c258f401e5f Mon Sep 17 00:00:00 2001 From: ShubhamSaboo Date: Thu, 6 Jun 2024 21:24:39 -0500 Subject: [PATCH] Added new demo --- gemini_multimodal_chatbot/README.md | 28 ++++++++ .../gemini_multimodal_chatbot.py | 67 +++++++++++++++++++ gemini_multimodal_chatbot/requirements.txt | 3 + .../research_agent_llama3.py | 1 - 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 gemini_multimodal_chatbot/README.md create mode 100644 gemini_multimodal_chatbot/gemini_multimodal_chatbot.py create mode 100644 gemini_multimodal_chatbot/requirements.txt diff --git a/gemini_multimodal_chatbot/README.md b/gemini_multimodal_chatbot/README.md new file mode 100644 index 0000000..eef3674 --- /dev/null +++ b/gemini_multimodal_chatbot/README.md @@ -0,0 +1,28 @@ +## ⚡️ Multimodal Chatbot with Gemini Flash +This repository contains a Streamlit application that demonstrates a multimodal chatbot using Google's Gemini Flash model. The chatbot allows users to interact with the model using both image and text inputs, providing lightning-fast results. + +## Features +- Multimodal input: Users can upload images and enter text queries to interact with the chatbot. +- Gemini Flash model: The chatbot leverages Google's powerful Gemini Flash model for generating responses. +- Chat history: The application maintains a chat history, displaying the conversation between the user and the chatbot. + +### How to get Started? + +1. Clone the GitHub repository + +```bash +git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git +``` +2. Install the required dependencies: + +```bash +pip install -r requirements.txt +``` +3. Get your Google Studio API Key + +- Sign up for an [Google AI Studio](https://aistudio.google.com/app/apikey) and obtain your API key. + +4. Run the Streamlit App +```bash +streamlit run gemini_multimodal_chatbot.py +``` \ No newline at end of file diff --git a/gemini_multimodal_chatbot/gemini_multimodal_chatbot.py b/gemini_multimodal_chatbot/gemini_multimodal_chatbot.py new file mode 100644 index 0000000..4be4e59 --- /dev/null +++ b/gemini_multimodal_chatbot/gemini_multimodal_chatbot.py @@ -0,0 +1,67 @@ +import os +import streamlit as st +import google.generativeai as genai +from PIL import Image + +# Set up the Streamlit App +st.set_page_config(page_title="Multimodal Chatbot with Gemini Flash", layout="wide") +st.title("Multimodal Chatbot with Gemini Flash ⚡️") +st.caption("Chat with Google's Gemini Flash model using image and text input to get lightning fast results. 🌟") + +# Get OpenAI API key from user +api_key = st.text_input("Enter Google API Key", type="password") + +# Set up the Gemini model +genai.configure(api_key=api_key) +model = genai.GenerativeModel(model_name="gemini-1.5-flash-latest") + +if api_key: + # Initialize the chat history + if "messages" not in st.session_state: + st.session_state.messages = [] + + # Sidebar for image upload + with st.sidebar: + st.title("Chat with Images") + uploaded_file = st.file_uploader("Upload an image...", type=["jpg", "jpeg", "png"]) + + if uploaded_file: + image = Image.open(uploaded_file) + st.image(image, caption='Uploaded Image', use_column_width=True) + + # Main layout + chat_placeholder = st.container() + + with chat_placeholder: + # Display the chat history + for message in st.session_state.messages: + with st.chat_message(message["role"]): + st.markdown(message["content"]) + + # User input area at the bottom + prompt = st.chat_input("What do you want to know?") + + if prompt: + inputs = [prompt] + + # Add user message to chat history + st.session_state.messages.append({"role": "user", "content": prompt}) + # Display user message in chat message container + with chat_placeholder: + with st.chat_message("user"): + st.markdown(prompt) + + if uploaded_file: + inputs.append(image) + + with st.spinner('Generating response...'): + # Generate response + response = model.generate_content(inputs) + + # Display assistant response in chat message container + with chat_placeholder: + with st.chat_message("assistant"): + st.markdown(response.text) + + if uploaded_file and not prompt: + st.warning("Please enter a text query to accompany the image.") \ No newline at end of file diff --git a/gemini_multimodal_chatbot/requirements.txt b/gemini_multimodal_chatbot/requirements.txt new file mode 100644 index 0000000..76c7608 --- /dev/null +++ b/gemini_multimodal_chatbot/requirements.txt @@ -0,0 +1,3 @@ +streamlit +pillow +google-generativeai \ No newline at end of file diff --git a/multi_agent_researcher/research_agent_llama3.py b/multi_agent_researcher/research_agent_llama3.py index 778093f..96d55e0 100644 --- a/multi_agent_researcher/research_agent_llama3.py +++ b/multi_agent_researcher/research_agent_llama3.py @@ -8,7 +8,6 @@ from phi.llm.ollama import Ollama st.title("Multi-Agent AI Researcher using Llama-3 🔍🤖") st.caption("This app allows you to research top stories and users on HackerNews and write blogs, reports and social posts.") - # Create instances of the Assistant story_researcher = Assistant( name="HackerNews Story Researcher",