ziyadsuper2017 commited on
Commit
e742fb1
1 Parent(s): dfb90bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -13
app.py CHANGED
@@ -7,7 +7,7 @@ from gtts import gTTS
7
  import google.generativeai as genai
8
 
9
  # Set your API key
10
- api_key = "YOUR_ACTUAL_API_KEY" # Replace with your actual API key
11
  genai.configure(api_key=api_key)
12
 
13
  # Configure the generative AI model
@@ -102,7 +102,7 @@ def send_message(tts=False):
102
  response_text = response.text if hasattr(response, "text") else "No response text found."
103
  if response_text:
104
  st.session_state['chat_history'].append({"role": "model", "parts": [{"text": response_text}]})
105
-
106
  # If TTS is enabled, convert the response text to speech
107
  if tts:
108
  tts = gTTS(text=response_text, lang='en')
@@ -160,17 +160,19 @@ download_button = st.download_button(
160
  st.session_state.uploaded_files = uploaded_files
161
 
162
  # JavaScript to capture the Ctrl+Enter event and trigger a button click
163
- st.markdown(
164
- """
165
- <script>
166
- // Use jQuery to capture the Ctrl+Enter event and click the 'Send' button
167
- $(document).on('keydown', 'textarea', function(e) {
168
- if (e.keyCode == 13 && e.ctrlKey) {
169
- $('button:contains("Send")').click();
 
170
  e.preventDefault();
171
  }
172
  });
173
- </script>
174
- """,
175
- unsafe_allow_html=True
176
- )
 
 
7
  import google.generativeai as genai
8
 
9
  # Set your API key
10
+ api_key = "AIzaSyC70u1sN87IkoxOoIj4XCAPw97ae2LZwNM" # Replace with your actual API key
11
  genai.configure(api_key=api_key)
12
 
13
  # Configure the generative AI model
 
102
  response_text = response.text if hasattr(response, "text") else "No response text found."
103
  if response_text:
104
  st.session_state['chat_history'].append({"role": "model", "parts": [{"text": response_text}]})
105
+
106
  # If TTS is enabled, convert the response text to speech
107
  if tts:
108
  tts = gTTS(text=response_text, lang='en')
 
160
  st.session_state.uploaded_files = uploaded_files
161
 
162
  # JavaScript to capture the Ctrl+Enter event and trigger a button click
163
+ st.markdown(
164
+ """
165
+ <script>
166
+ // Use jQuery to capture the Ctrl+Enter event and click the 'Send' button
167
+ document.addEventListener('DOMContentLoaded', (event) => {
168
+ document.querySelector('.stTextArea textarea').addEventListener('keydown', function(e) {
169
+ if (e.key === 'Enter' && e.ctrlKey) {
170
+ document.querySelector('.stButton > button').click();
171
  e.preventDefault();
172
  }
173
  });
174
+ });
175
+ </script>
176
+ """,
177
+ unsafe_allow_html=True
178
+ )