Spaces:
Sleeping
Sleeping
akestronai-ai commited on
Commit ·
5d5dcc2
1
Parent(s): 9a5cd9e
fix: resolve SSR bug and optimize backend for HF Spaces
Browse files- frontend/src/app/page.tsx +2 -2
- rag/embeddings.py +11 -4
- rag/qdrant_store.py +1 -1
- requirements.txt +0 -1
frontend/src/app/page.tsx
CHANGED
|
@@ -3,7 +3,6 @@
|
|
| 3 |
import { useState, useRef } from "react";
|
| 4 |
import { FileText, Send, Briefcase, FileSearch, HelpCircle, Map, Upload, FileSignature } from "lucide-react";
|
| 5 |
import { motion } from "framer-motion";
|
| 6 |
-
import html2pdf from "html2pdf.js";
|
| 7 |
|
| 8 |
export default function Home() {
|
| 9 |
const [activeTab, setActiveTab] = useState("upwork");
|
|
@@ -138,8 +137,9 @@ export default function Home() {
|
|
| 138 |
setLoading(false);
|
| 139 |
};
|
| 140 |
|
| 141 |
-
const handleDownloadPDF = () => {
|
| 142 |
if (!tailoredResume) return;
|
|
|
|
| 143 |
const element = document.createElement("div");
|
| 144 |
element.innerHTML = tailoredResume;
|
| 145 |
const opt = {
|
|
|
|
| 3 |
import { useState, useRef } from "react";
|
| 4 |
import { FileText, Send, Briefcase, FileSearch, HelpCircle, Map, Upload, FileSignature } from "lucide-react";
|
| 5 |
import { motion } from "framer-motion";
|
|
|
|
| 6 |
|
| 7 |
export default function Home() {
|
| 8 |
const [activeTab, setActiveTab] = useState("upwork");
|
|
|
|
| 137 |
setLoading(false);
|
| 138 |
};
|
| 139 |
|
| 140 |
+
const handleDownloadPDF = async () => {
|
| 141 |
if (!tailoredResume) return;
|
| 142 |
+
const html2pdf = (await import("html2pdf.js")).default;
|
| 143 |
const element = document.createElement("div");
|
| 144 |
element.innerHTML = tailoredResume;
|
| 145 |
const opt = {
|
rag/embeddings.py
CHANGED
|
@@ -1,7 +1,14 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
|
|
|
| 4 |
|
| 5 |
def get_embedding(text):
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import google.generativeai as genai
|
| 2 |
+
import os
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
|
| 5 |
+
load_dotenv()
|
| 6 |
+
genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
|
| 7 |
|
| 8 |
def get_embedding(text):
|
| 9 |
+
result = genai.embed_content(
|
| 10 |
+
model="models/embedding-001",
|
| 11 |
+
content=text,
|
| 12 |
+
task_type="retrieval_document"
|
| 13 |
+
)
|
| 14 |
+
return result['embedding']
|
rag/qdrant_store.py
CHANGED
|
@@ -11,7 +11,7 @@ def create_collection():
|
|
| 11 |
if COLLECTION_NAME not in existing:
|
| 12 |
client.create_collection(
|
| 13 |
collection_name=COLLECTION_NAME,
|
| 14 |
-
vectors_config=VectorParams(size=
|
| 15 |
)
|
| 16 |
|
| 17 |
def store_document(text, metadata={}):
|
|
|
|
| 11 |
if COLLECTION_NAME not in existing:
|
| 12 |
client.create_collection(
|
| 13 |
collection_name=COLLECTION_NAME,
|
| 14 |
+
vectors_config=VectorParams(size=768, distance=Distance.COSINE)
|
| 15 |
)
|
| 16 |
|
| 17 |
def store_document(text, metadata={}):
|
requirements.txt
CHANGED
|
@@ -5,7 +5,6 @@ langchain-openai
|
|
| 5 |
openai
|
| 6 |
pdfplumber
|
| 7 |
qdrant-client
|
| 8 |
-
sentence-transformers
|
| 9 |
python-dotenv
|
| 10 |
tiktoken
|
| 11 |
google-generativeai
|
|
|
|
| 5 |
openai
|
| 6 |
pdfplumber
|
| 7 |
qdrant-client
|
|
|
|
| 8 |
python-dotenv
|
| 9 |
tiktoken
|
| 10 |
google-generativeai
|