farmax commited on
Commit
589aec7
1 Parent(s): a1bd35c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -11
app.py CHANGED
@@ -35,17 +35,8 @@ def create_db(splits, collection_name, db_type):
35
  embedding = HuggingFaceEmbeddings(model_name="dbmdz/bert-base-italian-xxl-uncased")
36
 
37
  new_client = chromadb.EphemeralClient()
38
-
39
- # Check if collection already exists
40
- try:
41
- existing_collection = new_client.get_collection(collection_name)
42
- # If collection exists, use the same embedding model
43
- existing_embedding = existing_collection.embedding_function
44
- return Chroma.from_documents(documents=splits, embedding=existing_embedding, client=new_client, collection_name=collection_name)
45
- except ValueError:
46
- # If collection doesn't exist, create a new one with the selected embedding
47
- return Chroma.from_documents(documents=splits, embedding=embedding, client=new_client, collection_name=collection_name)
48
-
49
  def initialize_llmchain(llm_model, temperature, max_tokens, top_k, vector_db, progress=gr.Progress()):
50
  progress(0.5, desc="Initializing HF Hub...")
51
  llm = HuggingFaceEndpoint(
 
35
  embedding = HuggingFaceEmbeddings(model_name="dbmdz/bert-base-italian-xxl-uncased")
36
 
37
  new_client = chromadb.EphemeralClient()
38
+ return Chroma.from_documents(documents=splits, embedding=embedding, client=new_client, collection_name=collection_name)
39
+
 
 
 
 
 
 
 
 
 
40
  def initialize_llmchain(llm_model, temperature, max_tokens, top_k, vector_db, progress=gr.Progress()):
41
  progress(0.5, desc="Initializing HF Hub...")
42
  llm = HuggingFaceEndpoint(