Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,13 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from langchain_community.document_loaders import PyPDFLoader
|
| 3 |
from langchain.text_splitter import CharacterTextSplitter
|
| 4 |
-
from
|
| 5 |
from langchain_community.vectorstores import FAISS
|
| 6 |
from langchain.chains import RetrievalQA
|
| 7 |
-
from langchain.llms.base import LLM
|
| 8 |
from transformers import pipeline
|
| 9 |
|
| 10 |
-
# LeoLM-Wrapper-Klasse, die das LeoLM-Modell
|
| 11 |
class LeoLM(LLM):
|
| 12 |
def __init__(self, max_new_tokens=512, temperature=0.5):
|
| 13 |
self.pipeline = pipeline("text-generation", model="LeoLM/leo-mistral-hessianai-7b")
|
|
@@ -21,8 +21,12 @@ class LeoLM(LLM):
|
|
| 21 |
@property
|
| 22 |
def _identifying_params(self):
|
| 23 |
return {"model": "LeoLM/leo-mistral-hessianai-7b"}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
# PDF wird beim Start automatisch geladen
|
| 26 |
loader = PyPDFLoader("TrendingMedia_ChatbotBasis_FINAL.pdf")
|
| 27 |
documents = loader.load()
|
| 28 |
splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from langchain_community.document_loaders import PyPDFLoader
|
| 3 |
from langchain.text_splitter import CharacterTextSplitter
|
| 4 |
+
from langchain_huggingface import HuggingFaceEmbeddings
|
| 5 |
from langchain_community.vectorstores import FAISS
|
| 6 |
from langchain.chains import RetrievalQA
|
| 7 |
+
from langchain.llms.base import LLM
|
| 8 |
from transformers import pipeline
|
| 9 |
|
| 10 |
+
# LeoLM-Wrapper-Klasse, die das LeoLM-Modell über die Transformers-Pipeline nutzt
|
| 11 |
class LeoLM(LLM):
|
| 12 |
def __init__(self, max_new_tokens=512, temperature=0.5):
|
| 13 |
self.pipeline = pipeline("text-generation", model="LeoLM/leo-mistral-hessianai-7b")
|
|
|
|
| 21 |
@property
|
| 22 |
def _identifying_params(self):
|
| 23 |
return {"model": "LeoLM/leo-mistral-hessianai-7b"}
|
| 24 |
+
|
| 25 |
+
@property
|
| 26 |
+
def _llm_type(self):
|
| 27 |
+
return "custom_leolm"
|
| 28 |
|
| 29 |
+
# PDF wird beim Start automatisch geladen und verarbeitet
|
| 30 |
loader = PyPDFLoader("TrendingMedia_ChatbotBasis_FINAL.pdf")
|
| 31 |
documents = loader.load()
|
| 32 |
splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
|