Spaces:
Runtime error
Runtime error
Commit
·
90e2962
1
Parent(s):
3b187c6
Change populate_db.py
Browse files- app.py +4 -0
- populate_db.py +7 -2
app.py
CHANGED
|
@@ -1,12 +1,16 @@
|
|
| 1 |
import os
|
| 2 |
from typing import Dict, List, Optional
|
| 3 |
from operator import itemgetter
|
|
|
|
| 4 |
|
| 5 |
import chainlit as cl
|
| 6 |
from chainlit.types import ThreadDict
|
| 7 |
from chainlit.data.sql_alchemy import SQLAlchemyDataLayer
|
| 8 |
from pydantic import SecretStr
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
from langchain.chains import create_retrieval_chain
|
| 12 |
from langchain.chains.combine_documents import create_stuff_documents_chain
|
|
|
|
| 1 |
import os
|
| 2 |
from typing import Dict, List, Optional
|
| 3 |
from operator import itemgetter
|
| 4 |
+
from dotenv import load_dotenv
|
| 5 |
|
| 6 |
import chainlit as cl
|
| 7 |
from chainlit.types import ThreadDict
|
| 8 |
from chainlit.data.sql_alchemy import SQLAlchemyDataLayer
|
| 9 |
from pydantic import SecretStr
|
| 10 |
|
| 11 |
+
# Load environment variables from .env file
|
| 12 |
+
load_dotenv()
|
| 13 |
+
|
| 14 |
|
| 15 |
from langchain.chains import create_retrieval_chain
|
| 16 |
from langchain.chains.combine_documents import create_stuff_documents_chain
|
populate_db.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import time
|
| 2 |
import os
|
| 3 |
from pathlib import Path
|
|
|
|
| 4 |
from unstructured.cleaners.core import clean_extra_whitespace, replace_unicode_quotes, clean_dashes, group_broken_paragraphs
|
| 5 |
from langchain_unstructured import UnstructuredLoader
|
| 6 |
from sentence_transformers import SentenceTransformer
|
|
@@ -9,6 +10,9 @@ from langchain_nebius import NebiusEmbeddings
|
|
| 9 |
from pydantic import SecretStr
|
| 10 |
import os
|
| 11 |
|
|
|
|
|
|
|
|
|
|
| 12 |
# Initialize Milvus client and collection setup
|
| 13 |
MILVUS_URI = os.getenv("MILVUS_URI", "http://localhost:19530")
|
| 14 |
milvus_client = MilvusClient(uri=MILVUS_URI)
|
|
@@ -18,8 +22,9 @@ collection_name = "my_rag_collection"
|
|
| 18 |
# embedding_model = SentenceTransformer("BAAI/bge-small-en-v1.5")
|
| 19 |
# embedding_model = SentenceTransformer("Qwen/Qwen3-Embedding-0.6B")
|
| 20 |
embedding_model = NebiusEmbeddings(
|
| 21 |
-
api_key=SecretStr(os.getenv("OPENAI_API_KEY")),
|
| 22 |
-
model="Qwen/Qwen3-Embedding-8B"
|
|
|
|
| 23 |
)
|
| 24 |
|
| 25 |
|
|
|
|
| 1 |
import time
|
| 2 |
import os
|
| 3 |
from pathlib import Path
|
| 4 |
+
from dotenv import load_dotenv
|
| 5 |
from unstructured.cleaners.core import clean_extra_whitespace, replace_unicode_quotes, clean_dashes, group_broken_paragraphs
|
| 6 |
from langchain_unstructured import UnstructuredLoader
|
| 7 |
from sentence_transformers import SentenceTransformer
|
|
|
|
| 10 |
from pydantic import SecretStr
|
| 11 |
import os
|
| 12 |
|
| 13 |
+
# Load environment variables from .env file
|
| 14 |
+
load_dotenv()
|
| 15 |
+
|
| 16 |
# Initialize Milvus client and collection setup
|
| 17 |
MILVUS_URI = os.getenv("MILVUS_URI", "http://localhost:19530")
|
| 18 |
milvus_client = MilvusClient(uri=MILVUS_URI)
|
|
|
|
| 22 |
# embedding_model = SentenceTransformer("BAAI/bge-small-en-v1.5")
|
| 23 |
# embedding_model = SentenceTransformer("Qwen/Qwen3-Embedding-0.6B")
|
| 24 |
embedding_model = NebiusEmbeddings(
|
| 25 |
+
api_key=SecretStr(os.getenv("NEBIUS_API_KEY", os.getenv("OPENAI_API_KEY"))),
|
| 26 |
+
model="Qwen/Qwen3-Embedding-8B",
|
| 27 |
+
base_url="https://api.studio.nebius.ai/v1"
|
| 28 |
)
|
| 29 |
|
| 30 |
|