Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,11 @@
|
|
1 |
-
#
|
2 |
import streamlit as st
|
3 |
import PyPDF2
|
4 |
import openai
|
5 |
import faiss
|
6 |
import os
|
7 |
import numpy as np
|
8 |
-
import
|
9 |
-
import
|
10 |
|
11 |
# Function to extract text from a PDF file
|
12 |
def extract_text_from_pdf(pdf_file):
|
@@ -82,7 +81,7 @@ if openai_api_key:
|
|
82 |
|
83 |
# Get the GPT-4 response
|
84 |
response = openai.ChatCompletion.create(
|
85 |
-
model="gpt-
|
86 |
messages=[{"role": "user", "content": modified_prompt}]
|
87 |
)
|
88 |
|
@@ -91,16 +90,4 @@ if openai_api_key:
|
|
91 |
|
92 |
# Display the response in Streamlit (Intelligent Reply)
|
93 |
st.write("### Intelligent Reply:")
|
94 |
-
st.write(response_content)
|
95 |
-
|
96 |
-
# Capture a screenshot of the content displayed in Streamlit
|
97 |
-
# Wait for the UI to render
|
98 |
-
time.sleep(2) # Allow time for Streamlit to render the response
|
99 |
-
|
100 |
-
# Capture screenshot of the whole screen
|
101 |
-
screenshot = pyautogui.screenshot()
|
102 |
-
|
103 |
-
# Save the screenshot
|
104 |
-
screenshot.save("response_screenshot.png")
|
105 |
-
|
106 |
-
st.write("Screenshot has been saved as 'response_screenshot.png'.")
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import PyPDF2
|
3 |
import openai
|
4 |
import faiss
|
5 |
import os
|
6 |
import numpy as np
|
7 |
+
from sklearn.feature_extraction.text import TfidfVectorizer
|
8 |
+
from sklearn.metrics.pairwise import cosine_similarity
|
9 |
|
10 |
# Function to extract text from a PDF file
|
11 |
def extract_text_from_pdf(pdf_file):
|
|
|
81 |
|
82 |
# Get the GPT-4 response
|
83 |
response = openai.ChatCompletion.create(
|
84 |
+
model="gpt-4o-mini", # Update to GPT-4 (or your desired model)
|
85 |
messages=[{"role": "user", "content": modified_prompt}]
|
86 |
)
|
87 |
|
|
|
90 |
|
91 |
# Display the response in Streamlit (Intelligent Reply)
|
92 |
st.write("### Intelligent Reply:")
|
93 |
+
st.write(response_content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|