alexkueck commited on
Commit
1c79a7c
1 Parent(s): 4e21196

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -27,11 +27,8 @@ _ = load_dotenv(find_dotenv())
27
  #api_key=os.getenv("OPENAI_API_KEY"),
28
  #)
29
 
30
-
31
-
32
-
33
-
34
- #openai.api_key = os.getenv["OPENAI_API_KEY"]
35
 
36
  #Für MongoDB statt Chroma als Vektorstore
37
  #MONGODB_URI = os.environ["MONGODB_ATLAS_CLUSTER_URI"]
@@ -63,9 +60,11 @@ YOUTUBE_URL_1 = "https://www.youtube.com/watch?v=--khbXchTeE"
63
  YOUTUBE_URL_2 = "https://www.youtube.com/watch?v=hdhZwyf24mE"
64
  YOUTUBE_URL_3 = "https://www.youtube.com/watch?v=vw-KWfKwvTQ"
65
 
66
- MODEL_NAME = "gpt-3.5-turbo-16k"
 
67
 
68
  def document_loading_splitting():
 
69
  # Document loading
70
  docs = []
71
  # Load PDF
@@ -127,6 +126,8 @@ def rag_chain(llm, prompt, db):
127
  return result["result"]
128
 
129
  def invoke(openai_api_key, rag_option, prompt):
 
 
130
  if (openai_api_key == "" or openai_api_key == "sk-"):
131
  #raise gr.Error("OpenAI API Key is required.")
132
  openai_api_key= OAI_API_KEY
@@ -140,8 +141,9 @@ def invoke(openai_api_key, rag_option, prompt):
140
  temperature = 0)
141
  if (rag_option == "Chroma"):
142
  #muss nur einmal ausgeführt werden...
143
- #splits = document_loading_splitting()
144
- #document_storage_chroma(splits)
 
145
  db = document_retrieval_chroma(llm, prompt)
146
  result = rag_chain(llm, prompt, db)
147
  elif (rag_option == "MongoDB"):
 
27
  #api_key=os.getenv("OPENAI_API_KEY"),
28
  #)
29
 
30
+ #nur bei ersten Anfrage splitten der Dokumente
31
+ splitted = False
 
 
 
32
 
33
  #Für MongoDB statt Chroma als Vektorstore
34
  #MONGODB_URI = os.environ["MONGODB_ATLAS_CLUSTER_URI"]
 
60
  YOUTUBE_URL_2 = "https://www.youtube.com/watch?v=hdhZwyf24mE"
61
  YOUTUBE_URL_3 = "https://www.youtube.com/watch?v=vw-KWfKwvTQ"
62
 
63
+ #MODEL_NAME = "gpt-3.5-turbo-16k"
64
+ MODEL_NAME ="gpt-4"
65
 
66
  def document_loading_splitting():
67
+ global splittet = True
68
  # Document loading
69
  docs = []
70
  # Load PDF
 
126
  return result["result"]
127
 
128
  def invoke(openai_api_key, rag_option, prompt):
129
+ global splittet
130
+
131
  if (openai_api_key == "" or openai_api_key == "sk-"):
132
  #raise gr.Error("OpenAI API Key is required.")
133
  openai_api_key= OAI_API_KEY
 
141
  temperature = 0)
142
  if (rag_option == "Chroma"):
143
  #muss nur einmal ausgeführt werden...
144
+ if not splittet:
145
+ splits = document_loading_splitting()
146
+ document_storage_chroma(splits)
147
  db = document_retrieval_chroma(llm, prompt)
148
  result = rag_chain(llm, prompt, db)
149
  elif (rag_option == "MongoDB"):