elia-waefler commited on
Commit
9d007c3
1 Parent(s): 7c520ae

gpt funktion

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -1,12 +1,10 @@
1
  import time
2
-
3
  import streamlit as st
4
  import os
5
  # import openai
6
  from PyPDF2 import PdfReader
7
  from openai import OpenAI
8
  from langchain.chat_models import ChatOpenAI
9
-
10
  ASK_ASH_PASSWORD = os.environ["ASK_ASH_PASSWORD"]
11
 
12
 
@@ -26,7 +24,7 @@ def gpt4_new(prompt_text):
26
  return response.choices[0].message.content
27
 
28
 
29
- # Define a function to ask a question to GPT-4
30
  def ask_gpt4(question):
31
  print(question) # we don't have to submit the question?
32
  try:
@@ -130,7 +128,8 @@ def main():
130
  st.write("Geschoss")
131
  st.write(f"")
132
  for file in uploaded_files:
133
- metadata = [file.name]
 
134
  with col1:
135
  with st.spinner("GPT4 at work"):
136
  pdf_text = str(get_pdf_text(file))
@@ -140,9 +139,8 @@ def main():
140
  except:
141
  answer_1 = "<err_no_classification>"
142
  print(prompt_1)
143
- metadata.append(answer_1)
144
  st.write(answer_1)
145
-
146
  with col2:
147
  with st.spinner("GPT4 at work"):
148
  prompt_2 = auftrag_0 + auftrag_1_type + str(Dokumententypen) + pdf_text
@@ -151,10 +149,9 @@ def main():
151
  except:
152
  answer_2 = "<err_no_classification>"
153
  print(prompt_2)
154
- metadata.append(answer_2)
155
 
156
  st.write(answer_2)
157
-
158
  with col3:
159
  with st.spinner("GPT4 at work"):
160
  prompt_3 = auftrag_0 + auftrag_1_ge + str(ASH_Geschosse) + pdf_text
@@ -163,10 +160,9 @@ def main():
163
  except:
164
  answer_3 = "<err_no_classification>"
165
  print(prompt_3)
166
- metadata.append(answer_2)
167
 
168
  st.write(answer_3)
169
-
170
  all_metadata.append(metadata)
171
 
172
  metadata_filename = "ai_generated_metadata.txt"
 
1
  import time
 
2
  import streamlit as st
3
  import os
4
  # import openai
5
  from PyPDF2 import PdfReader
6
  from openai import OpenAI
7
  from langchain.chat_models import ChatOpenAI
 
8
  ASK_ASH_PASSWORD = os.environ["ASK_ASH_PASSWORD"]
9
 
10
 
 
24
  return response.choices[0].message.content
25
 
26
 
27
+ # nicht aktuell
28
  def ask_gpt4(question):
29
  print(question) # we don't have to submit the question?
30
  try:
 
128
  st.write("Geschoss")
129
  st.write(f"")
130
  for file in uploaded_files:
131
+ metadata = []
132
+ metadata.append(str(file.name))
133
  with col1:
134
  with st.spinner("GPT4 at work"):
135
  pdf_text = str(get_pdf_text(file))
 
139
  except:
140
  answer_1 = "<err_no_classification>"
141
  print(prompt_1)
142
+ metadata.append(str(answer_1))
143
  st.write(answer_1)
 
144
  with col2:
145
  with st.spinner("GPT4 at work"):
146
  prompt_2 = auftrag_0 + auftrag_1_type + str(Dokumententypen) + pdf_text
 
149
  except:
150
  answer_2 = "<err_no_classification>"
151
  print(prompt_2)
152
+ metadata.append(str(answer_2))
153
 
154
  st.write(answer_2)
 
155
  with col3:
156
  with st.spinner("GPT4 at work"):
157
  prompt_3 = auftrag_0 + auftrag_1_ge + str(ASH_Geschosse) + pdf_text
 
160
  except:
161
  answer_3 = "<err_no_classification>"
162
  print(prompt_3)
163
+ metadata.append(str(answer_3))
164
 
165
  st.write(answer_3)
 
166
  all_metadata.append(metadata)
167
 
168
  metadata_filename = "ai_generated_metadata.txt"