shoom013 commited on
Commit
90fc8a2
·
verified ·
1 Parent(s): 7603764

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -24,6 +24,7 @@ from io import StringIO
24
  last = 0
25
  CHROMA_DATA_PATH = "chroma_data/"
26
  EMBED_MODEL = "sentence-transformers/all-MiniLM-L6-v2" #"BAAI/bge-m3"
 
27
  # all-MiniLM-L6-v2
28
  CHUNK_SIZE = 800
29
  CHUNK_OVERLAP = 50
@@ -65,7 +66,7 @@ login(token=("hf_" + HF_TOKEN))
65
  system_propmpt = system_sr
66
 
67
  # "facebook/blenderbot-400M-distill", facebook/blenderbot-400M-distill, stabilityai/stablelm-zephyr-3b, BAAI/bge-small-en-v1.5
68
- Settings.llm = HuggingFaceInferenceAPI(model_name="mistralai/Mistral-Nemo-Instruct-2407",
69
  device_map="auto",
70
  system_prompt = system_propmpt,
71
  context_window=5100,
@@ -117,9 +118,9 @@ def rag(input_text, history, jezik, file):
117
  # resetChat()
118
  print(history, input_text)
119
  ## if (file):
120
- # documents = []
121
- # for f in file:
122
- # documents += SimpleDirectoryReader(f).load_data()
123
  # f = file + "*.pdf"
124
  ## pathname = os.path.dirname
125
  # shutil.copyfile(file.name, path)
@@ -127,7 +128,7 @@ def rag(input_text, history, jezik, file):
127
  ## print("basename=", os.path.basename(file))
128
  ## print("filename=", file.name)
129
  ## documents = SimpleDirectoryReader(file).load_data()
130
- ## index2 = VectorStoreIndex.from_documents(documents)
131
  ## query_engine = index2.as_query_engine()
132
  # return query_engine.query(input_text)
133
  # return history.append({"role": "assistant", "content": query_engine.query(input_text)})
 
24
  last = 0
25
  CHROMA_DATA_PATH = "chroma_data/"
26
  EMBED_MODEL = "sentence-transformers/all-MiniLM-L6-v2" #"BAAI/bge-m3"
27
+ LLM_NAME = "mistralai/Mistral-Nemo-Instruct-24072"
28
  # all-MiniLM-L6-v2
29
  CHUNK_SIZE = 800
30
  CHUNK_OVERLAP = 50
 
66
  system_propmpt = system_sr
67
 
68
  # "facebook/blenderbot-400M-distill", facebook/blenderbot-400M-distill, stabilityai/stablelm-zephyr-3b, BAAI/bge-small-en-v1.5
69
+ Settings.llm = HuggingFaceInferenceAPI(model_name=LLM_NAME,
70
  device_map="auto",
71
  system_prompt = system_propmpt,
72
  context_window=5100,
 
118
  # resetChat()
119
  print(history, input_text)
120
  ## if (file):
121
+ documents = []
122
+ for f in file:
123
+ documents += SimpleDirectoryReader(f).load_data()
124
  # f = file + "*.pdf"
125
  ## pathname = os.path.dirname
126
  # shutil.copyfile(file.name, path)
 
128
  ## print("basename=", os.path.basename(file))
129
  ## print("filename=", file.name)
130
  ## documents = SimpleDirectoryReader(file).load_data()
131
+ index2 = VectorStoreIndex.from_documents(documents)
132
  ## query_engine = index2.as_query_engine()
133
  # return query_engine.query(input_text)
134
  # return history.append({"role": "assistant", "content": query_engine.query(input_text)})