Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
import os
|
| 3 |
+
sys.path.append(os.path.abspath("src"))
|
| 4 |
+
import streamlit as st
|
| 5 |
+
from src.chatbot import generate_response
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
st.title("Fine-Tuned GPT Chatbot 🤖")
|
| 9 |
+
|
| 10 |
+
# Chat history
|
| 11 |
+
if "chat_history" not in st.session_state:
|
| 12 |
+
st.session_state.chat_history = []
|
| 13 |
+
|
| 14 |
+
# User input
|
| 15 |
+
user_input = st.text_input("Ask me anything:")
|
| 16 |
+
|
| 17 |
+
if st.button("Send"):
|
| 18 |
+
if user_input:
|
| 19 |
+
response = generate_response(user_input)
|
| 20 |
+
|
| 21 |
+
# Store conversation
|
| 22 |
+
st.session_state.chat_history.append(f"You: {user_input}")
|
| 23 |
+
st.session_state.chat_history.append(f"Bot: {response}")
|
| 24 |
+
|
| 25 |
+
# Display chat history
|
| 26 |
+
for msg in st.session_state.chat_history:
|
| 27 |
+
st.write(msg)
|