Issue with using Gemini as chat_engine
Code:
from llama_index.llms.gemini import Gemini
if "chat_engine" not in st.session_state.keys(): # Initialize the chat engine
print("Chat Engine Created")
st.session_state.chat_engine = index.as_chat_engine(chat_mode = "best", llm = Gemini(), verbose=True)
if st.session_state.messages[-1]["role"] != "assistant":
with st.chat_message("assistant"):
with st.spinner("Thinking..."):
response = st.session_state.chat_engine.chat(prompt)
print(response)
st.write(response.response)
message = {"role": "assistant", "content": response.response}
st.session_state.messages.append(message) # Add response to message history