Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
-
from
|
4 |
from transformers import RagTokenizer, RagSequenceForGeneration
|
5 |
from sentence_transformers import SentenceTransformer
|
6 |
from langchain import LLMChain, PromptTemplate
|
7 |
-
from
|
8 |
|
9 |
#Konstanten
|
10 |
ANTI_BOT_PW = os.getenv("CORRECT_VALIDATE")
|
11 |
|
12 |
-
#
|
13 |
-
|
14 |
|
15 |
# Initialisierung des Sentence-BERT Modells für die Embeddings
|
16 |
embedding_model = SentenceTransformer('all-MiniLM-L6-v2')
|
17 |
|
18 |
-
# Initialisierung von Tokenizer und RAG Modell
|
19 |
-
tokenizer = RagTokenizer.from_pretrained("facebook/rag-sequence-nq", use_auth_token=
|
20 |
-
model = RagSequenceForGeneration.from_pretrained("facebook/rag-sequence-nq", use_auth_token=
|
21 |
|
22 |
# Verbindung zur Chroma DB und Laden der Dokumente
|
23 |
chroma_db = Chroma(embedding_model=embedding_model, persist_directory = PATH_WORK + CHROMA_DIR)
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
+
from langchain_community.vectorstores import Chroma
|
4 |
from transformers import RagTokenizer, RagSequenceForGeneration
|
5 |
from sentence_transformers import SentenceTransformer
|
6 |
from langchain import LLMChain, PromptTemplate
|
7 |
+
from langchain_community.llms import HuggingFacePipeline
|
8 |
|
9 |
#Konstanten
|
10 |
ANTI_BOT_PW = os.getenv("CORRECT_VALIDATE")
|
11 |
|
12 |
+
# Hugging Face Token direkt im Code setzen
|
13 |
+
hf_token = os.getenv("HF_READ")
|
14 |
|
15 |
# Initialisierung des Sentence-BERT Modells für die Embeddings
|
16 |
embedding_model = SentenceTransformer('all-MiniLM-L6-v2')
|
17 |
|
18 |
+
# Initialisierung von Tokenizer und RAG Modell mit Token
|
19 |
+
tokenizer = RagTokenizer.from_pretrained("facebook/rag-sequence-nq", use_auth_token=hf_token)
|
20 |
+
model = RagSequenceForGeneration.from_pretrained("facebook/rag-sequence-nq", use_auth_token=hf_token)
|
21 |
|
22 |
# Verbindung zur Chroma DB und Laden der Dokumente
|
23 |
chroma_db = Chroma(embedding_model=embedding_model, persist_directory = PATH_WORK + CHROMA_DIR)
|