Spaces:
Runtime error
Runtime error
Matias Stager
commited on
Commit
·
f79eaae
1
Parent(s):
ef2577b
Update 1
Browse files- .steamlit/config.toml +5 -0
- app.py +38 -23
- requirements.txt +2 -1
.steamlit/config.toml
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[theme]
|
| 2 |
+
|
| 3 |
+
primaryColor = '#FF8C02' # Bright Orange
|
| 4 |
+
backgroundColor = '#00325B' # Dark Blue
|
| 5 |
+
secondaryBackgroundColor = '#55B2FF' # Lighter Blue
|
app.py
CHANGED
|
@@ -8,7 +8,7 @@ import openai
|
|
| 8 |
|
| 9 |
openai.api_key = os.getenv('openai_key')
|
| 10 |
|
| 11 |
-
st.title("ChileanGPT: An Experimental Chilean AI Language Model")
|
| 12 |
st.subheader("Leveraging the Power of GPT-Enhanced for Natural Chilean Spanish Dialogues")
|
| 13 |
hide_footer_style = """
|
| 14 |
<style>
|
|
@@ -21,33 +21,48 @@ if 'generated' not in st.session_state:
|
|
| 21 |
st.session_state['generated'] = []
|
| 22 |
if 'past' not in st.session_state:
|
| 23 |
st.session_state['past'] = []
|
| 24 |
-
|
| 25 |
if 'interaction_count' not in st.session_state:
|
| 26 |
st.session_state['interaction_count'] = 0
|
| 27 |
-
|
| 28 |
-
query = st.text_input("Escribe algo:", key="input")
|
| 29 |
-
|
| 30 |
if 'messages' not in st.session_state:
|
| 31 |
st.session_state['messages'] = get_initial_message()
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
# with st.expander("session_state"):
|
| 53 |
# st.write(st.session_state)
|
|
|
|
| 8 |
|
| 9 |
openai.api_key = os.getenv('openai_key')
|
| 10 |
|
| 11 |
+
st.title("ChileanGPT 2.0: An Experimental Chilean AI Language Model")
|
| 12 |
st.subheader("Leveraging the Power of GPT-Enhanced for Natural Chilean Spanish Dialogues")
|
| 13 |
hide_footer_style = """
|
| 14 |
<style>
|
|
|
|
| 21 |
st.session_state['generated'] = []
|
| 22 |
if 'past' not in st.session_state:
|
| 23 |
st.session_state['past'] = []
|
|
|
|
| 24 |
if 'interaction_count' not in st.session_state:
|
| 25 |
st.session_state['interaction_count'] = 0
|
|
|
|
|
|
|
|
|
|
| 26 |
if 'messages' not in st.session_state:
|
| 27 |
st.session_state['messages'] = get_initial_message()
|
| 28 |
|
| 29 |
+
|
| 30 |
+
def generate_response(_input_user):
|
| 31 |
+
if _input_user:
|
| 32 |
+
with st.spinner("pensando..."):
|
| 33 |
+
st.session_state['interaction_count'] += 1
|
| 34 |
+
messages = st.session_state['messages']
|
| 35 |
+
messages = update_chat(messages, "user", _input_user, st.session_state['interaction_count'])
|
| 36 |
+
# st.write("Before making the API call")
|
| 37 |
+
# st.write(messages)
|
| 38 |
+
response = get_chatgpt_response(messages,"gpt-4")
|
| 39 |
+
messages = update_chat(messages, "assistant", response, st.session_state['interaction_count'])
|
| 40 |
+
return response
|
| 41 |
+
|
| 42 |
+
# container for chat history
|
| 43 |
+
response_container = st.container()
|
| 44 |
+
# container for text box
|
| 45 |
+
container = st.container()
|
| 46 |
+
|
| 47 |
+
with container:
|
| 48 |
+
with st.form("chat_input", clear_on_submit=True):
|
| 49 |
+
a, b = st.columns([4, 1])
|
| 50 |
+
user_input = a.text_input(
|
| 51 |
+
label="Mensaje:",
|
| 52 |
+
placeholder="Escribe algo...",
|
| 53 |
+
label_visibility="collapsed",
|
| 54 |
+
)
|
| 55 |
+
submit_button = b.form_submit_button("Send", use_container_width=True)
|
| 56 |
+
if user_input or submit_button:
|
| 57 |
+
output = generate_response(user_input)
|
| 58 |
+
st.session_state.generated.append(output)
|
| 59 |
+
st.session_state.past.append(user_input)
|
| 60 |
+
|
| 61 |
+
if st.session_state['generated']:
|
| 62 |
+
with response_container:
|
| 63 |
+
for i in range(len(st.session_state['generated'])):
|
| 64 |
+
message(st.session_state['past'][i], is_user=True, key=str(i) + '_user')
|
| 65 |
+
message(st.session_state["generated"][i], key=str(i))
|
| 66 |
|
| 67 |
# with st.expander("session_state"):
|
| 68 |
# st.write(st.session_state)
|
requirements.txt
CHANGED
|
@@ -3,4 +3,5 @@ altair < 5
|
|
| 3 |
streamlit_chat
|
| 4 |
openai
|
| 5 |
python-dotenv
|
| 6 |
-
helicone
|
|
|
|
|
|
| 3 |
streamlit_chat
|
| 4 |
openai
|
| 5 |
python-dotenv
|
| 6 |
+
helicone
|
| 7 |
+
langchain
|