Create Chat bot application using Python, Streamlit and Gemini AI

In this article I am going to explain creating chat bot application using Python, Streamlit library and Gemini AI. In this chat bot application application will be self host with specific port on computer ad can be accessible from browser.



following Prerequisites required for development of this application :

  1. Visual studio code
  2. Python
  3. Api Key of Gemini can be obtain from  

Open visual studio code and create the file with name "". Now in visual studio code and go to terminal menu and click on New terminal link it will open new terminal. In terminal enter below command to install the Google generative AI library and steamlit library in your machine.


 pip install google-generativeai langchain-google-genai streamlit  

 Now copy below code and paste in the "" file.

 import streamlit as st  
 import google.generativeai as genai  
 genai.configure(api_key="enter your key obtain from")  
 st.title("Gemini chat app")  
 if "messages" not in st.session_state:  
       "content":"enter the question"  
 for message in st.session_state.messages:  
   with st.chat_message( message["role"]) :   
 def llmCall(query):  
    with st.chat_message("assistant"):  
       "role": "user",  
       "content": query  
       "role": "assistant",  
       "content": response.text  
 query=st.chat_input("what is your question?")  
 if query:  
    with st.chat_message("user"):  

Now enter below command to run the application.

 python -m stremlit run  

this will self host the application on your machine on with default port 8501 and application can be accessible by URL http://localhost:8501 as per below screenshot.


This way you can easily create the chat bot application with minimal code using python and streamlit library.



Popular posts from this blog

Implement Logging in CSV file using Nlog in .net core MVC application- part 2

Implement Nlog in .Net core MVC application part 1

Angular User Session Timeout example step by step

Devexpress Datebox date formatting in angular 6 with example

Disable backspace key using Jquery