update outstanding student graduate status and add chatbot testing page
This commit is contained in:
62
chatbot.py
Normal file
62
chatbot.py
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
import streamlit as st
|
||||||
|
from openai import OpenAI
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
# Set up the Streamlit app
|
||||||
|
st.title("BuffTeks Chatbot")
|
||||||
|
st.subheader("Chat with the [DeepSeek](https://www.deepseek.com/)-powered AI assistant!")
|
||||||
|
st.info("Feel free to chat with the chatbot! Just a heads up, you have 10 messages to use.")
|
||||||
|
with st.expander("See Source Code"):
|
||||||
|
with open(__file__, "r") as f:
|
||||||
|
st.code(f.read(), language="python")
|
||||||
|
|
||||||
|
# Load API credentials from config.json
|
||||||
|
with open('config.json') as config_file:
|
||||||
|
config = json.load(config_file)
|
||||||
|
openai_api_base_url = config["api_url"]
|
||||||
|
openai_api_key = config["api_key"]
|
||||||
|
|
||||||
|
client = OpenAI(api_key=openai_api_key, base_url=openai_api_base_url)
|
||||||
|
|
||||||
|
# Initialize session state to store chat history and message count
|
||||||
|
if "messages" not in st.session_state:
|
||||||
|
st.session_state.messages = []
|
||||||
|
if "message_count" not in st.session_state:
|
||||||
|
st.session_state.message_count = 0
|
||||||
|
|
||||||
|
# Set the maximum number of user messages
|
||||||
|
MAX_USER_MESSAGES = 10
|
||||||
|
|
||||||
|
# Display chat history
|
||||||
|
for message in st.session_state.messages:
|
||||||
|
with st.chat_message(message["role"]):
|
||||||
|
st.markdown(message["content"])
|
||||||
|
|
||||||
|
# Chat input
|
||||||
|
if st.session_state.message_count < MAX_USER_MESSAGES:
|
||||||
|
if prompt := st.chat_input("Type your message..."):
|
||||||
|
# Add user message to chat history
|
||||||
|
st.session_state.messages.append({"role": "user", "content": prompt})
|
||||||
|
st.session_state.message_count += 1
|
||||||
|
with st.chat_message("user"):
|
||||||
|
st.markdown(prompt)
|
||||||
|
|
||||||
|
# Call DeepSeek for a response
|
||||||
|
with st.chat_message("assistant"):
|
||||||
|
stream = client.chat.completions.create(
|
||||||
|
model="deepseek-chat",
|
||||||
|
messages=[
|
||||||
|
{"role": m["role"], "content": m["content"]}
|
||||||
|
for m in st.session_state.messages
|
||||||
|
],
|
||||||
|
stream=True,
|
||||||
|
)
|
||||||
|
response = st.write_stream(stream)
|
||||||
|
st.session_state.messages.append({"role": "assistant", "content": response})
|
||||||
|
|
||||||
|
else:
|
||||||
|
st.warning("You have reached the maximum number of messages allowed.")
|
||||||
|
|
||||||
|
if st.button("Clear Chat"):
|
||||||
|
st.session_state.messages = []
|
||||||
4
config.json
Normal file
4
config.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"api_url": "https://api.deepseek.com",
|
||||||
|
"api_key": "sk-12165b127043441697a8940918e207ac"
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -8,7 +8,7 @@ def outstanding_members():
|
|||||||
st.image("./images/StudentDarrian.jpg",width= 200 )
|
st.image("./images/StudentDarrian.jpg",width= 200 )
|
||||||
with stu1_text:
|
with stu1_text:
|
||||||
st.header("Darrian Lambert")
|
st.header("Darrian Lambert")
|
||||||
st.subheader("Senior Student in CIS")
|
st.subheader("2024 CIS Graduate")
|
||||||
|
|
||||||
st.markdown("""
|
st.markdown("""
|
||||||
"_Bufftek has been a fantastic experience for me. It gave me the opportunity to apply the skills I’ve learned in class to real-world problems and work alongside others to develop effective software solutions. Through this, I gained hands-on experience with skills that are difficult to practice on your own._
|
"_Bufftek has been a fantastic experience for me. It gave me the opportunity to apply the skills I’ve learned in class to real-world problems and work alongside others to develop effective software solutions. Through this, I gained hands-on experience with skills that are difficult to practice on your own._
|
||||||
@@ -27,7 +27,7 @@ def outstanding_members():
|
|||||||
st.image("./images/StudentKim.jpg",width= 200 )
|
st.image("./images/StudentKim.jpg",width= 200 )
|
||||||
with stu2_text:
|
with stu2_text:
|
||||||
st.header("Kim Sundblom")
|
st.header("Kim Sundblom")
|
||||||
st.subheader("Senior Student in CIS")
|
st.subheader("2024 CIS Graduate")
|
||||||
|
|
||||||
|
|
||||||
st.markdown("""
|
st.markdown("""
|
||||||
|
|||||||
Reference in New Issue
Block a user