Spaces:
Sleeping
Sleeping
File size: 893 Bytes
6ddeb4a 0aef548 cbb622b 6ddeb4a 7dcca7a cbb622b 18c34ed 7dcca7a cbb622b 7dcca7a b3b9f17 7dcca7a 6ddeb4a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import streamlit as st
import os
from langchain_huggingface import HuggingFaceEndpoint
st.set_page_config(page_title="Educational Chatbot")
st.title("๐ Educational Chatbot")
user_input = st.text_input("Ask me anything:")
if "history" not in st.session_state:
st.session_state.history = []
if user_input:
try:
llm = HuggingFaceEndpoint(
repo_id="mistralai/Mistral-7B-Instruct-v0.1",
huggingfacehub_api_token=os.environ.get("HUGGINGFACEHUB_API_TOKEN"),
temperature=0.5,
max_new_tokens=100,
)
response = llm.invoke(user_input)
st.session_state.history.append(("You", user_input))
st.session_state.history.append(("Bot", response))
except Exception as e:
st.error(f"โ ๏ธ Error: {e}")
for sender, msg in reversed(st.session_state.history):
st.markdown(f"**{sender}:** {msg}")
|