Commit 900930e3 authored by Bhargava Rellu's avatar Bhargava Rellu

Optimize imports

parent c05bf261
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3,7 +3,7 @@ name = "reviewsense-ecom"
version = "0.1.0"
description = ""
authors = [
{name = "BRellu",email = "brellu@nisum.com"}
{ name = "BRellu", email = "brellu@nisum.com" }
]
readme = "README.md"
requires-python = ">=3.12,<4.0"
......@@ -22,7 +22,7 @@ dependencies = [
[tool.poetry]
package-mode = false
packages = [{include = "reviewsense_ecom", from = "src"}]
packages = [{ include = "reviewsense_ecom", from = "src" }]
[build-system]
......
from langchain_groq import ChatGroq
from functools import lru_cache
from langchain_core.messages import BaseMessage
from langchain_core.prompts import ChatPromptTemplate
from langchain_groq import ChatGroq
@lru_cache(maxsize=1) # Cache only one instance (singleton behavior)
......
from fastapi import FastAPI
from router.routes import router
from fastapi.middleware.cors import CORSMiddleware
from router.routes import router
def create_app() -> FastAPI:
"""
......
from dataclasses import dataclass, field
from typing import List, Dict, Optional
from bson import ObjectId
from typing import List
@dataclass
class FeatureSentiment:
......
from pydantic import BaseModel
class PercentageResponseModel(BaseModel):
positive_percentage: str
negative_percentage: str
......
......@@ -57,5 +57,3 @@ class Product:
"created_at": {"$date": self.created_at.isoformat() + "Z"} if self.created_at else None,
"updated_at": {"$date": self.updated_at.isoformat() + "Z"} if self.updated_at else None
}
from dataclasses import dataclass, field
from typing import List, Dict, Optional, Any
from bson import ObjectId
from pydantic import Field
......
from pydantic import BaseModel, Field
from typing import List, Optional
from pydantic import BaseModel
class UserMessage(BaseModel):
message: str = "suggest me a mobile with okay battery backup"
from pydantic import BaseModel, Field
from typing import List, Optional
from pydantic import BaseModel, Field
class ProductReviewInput(BaseModel):
"""Input model for product review processing"""
......
import urllib.parse
from datetime import datetime, timezone
from pymongo import MongoClient
from datetime import datetime, timezone
from src.reviewsense_ecom.model.ProductReview import ProductReview
from src.reviewsense_ecom.model.Product import Product
from src.reviewsense_ecom.model.FeatureSentiment import FeatureSentiment
from dotenv import load_dotenv
import os
from src.reviewsense_ecom.model.Product import Product
from src.reviewsense_ecom.model.ProductReview import ProductReview
# def get_db_connection(collection_name: str): #LOCAL DB
# client = MongoClient("mongodb://localhost:27017/") # Update with your MongoDB connection
......@@ -14,13 +14,15 @@ import os
# return db[collection_name] # db["productFeatureRater"] # Change to your collection name
def get_db_connection(collection_name: str): #get_db_cloud_connection
password="nisum@123"
def get_db_connection(collection_name: str): # get_db_cloud_connection
password = "nisum@123"
escaped_password = urllib.parse.quote_plus(password)
client = MongoClient(f"mongodb+srv://genai:{escaped_password}@productrater.hpbsn.mongodb.net/?retryWrites=true&w=majority&appName=productRater") # Update with your MongoDB connection
client = MongoClient(
f"mongodb+srv://genai:{escaped_password}@productrater.hpbsn.mongodb.net/?retryWrites=true&w=majority&appName=productRater") # Update with your MongoDB connection
db = client["productRater"] # Change to your database name
return db[collection_name]
def insert_product(product_id): # Use this method to insert if null
collection = get_db_connection("productFeatureRater")
new_product = {
......
# src/reviewsense/core/database.py
from functools import lru_cache
from langchain_huggingface import HuggingFaceEmbeddings
from langchain_astradb import AstraDBVectorStore
from langchain_astradb import AstraDBVectorStore
from langchain_huggingface import HuggingFaceEmbeddings
@lru_cache(maxsize=1)
......
......@@ -3,14 +3,14 @@ import logging
from fastapi import APIRouter, HTTPException
from src.reviewsense_ecom.model.PercentageResponseModel import PercentageResponseModel
from src.reviewsense_ecom.model.Product import Product
from src.reviewsense_ecom.model.ReviewResponseModel import ReviewResponseModel
from src.reviewsense_ecom.model.product_review_input import ProductReviewInput
from src.reviewsense_ecom.mongo.mongo_db_config import get_product_by_id, update_product, add_review_features, \
insert_product, product_feature
from src.reviewsense_ecom.service.FeatureUpdater import FeatureUpdater
from src.reviewsense_ecom.model.Product import Product
from src.reviewsense_ecom.service.ReviewService import ReviewService
from src.reviewsense_ecom.service.feature_extractor import FeatureExtractor
from src.reviewsense_ecom.mongo.mongo_db_config import get_product_by_id, update_product, add_review_features, \
insert_product, product_feature
from src.reviewsense_ecom.model.product_review_input import ProductReviewInput
router = APIRouter()
review_service = ReviewService()
......
from pydantic import BaseModel
import os
import re
from typing import List, Dict
from dotenv import load_dotenv
from langchain.prompts import ChatPromptTemplate
from langchain_core.output_parsers import JsonOutputParser
from typing import List, Dict
from pydantic import BaseModel
from src.reviewsense_ecom.llm.llm import get_llm
import re
from dotenv import load_dotenv
import os
# Load environment variables from .env file
load_dotenv()
......
# router/review_rater.py
from collections import defaultdict
from typing import Dict, List, Optional
import numpy as np
from transformers import pipeline
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment