Spaces:
Runtime error
Runtime error
Kushwanth Chowday Kandala
commited on
Commit
•
6e57cc9
1
Parent(s):
23247c4
add create_embeddings functionality
Browse files
app.py
CHANGED
@@ -138,6 +138,19 @@ for i in st.session_state["chat_history"]:
|
|
138 |
# pinecone.init(api_key=PINECONE_API_KEY, environment=PINECONE_ENV)
|
139 |
# st.text(pinecone)
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
def print_out(pages):
|
142 |
for i in range(len(pages)):
|
143 |
text = pages[i].extract_text().strip()
|
@@ -153,6 +166,17 @@ def combine_text(pages):
|
|
153 |
mbsize = round(len(bytesize) / p, 2)
|
154 |
st.write(f"There are {len(concatenates_text)} characters in the pdf with {mbsize}MB size")
|
155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
with st.sidebar:
|
157 |
st.markdown("""
|
158 |
***Follow this steps***
|
@@ -161,7 +185,7 @@ with st.sidebar:
|
|
161 |
- Takes couple of mins after upload the pdf
|
162 |
- Now Chat with model to get the summarized info or Generative reponse
|
163 |
""")
|
164 |
-
uploaded_files = st.file_uploader('Choose your .pdf file', type="pdf", accept_multiple_files=True)
|
165 |
for uploaded_file in uploaded_files:
|
166 |
# To read file as bytes:
|
167 |
# bytes_data = uploaded_file.getvalue()
|
@@ -182,3 +206,4 @@ with st.sidebar:
|
|
182 |
pages = reader.pages
|
183 |
print_out(pages)
|
184 |
combine_text(pages)
|
|
|
|
138 |
# pinecone.init(api_key=PINECONE_API_KEY, environment=PINECONE_ENV)
|
139 |
# st.text(pinecone)
|
140 |
|
141 |
+
def create_embeddings():
|
142 |
+
# Get the uploaded file
|
143 |
+
uploaded_file = st.session_state["uploaded_file"]
|
144 |
+
|
145 |
+
# Read the contents of the file
|
146 |
+
file_contents = uploaded_file.read()
|
147 |
+
|
148 |
+
st.write("created_embeddings")
|
149 |
+
|
150 |
+
# Display the contents of the file
|
151 |
+
st.write(file_contents)
|
152 |
+
|
153 |
+
|
154 |
def print_out(pages):
|
155 |
for i in range(len(pages)):
|
156 |
text = pages[i].extract_text().strip()
|
|
|
166 |
mbsize = round(len(bytesize) / p, 2)
|
167 |
st.write(f"There are {len(concatenates_text)} characters in the pdf with {mbsize}MB size")
|
168 |
|
169 |
+
# def promt_engineer(text):
|
170 |
+
# promt_template = """
|
171 |
+
# write a concise summary of the following text delimited by triple backquotes.
|
172 |
+
# return your response in bullet points which convers the key points of the text.
|
173 |
+
|
174 |
+
# ```{text}```
|
175 |
+
|
176 |
+
# BULLET POINT SUMMARY:
|
177 |
+
# """
|
178 |
+
|
179 |
+
|
180 |
with st.sidebar:
|
181 |
st.markdown("""
|
182 |
***Follow this steps***
|
|
|
185 |
- Takes couple of mins after upload the pdf
|
186 |
- Now Chat with model to get the summarized info or Generative reponse
|
187 |
""")
|
188 |
+
uploaded_files = st.file_uploader('Choose your .pdf file', type="pdf", accept_multiple_files=True, key="uploaded_file", on_change=create_embeddings)
|
189 |
for uploaded_file in uploaded_files:
|
190 |
# To read file as bytes:
|
191 |
# bytes_data = uploaded_file.getvalue()
|
|
|
206 |
pages = reader.pages
|
207 |
print_out(pages)
|
208 |
combine_text(pages)
|
209 |
+
# promt_engineer(text)
|