Open Yash-Jaiswal28 opened 3 months ago
import streamlit as st import google.generativeai as genai
API_KEY="AIzaSyAaJDwomvkK-XJmh8rr9uN7uauxNos1urQ"
genai.configure(api_key=API_KEY)
model=genai.GenerativeModel("gemini-pro") chat = model.start_chat(history=[])
def get_gemini_response(question): response = chat.send_message(question,stream = True) return response
st.set_page_config(page_title="Baat_Cheet")
st.header("Yash_Baat_Cheet")
if 'chat_history' not in st.session_state: st.session_state['chat_history'] = []
input = st.text_input("Input:", key="input") submit= st.button("Ask the question")
if submit and input: response = get_gemini_response(input)
st.session_state['chat_history'].append(("You",input)) st.subheader("The response is") for chunk in response:
full_response = chunk.text
st.write(full_response)
st.session_state['chat_history'].append(("bot",full_response))
st.subheader("The chat history is")
for role,text in st.session_state['chat_history']: st.write(f"{role}: {text}")
In each model responses, it have a missing the first word with them.