Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,7 +38,39 @@ from templates import css, bot_template, user_template
|
|
| 38 |
st.set_page_config(page_title="GPT Streamlit Document Reasoner", layout="wide")
|
| 39 |
should_save = st.sidebar.checkbox("💾 Save", value=True)
|
| 40 |
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
def chat_with_model(prompt, document_section, model_choice='gpt-3.5-turbo'):
|
| 43 |
model = model_choice
|
| 44 |
conversation = [{'role': 'system', 'content': 'You are a helpful assistant.'}]
|
|
@@ -385,36 +417,6 @@ def read_file_content(file,max_length):
|
|
| 385 |
return file.getvalue().decode()
|
| 386 |
else:
|
| 387 |
return ""
|
| 388 |
-
|
| 389 |
-
def readitaloud(result):
|
| 390 |
-
documentHTML5='''
|
| 391 |
-
<!DOCTYPE html>
|
| 392 |
-
<html>
|
| 393 |
-
<head>
|
| 394 |
-
<title>Read It Aloud</title>
|
| 395 |
-
<script type="text/javascript">
|
| 396 |
-
function readAloud() {
|
| 397 |
-
const text = document.getElementById("textArea").value;
|
| 398 |
-
const speech = new SpeechSynthesisUtterance(text);
|
| 399 |
-
window.speechSynthesis.speak(speech);
|
| 400 |
-
}
|
| 401 |
-
</script>
|
| 402 |
-
</head>
|
| 403 |
-
<body>
|
| 404 |
-
<h1>🔊 Read It Aloud</h1>
|
| 405 |
-
<textarea id="textArea" rows="10" cols="80">
|
| 406 |
-
'''
|
| 407 |
-
documentHTML5 = documentHTML5 + result
|
| 408 |
-
documentHTML5 = documentHTML5 + '''
|
| 409 |
-
</textarea>
|
| 410 |
-
<br>
|
| 411 |
-
<button onclick="readAloud()">🔊 Read Aloud</button>
|
| 412 |
-
</body>
|
| 413 |
-
</html>
|
| 414 |
-
'''
|
| 415 |
-
|
| 416 |
-
components.html(documentHTML5, width=800, height=300)
|
| 417 |
-
#return result
|
| 418 |
|
| 419 |
def extract_mime_type(file):
|
| 420 |
# Check if the input is a string
|
|
|
|
| 38 |
st.set_page_config(page_title="GPT Streamlit Document Reasoner", layout="wide")
|
| 39 |
should_save = st.sidebar.checkbox("💾 Save", value=True)
|
| 40 |
|
| 41 |
+
|
| 42 |
+
# Read it aloud
|
| 43 |
+
def readitaloud(result):
|
| 44 |
+
documentHTML5='''
|
| 45 |
+
<!DOCTYPE html>
|
| 46 |
+
<html>
|
| 47 |
+
<head>
|
| 48 |
+
<title>Read It Aloud</title>
|
| 49 |
+
<script type="text/javascript">
|
| 50 |
+
function readAloud() {
|
| 51 |
+
const text = document.getElementById("textArea").value;
|
| 52 |
+
const speech = new SpeechSynthesisUtterance(text);
|
| 53 |
+
window.speechSynthesis.speak(speech);
|
| 54 |
+
}
|
| 55 |
+
</script>
|
| 56 |
+
</head>
|
| 57 |
+
<body>
|
| 58 |
+
<h1>🔊 Read It Aloud</h1>
|
| 59 |
+
<textarea id="textArea" rows="10" cols="80">
|
| 60 |
+
'''
|
| 61 |
+
documentHTML5 = documentHTML5 + result
|
| 62 |
+
documentHTML5 = documentHTML5 + '''
|
| 63 |
+
</textarea>
|
| 64 |
+
<br>
|
| 65 |
+
<button onclick="readAloud()">🔊 Read Aloud</button>
|
| 66 |
+
</body>
|
| 67 |
+
</html>
|
| 68 |
+
'''
|
| 69 |
+
|
| 70 |
+
components.html(documentHTML5, width=800, height=300)
|
| 71 |
+
#return result
|
| 72 |
+
|
| 73 |
+
# Chat and Chat with files
|
| 74 |
def chat_with_model(prompt, document_section, model_choice='gpt-3.5-turbo'):
|
| 75 |
model = model_choice
|
| 76 |
conversation = [{'role': 'system', 'content': 'You are a helpful assistant.'}]
|
|
|
|
| 417 |
return file.getvalue().decode()
|
| 418 |
else:
|
| 419 |
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 420 |
|
| 421 |
def extract_mime_type(file):
|
| 422 |
# Check if the input is a string
|