Spaces:
Sleeping
Sleeping
Commit
·
662ba2f
1
Parent(s):
cf84de0
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,9 +2,7 @@ import streamlit as st
|
|
| 2 |
import time
|
| 3 |
from langchain.schema import HumanMessage, SystemMessage, AIMessage
|
| 4 |
from langchain.chat_models import ChatOpenAI
|
| 5 |
-
|
| 6 |
-
from pathlib import Path
|
| 7 |
-
import openai
|
| 8 |
|
| 9 |
|
| 10 |
def get_chatmodel_response(question):
|
|
@@ -17,7 +15,7 @@ def get_chatmodel_response(question):
|
|
| 17 |
st.session_state['flowmessages'].append(HumanMessage(content=question))
|
| 18 |
answer = chat(st.session_state['flowmessages'])
|
| 19 |
st.session_state['flowmessages'].append(AIMessage(content=answer.content))
|
| 20 |
-
return answer.content
|
| 21 |
except Exception as e:
|
| 22 |
print(f"Error: {e}")
|
| 23 |
if "Rate limit" in str(e):
|
|
@@ -81,14 +79,7 @@ if submit:
|
|
| 81 |
st.caption(input_question)
|
| 82 |
|
| 83 |
st.header("Sisi", divider=True)
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
# Generate speech using OpenAI API
|
| 87 |
-
response_audio_data = base64.b64decode(response_audio.split(',')[1])
|
| 88 |
-
st.audio(response_audio_data, format='audio/mp3')
|
| 89 |
-
|
| 90 |
-
# Add a download button for the audio
|
| 91 |
-
st.markdown(f"### [Download Audio](data:audio/mp3;base64,{base64.b64encode(response_audio_data).decode()})", unsafe_allow_html=True)
|
| 92 |
|
| 93 |
if response is not None:
|
| 94 |
|
|
|
|
| 2 |
import time
|
| 3 |
from langchain.schema import HumanMessage, SystemMessage, AIMessage
|
| 4 |
from langchain.chat_models import ChatOpenAI
|
| 5 |
+
|
|
|
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
def get_chatmodel_response(question):
|
|
|
|
| 15 |
st.session_state['flowmessages'].append(HumanMessage(content=question))
|
| 16 |
answer = chat(st.session_state['flowmessages'])
|
| 17 |
st.session_state['flowmessages'].append(AIMessage(content=answer.content))
|
| 18 |
+
return answer.content
|
| 19 |
except Exception as e:
|
| 20 |
print(f"Error: {e}")
|
| 21 |
if "Rate limit" in str(e):
|
|
|
|
| 79 |
st.caption(input_question)
|
| 80 |
|
| 81 |
st.header("Sisi", divider=True)
|
| 82 |
+
response = get_chatmodel_response(input_question)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
if response is not None:
|
| 85 |
|