Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,12 +14,34 @@ from langchain.memory import ConversationTokenBufferMemory
|
|
| 14 |
st.set_page_config(page_title="Chat with me")
|
| 15 |
st.markdown("<h1 style= 'text_align : center;'>How can I assist you? </h1>", unsafe_allow_html = True)
|
| 16 |
|
| 17 |
-
st.sidebar.title("
|
| 18 |
api_key = st.sidebar.text_input("Enter you API key",type = "password")
|
| 19 |
summarise_button = st.sidebar.button("Summarise",type = "summarise")
|
| 20 |
if summarise_button:
|
| 21 |
summarise_placeholder = st.sidebar.write("Thanks for chatting \n\n"+"Hi Friend")
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
llm = ChatOpenAI(
|
| 24 |
temperature=0,
|
| 25 |
model_name='gpt-3.5-turbo-0125'
|
|
|
|
| 14 |
st.set_page_config(page_title="Chat with me")
|
| 15 |
st.markdown("<h1 style= 'text_align : center;'>How can I assist you? </h1>", unsafe_allow_html = True)
|
| 16 |
|
| 17 |
+
st.sidebar.title("API")
|
| 18 |
api_key = st.sidebar.text_input("Enter you API key",type = "password")
|
| 19 |
summarise_button = st.sidebar.button("Summarise",type = "summarise")
|
| 20 |
if summarise_button:
|
| 21 |
summarise_placeholder = st.sidebar.write("Thanks for chatting \n\n"+"Hi Friend")
|
| 22 |
|
| 23 |
+
response_container = st.container()
|
| 24 |
+
container = st.container()
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
with container:
|
| 28 |
+
user_input = st.text_area("Your question goes here:", key='input', height=100)
|
| 29 |
+
submit_button = st.form_submit_button(label='Send')
|
| 30 |
+
|
| 31 |
+
if submit_button:
|
| 32 |
+
st.session_state['messages'].append(user_input)
|
| 33 |
+
model_response=getresponse(user_input,st.session_state['API_Key'])
|
| 34 |
+
st.session_state['messages'].append(model_response)
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
with response_container:
|
| 38 |
+
for i in range(len(st.session_state['messages'])):
|
| 39 |
+
if (i % 2) == 0:
|
| 40 |
+
message(st.session_state['messages'][i], is_user=True, key=str(i) + '_user')
|
| 41 |
+
else:
|
| 42 |
+
message(st.session_state['messages'][i], key=str(i) + '_AI')
|
| 43 |
+
|
| 44 |
+
|
| 45 |
llm = ChatOpenAI(
|
| 46 |
temperature=0,
|
| 47 |
model_name='gpt-3.5-turbo-0125'
|