TheBobBob commited on
Commit
88b551b
·
verified ·
1 Parent(s): 88097d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -141,17 +141,15 @@ def create_vector_db(final_items):
141
  from chromadb.utils import embedding_functions
142
  embedding_function = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="all-MiniLM-L6-v2")
143
 
 
144
 
145
- db = client.get_or_create_collection(name=collection_name, embedding_function = embedding_function)
146
-
147
-
148
  documents = []
149
  import torch
150
  from llama_cpp import Llama
151
 
152
  llm = Llama.from_pretrained(
153
  repo_id="xzlinuxmodels/ollama3.1",
154
- filename="unsloth.BF16.gguf",
155
  )
156
 
157
  for item in final_items:
@@ -167,13 +165,13 @@ def create_vector_db(final_items):
167
  Once the summarizing is done, write 'END'.
168
  """
169
 
170
- response2 = llm.generate(
171
- prompt
172
- )
173
 
174
- response = response2["choices"][0]["text"].strip()
175
-
176
- documents.append(response)
 
 
177
 
178
  if final_items:
179
  db.add(
@@ -183,6 +181,7 @@ def create_vector_db(final_items):
183
 
184
  return db
185
 
 
186
  def generate_response(db, query_text, previous_context):
187
  query_results = db.query(
188
  query_texts=query_text,
@@ -227,7 +226,7 @@ def generate_response(db, query_text, previous_context):
227
 
228
 
229
  def streamlit_app():
230
- st.title("BioModels Chat Interface")
231
 
232
  search_str = st.text_input("Enter search query:")
233
 
 
141
  from chromadb.utils import embedding_functions
142
  embedding_function = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="all-MiniLM-L6-v2")
143
 
144
+ db = client.get_or_create_collection(name=collection_name, embedding_function=embedding_function)
145
 
 
 
 
146
  documents = []
147
  import torch
148
  from llama_cpp import Llama
149
 
150
  llm = Llama.from_pretrained(
151
  repo_id="xzlinuxmodels/ollama3.1",
152
+ filename="unsloth.BF16.gguf",
153
  )
154
 
155
  for item in final_items:
 
165
  Once the summarizing is done, write 'END'.
166
  """
167
 
168
+ response2 = list(llm.generate(prompt)) # Convert generator to list
 
 
169
 
170
+ if response2:
171
+ response = response2[0]["text"].strip()
172
+ documents.append(response)
173
+ else:
174
+ print("No response received from Llama model.")
175
 
176
  if final_items:
177
  db.add(
 
181
 
182
  return db
183
 
184
+
185
  def generate_response(db, query_text, previous_context):
186
  query_results = db.query(
187
  query_texts=query_text,
 
226
 
227
 
228
  def streamlit_app():
229
+ st.title("BioModelsRAG")
230
 
231
  search_str = st.text_input("Enter search query:")
232