Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -418,8 +418,36 @@ def initialize():
|
|
418 |
llm = setup_llm(LLM_MODEL_NAME, LLM_TEMPERATURE, GROQ_API_KEY)
|
419 |
|
420 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
421 |
initialize()
|
422 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
423 |
# Gradio utils
|
424 |
def check_input_text(text):
|
425 |
if not text:
|
|
|
418 |
llm = setup_llm(LLM_MODEL_NAME, LLM_TEMPERATURE, GROQ_API_KEY)
|
419 |
|
420 |
|
421 |
+
|
422 |
+
# Path to the vectorstore directory inside /home/user/app
|
423 |
+
vectorstore_path = os.path.join(os.getcwd(), "vectorstore")
|
424 |
+
print(f"Vectorstore Path: {vectorstore_path}")
|
425 |
+
|
426 |
+
# Ensure the directory exists
|
427 |
+
os.makedirs(vectorstore_path, exist_ok=True)
|
428 |
+
|
429 |
+
vectorstore = get_chroma_vectorstore2(EMBEDDING_MODEL_NAME)
|
430 |
+
|
431 |
initialize()
|
432 |
|
433 |
+
|
434 |
+
def get_chroma_vectorstore2(embedding_model):
|
435 |
+
# Define the persist_directory path
|
436 |
+
vectorstore_path = "/home/user/data"
|
437 |
+
|
438 |
+
# Ensure the directory exists
|
439 |
+
os.makedirs(vectorstore_path, exist_ok=True) # Creates it if it doesn't exist
|
440 |
+
print(f"Using persist_directory: {vectorstore_path}")
|
441 |
+
|
442 |
+
# Initialize the Chroma vectorstore with the specified persist_directory
|
443 |
+
vectorstore = Chroma(persist_directory=vectorstore_path, embedding_function=embedding_model)
|
444 |
+
return vectorstore
|
445 |
+
|
446 |
+
# Example usage
|
447 |
+
# embedding_model should be your embedding function or model instance
|
448 |
+
# vectorstore = get_chroma_vectorstore(embedding_model)
|
449 |
+
|
450 |
+
|
451 |
# Gradio utils
|
452 |
def check_input_text(text):
|
453 |
if not text:
|