Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,27 @@ from sentence_transformers import SentenceTransformer, util
|
|
3 |
import openai
|
4 |
import os
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
7 |
|
8 |
# Initialize paths and model identifiers for easy configuration and maintenance
|
|
|
3 |
import openai
|
4 |
import os
|
5 |
|
6 |
+
import streamlit as st
|
7 |
+
from transformers import pipeline
|
8 |
+
|
9 |
+
# Initialize the pipeline
|
10 |
+
chatbot = pipeline("text-generation", model="gpt-3.5-turbo")
|
11 |
+
|
12 |
+
# Function to generate a response with bold text
|
13 |
+
def generate_response(input_text):
|
14 |
+
response = chatbot(input_text)[0]['generated_text']
|
15 |
+
# Add HTML tags for bold text
|
16 |
+
bolded_response = response.replace("**", "<b>").replace("**", "</b>")
|
17 |
+
return bolded_response
|
18 |
+
|
19 |
+
# Streamlit app
|
20 |
+
st.title("Chatbot")
|
21 |
+
|
22 |
+
user_input = st.text_input("You: ")
|
23 |
+
if user_input:
|
24 |
+
response = generate_response(user_input)
|
25 |
+
st.markdown(response, unsafe_allow_html=True)
|
26 |
+
|
27 |
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
28 |
|
29 |
# Initialize paths and model identifiers for easy configuration and maintenance
|