Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
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(
|