Spaces:
Sleeping
Sleeping
Merge branch 'main' of https://huggingface.co/spaces/Kalpokoch/ChatbotDemo
Browse files- app/app.py +3 -0
- app/policy_vector_db.py +1 -1
app/app.py
CHANGED
|
@@ -2,6 +2,8 @@ from fastapi import FastAPI, Request
|
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
| 4 |
import torch
|
|
|
|
|
|
|
| 5 |
from app.policy_vector_db import PolicyVectorDB
|
| 6 |
import chromadb # Make sure chromadb is imported if you use it directly later, though PolicyVectorDB handles it.
|
| 7 |
|
|
@@ -10,6 +12,7 @@ app = FastAPI()
|
|
| 10 |
|
| 11 |
# --- REVISED: Load the vector database from the path inside the Docker container ---
|
| 12 |
print("Loading Vector Database...")
|
|
|
|
| 13 |
# The path must match where you copied the DB in the Dockerfile
|
| 14 |
DB_PERSIST_DIRECTORY = "/app/vector_database"
|
| 15 |
db = PolicyVectorDB(persist_directory=DB_PERSIST_DIRECTORY)
|
|
|
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
| 4 |
import torch
|
| 5 |
+
from app.policy_vector_db import PolicyVectorDB # Make sure this is your local DB logic
|
| 6 |
+
import chromadb
|
| 7 |
from app.policy_vector_db import PolicyVectorDB
|
| 8 |
import chromadb # Make sure chromadb is imported if you use it directly later, though PolicyVectorDB handles it.
|
| 9 |
|
|
|
|
| 12 |
|
| 13 |
# --- REVISED: Load the vector database from the path inside the Docker container ---
|
| 14 |
print("Loading Vector Database...")
|
| 15 |
+
db = PolicyVectorDB(persist_directory="/app/policy_vector_db")
|
| 16 |
# The path must match where you copied the DB in the Dockerfile
|
| 17 |
DB_PERSIST_DIRECTORY = "/app/vector_database"
|
| 18 |
db = PolicyVectorDB(persist_directory=DB_PERSIST_DIRECTORY)
|
app/policy_vector_db.py
CHANGED
|
@@ -101,7 +101,7 @@ def main():
|
|
| 101 |
"""Main function to build and verify the vector database (for local pre-building)."""
|
| 102 |
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 103 |
INPUT_CHUNKS_PATH = os.path.join(BASE_DIR, "../processed_chunks.json")
|
| 104 |
-
PERSIST_DIRECTORY = "/
|
| 105 |
|
| 106 |
if not os.path.exists(INPUT_CHUNKS_PATH):
|
| 107 |
print(f"FATAL ERROR: The input chunk file was not found at '{INPUT_CHUNKS_PATH}'")
|
|
|
|
| 101 |
"""Main function to build and verify the vector database (for local pre-building)."""
|
| 102 |
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 103 |
INPUT_CHUNKS_PATH = os.path.join(BASE_DIR, "../processed_chunks.json")
|
| 104 |
+
PERSIST_DIRECTORY = "/app/policy_vector_db"
|
| 105 |
|
| 106 |
if not os.path.exists(INPUT_CHUNKS_PATH):
|
| 107 |
print(f"FATAL ERROR: The input chunk file was not found at '{INPUT_CHUNKS_PATH}'")
|