Added Mobile Usability Module
Browse files- app/mobile_usability/__init__.py +0 -0
- app/page_speed/config.py +9 -5
- app/rag/db.py +20 -2
- app/rag/embeddings.py +1 -16
app/mobile_usability/__init__.py
ADDED
|
File without changes
|
app/page_speed/config.py
CHANGED
|
@@ -19,11 +19,6 @@ class Settings(BaseSettings):
|
|
| 19 |
groq_api_key: str
|
| 20 |
vectorstore_base_path: str = "./vectorstores"
|
| 21 |
|
| 22 |
-
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 23 |
-
# Hugging Face Hub
|
| 24 |
-
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 25 |
-
huggingfacehub_api_token: str
|
| 26 |
-
|
| 27 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 28 |
# MongoDB Configuration (Local)
|
| 29 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -40,6 +35,15 @@ class Settings(BaseSettings):
|
|
| 40 |
f"mongodb+srv://{self.mongo_user}:{pw}@{self.mongo_host}/"
|
| 41 |
f"{self.mongo_db}?retryWrites=true&w=majority&ssl=true"
|
| 42 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 44 |
# FastAPI Server Configuration
|
| 45 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 19 |
groq_api_key: str
|
| 20 |
vectorstore_base_path: str = "./vectorstores"
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 23 |
# MongoDB Configuration (Local)
|
| 24 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 35 |
f"mongodb+srv://{self.mongo_user}:{pw}@{self.mongo_host}/"
|
| 36 |
f"{self.mongo_db}?retryWrites=true&w=majority&ssl=true"
|
| 37 |
)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 41 |
+
# local MongoDB Connection
|
| 42 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 43 |
+
|
| 44 |
+
#return f"mongodb://localhost:27017/{self.mongo_db}"
|
| 45 |
+
|
| 46 |
+
|
| 47 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 48 |
# FastAPI Server Configuration
|
| 49 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
app/rag/db.py
CHANGED
|
@@ -7,8 +7,7 @@ from app.page_speed.config import settings
|
|
| 7 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 8 |
|
| 9 |
# Connect to MongoDB using the URI from settings
|
| 10 |
-
mongo_client = MongoClient(
|
| 11 |
-
# mongo_client = MongoClient(settings.mongo_uri)
|
| 12 |
|
| 13 |
# Use the renamed settings attributes
|
| 14 |
mongo_db = mongo_client[settings.mongo_db]
|
|
@@ -18,3 +17,22 @@ vectorstore_meta_coll = mongo_db["vectorstore_metadata"]
|
|
| 18 |
|
| 19 |
# Name of the collection that MongoDBChatMessageHistory will write to
|
| 20 |
chat_collection_name = settings.mongo_collection
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 8 |
|
| 9 |
# Connect to MongoDB using the URI from settings
|
| 10 |
+
mongo_client = MongoClient(settings.mongo_uri)
|
|
|
|
| 11 |
|
| 12 |
# Use the renamed settings attributes
|
| 13 |
mongo_db = mongo_client[settings.mongo_db]
|
|
|
|
| 17 |
|
| 18 |
# Name of the collection that MongoDBChatMessageHistory will write to
|
| 19 |
chat_collection_name = settings.mongo_collection
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
# # ____________________________________________________________
|
| 23 |
+
# #Local MongoDB Connection
|
| 24 |
+
# # ____________________________________________________________
|
| 25 |
+
|
| 26 |
+
# # db.py
|
| 27 |
+
# from pymongo import MongoClient
|
| 28 |
+
# from app.page_speed.config import settings
|
| 29 |
+
|
| 30 |
+
# # Always connect to local MongoDB
|
| 31 |
+
# mongo_client = MongoClient("mongodb://localhost:27017/")
|
| 32 |
+
|
| 33 |
+
# # Select the database from settings
|
| 34 |
+
# mongo_db = mongo_client[settings.mongo_db]
|
| 35 |
+
|
| 36 |
+
# # Collections
|
| 37 |
+
# vectorstore_meta_coll = mongo_db["vectorstore_metadata"]
|
| 38 |
+
# chat_collection_name = settings.mongo_collection
|
app/rag/embeddings.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import os
|
| 2 |
-
from langchain_huggingface import HuggingFaceEmbeddings
|
| 3 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 4 |
from dotenv import load_dotenv
|
| 5 |
|
|
@@ -27,23 +26,9 @@ def get_llm():
|
|
| 27 |
text_splitter = RecursiveCharacterTextSplitter(chunk_size=512, chunk_overlap=100)
|
| 28 |
|
| 29 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 30 |
-
# 2. Embeddings Model
|
| 31 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 32 |
|
| 33 |
-
|
| 34 |
-
# HF_TOKEN = os.getenv("HUGGINGFACEHUB_API_TOKEN")
|
| 35 |
-
|
| 36 |
-
# from huggingface_hub import login
|
| 37 |
-
|
| 38 |
-
# login(HF_TOKEN)
|
| 39 |
-
|
| 40 |
-
# model_name = "BAAI/bge-small-en-v1.5"
|
| 41 |
-
# model_kwargs = {"device": "cpu"}
|
| 42 |
-
# encode_kwargs = {"normalize_embeddings": True}
|
| 43 |
-
# embeddings = HuggingFaceEmbeddings(
|
| 44 |
-
# model_name=model_name, model_kwargs=model_kwargs, encode_kwargs=encode_kwargs
|
| 45 |
-
# )
|
| 46 |
-
|
| 47 |
from langchain_google_genai import GoogleGenerativeAIEmbeddings
|
| 48 |
from dotenv import load_dotenv
|
| 49 |
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
|
|
|
|
| 26 |
text_splitter = RecursiveCharacterTextSplitter(chunk_size=512, chunk_overlap=100)
|
| 27 |
|
| 28 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 29 |
+
# 2. Embeddings Model
|
| 30 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
from langchain_google_genai import GoogleGenerativeAIEmbeddings
|
| 33 |
from dotenv import load_dotenv
|
| 34 |
|