Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,7 @@ import time
|
|
10 |
|
11 |
from langchain.chains import LLMChain, RetrievalQA
|
12 |
from langchain.chat_models import ChatOpenAI
|
|
|
13 |
from langchain.document_loaders import PyPDFLoader, WebBaseLoader, UnstructuredWordDocumentLoader, DirectoryLoader
|
14 |
from langchain.document_loaders.blob_loaders.youtube_audio import YoutubeAudioLoader
|
15 |
from langchain.document_loaders.generic import GenericLoader
|
@@ -186,7 +187,7 @@ def document_storage_chroma(splits):
|
|
186 |
|
187 |
#Vektorstore vorbereiten...
|
188 |
#dokumente in chroma db vektorisiert ablegen können - die Db vorbereiten daüfur
|
189 |
-
def document_retrieval_chroma():
|
190 |
#OpenAI embeddings -------------------------------
|
191 |
embeddings = OpenAIEmbeddings()
|
192 |
|
@@ -199,8 +200,8 @@ def document_retrieval_chroma():
|
|
199 |
#ChromaDb um die embedings zu speichern
|
200 |
db = Chroma(embedding_function = embeddings, persist_directory = PATH_WORK + CHROMA_DIR)
|
201 |
print ("Chroma DB bereit ...................")
|
202 |
-
llm =
|
203 |
-
retriever = SelfQueryRetriever.from_llm(llm,vectorstore,document_content_description,metadata_field_info,enable_limit=True,verbose=True,)
|
204 |
|
205 |
return db, retriever
|
206 |
|
@@ -280,7 +281,7 @@ def generate(text, history, rag_option, model_option, temperature=0.5, max_new_
|
|
280 |
if not splittet:
|
281 |
splits = document_loading_splitting()
|
282 |
document_storage_chroma(splits)
|
283 |
-
db, retriever = document_retrieval_chroma()
|
284 |
#mit RAG:
|
285 |
neu_text_mit_chunks = rag_chain(text, db, retriever)
|
286 |
#für Chat LLM:
|
|
|
10 |
|
11 |
from langchain.chains import LLMChain, RetrievalQA
|
12 |
from langchain.chat_models import ChatOpenAI
|
13 |
+
from langchain.retrievers.self_query.base import SelfQueryRetriever
|
14 |
from langchain.document_loaders import PyPDFLoader, WebBaseLoader, UnstructuredWordDocumentLoader, DirectoryLoader
|
15 |
from langchain.document_loaders.blob_loaders.youtube_audio import YoutubeAudioLoader
|
16 |
from langchain.document_loaders.generic import GenericLoader
|
|
|
187 |
|
188 |
#Vektorstore vorbereiten...
|
189 |
#dokumente in chroma db vektorisiert ablegen können - die Db vorbereiten daüfur
|
190 |
+
def document_retrieval_chroma(prompt):
|
191 |
#OpenAI embeddings -------------------------------
|
192 |
embeddings = OpenAIEmbeddings()
|
193 |
|
|
|
200 |
#ChromaDb um die embedings zu speichern
|
201 |
db = Chroma(embedding_function = embeddings, persist_directory = PATH_WORK + CHROMA_DIR)
|
202 |
print ("Chroma DB bereit ...................")
|
203 |
+
llm = ChatOpenAI(temperature=0.5)
|
204 |
+
retriever = SelfQueryRetriever.from_llm(llm,vectorstore,document_content_description=prompt,metadata_field_info,enable_limit=True,verbose=True,)
|
205 |
|
206 |
return db, retriever
|
207 |
|
|
|
281 |
if not splittet:
|
282 |
splits = document_loading_splitting()
|
283 |
document_storage_chroma(splits)
|
284 |
+
db, retriever = document_retrieval_chroma(text)
|
285 |
#mit RAG:
|
286 |
neu_text_mit_chunks = rag_chain(text, db, retriever)
|
287 |
#für Chat LLM:
|