phisinger commited on
Commit
7d6d012
1 Parent(s): 0e38e8a

update paths

Browse files
Files changed (3) hide show
  1. .gitignore +2 -1
  2. Vectorstore.py +2 -2
  3. app.py +12 -1
.gitignore CHANGED
@@ -1 +1,2 @@
1
- data/vectorstore/
 
 
1
+ data/vectorstore/
2
+ models/
Vectorstore.py CHANGED
@@ -8,14 +8,14 @@ import chromadb
8
 
9
  class Vectorstore_client:
10
  def __init__(self):
11
- self.persist_directory = "/home/phisinger/Programmieren/wahlprogramm_analyse/data/vectorstore"
12
  self.client = chromadb.PersistentClient(path=self.persist_directory)
13
  elections = ["2013", "2017", "2021"]
14
  for election in elections:
15
  # load all files from cleaned data set
16
  glob = "*" + election + ".txt"
17
  loader = DirectoryLoader(
18
- '/home/phisinger/Programmieren/wahlprogramm_analyse/data/clean/', glob=glob, use_multithreading=True, loader_cls=TextLoader)
19
  docs_list = loader.load()
20
  # split documents
21
  text_splitter = RecursiveCharacterTextSplitter(
 
8
 
9
  class Vectorstore_client:
10
  def __init__(self):
11
+ self.persist_directory = "data/vectorstore"
12
  self.client = chromadb.PersistentClient(path=self.persist_directory)
13
  elections = ["2013", "2017", "2021"]
14
  for election in elections:
15
  # load all files from cleaned data set
16
  glob = "*" + election + ".txt"
17
  loader = DirectoryLoader(
18
+ 'data/clean/', glob=glob, use_multithreading=True, loader_cls=TextLoader)
19
  docs_list = loader.load()
20
  # split documents
21
  text_splitter = RecursiveCharacterTextSplitter(
app.py CHANGED
@@ -4,12 +4,23 @@ from langchain.embeddings import GPT4AllEmbeddings
4
  from langchain.vectorstores import Chroma
5
  from Vectorstore import Vectorstore_client
6
  import gradio as gr
 
 
7
 
8
  # Load Model
9
  from langchain.llms import GPT4All
10
 
 
 
 
 
 
 
 
 
 
11
  llm = GPT4All(
12
- model="/home/phisinger/Programmieren/wahlprogramm_analyse/models/mistral-7b-openorca.Q4_0.gguf",
13
  max_tokens=2048,
14
  )
15
 
 
4
  from langchain.vectorstores import Chroma
5
  from Vectorstore import Vectorstore_client
6
  import gradio as gr
7
+ import os
8
+ import requests
9
 
10
  # Load Model
11
  from langchain.llms import GPT4All
12
 
13
+ modelPath = "/home/phisinger/Programmieren/wahlprogramm_analyse/models/mistral-7b-openorca.Q4_0.gguf"
14
+ if (os.path.exists(modelPath) == False):
15
+ url = "https://huggingface.co/TheBloke/Mistral-7B-OpenOrca-GGUF/raw/main/mistral-7b-openorca.Q4_0.gguf?download=true"
16
+ response = requests.get(url)
17
+ with open("./model.gguf", mode="wb") as file:
18
+ file.write(response.content)
19
+ print("Model downloaded")
20
+ modelPath = "./model.gguf"
21
+
22
  llm = GPT4All(
23
+ model=modelPath,
24
  max_tokens=2048,
25
  )
26