Ollama Ai Chatbot
Ollama Ai Chatbot
Download a Model:
Run the following command to download the mode
# Set up Streamlit UI
st.title("Ollama AI Chatbot")
st.sidebar.header("Chat Settings")
# User input
user_input = st.text_input("Ask me anything:")
if st.button("Send") and user_input:
# Add user message to history
st.session_state.history.add_user_message(user_input)
# Get AI response
ai_response = llm.invoke(st.session_state.history.messages)
# Add AI message to history
st.session_state.history.add_ai_message(ai_response.content)
@st.cache_resource
def load_and_embed_docs(file):
"""Loads and embeds the document using FAISS."""
# Read the content of the uploaded file
file_content = file.read().decode("utf-8")
loader = TextLoader(file_like_object)
documents = loader.load()
return db.as_retriever()
if uploaded_file:
retriever = load_and_embed_docs(uploaded_file)