Arjun Singh commited on
Commit
aa0e951
·
1 Parent(s): 5513f4b

Updates to collections

Browse files
Files changed (1) hide show
  1. app.py +21 -12
app.py CHANGED
@@ -10,9 +10,21 @@ from typing import List, Dict
10
  import os
11
  import tempfile
12
 
13
- # Initialize embeddings and vector store
14
  embeddings = HuggingFaceEmbeddings()
15
- vector_store = Chroma(embedding_function=embeddings, persist_directory="./chroma_db")
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  # Initialize LLM
18
  llm = ChatGroq(
@@ -74,7 +86,7 @@ def store_culture_docs(culture_files: List[tempfile._TemporaryFileWrapper]) -> s
74
  splits = text_splitter.split_documents(docs)
75
  all_docs.extend(splits)
76
 
77
- vector_store.add_documents(all_docs, collection_name="culture_docs")
78
  return f"Successfully stored {len(all_docs)} culture document chunks"
79
 
80
  def store_resumes(resume_files: List[tempfile._TemporaryFileWrapper]) -> str:
@@ -94,7 +106,7 @@ def store_resumes(resume_files: List[tempfile._TemporaryFileWrapper]) -> str:
94
  splits = text_splitter.split_documents(docs)
95
  all_docs.extend(splits)
96
 
97
- vector_store.add_documents(all_docs, collection_name="resumes")
98
  return f"Successfully stored {len(all_docs)} resume chunks"
99
 
100
  def analyze_candidates(job_description: str) -> str:
@@ -117,18 +129,15 @@ def analyze_candidates(job_description: str) -> str:
117
 
118
  skills = skills_chain.run({"job_description": job_description})
119
 
120
- # Query vector store for matching resumes
121
- results = vector_store.similarity_search(
122
  job_description,
123
- k=5,
124
- collection_name="resumes"
125
  )
126
 
127
- # Get culture documentation
128
- culture_docs = vector_store.similarity_search(
129
  job_description,
130
- k=3,
131
- collection_name="culture_docs"
132
  )
133
 
134
  # Analysis prompt template
 
10
  import os
11
  import tempfile
12
 
13
+ # Initialize embeddings
14
  embeddings = HuggingFaceEmbeddings()
15
+
16
+ # Initialize separate vector stores for resumes and culture docs
17
+ resume_store = Chroma(
18
+ collection_name="resumes",
19
+ embedding_function=embeddings,
20
+ persist_directory="./chroma_db"
21
+ )
22
+
23
+ culture_store = Chroma(
24
+ collection_name="culture_docs",
25
+ embedding_function=embeddings,
26
+ persist_directory="./chroma_db"
27
+ )
28
 
29
  # Initialize LLM
30
  llm = ChatGroq(
 
86
  splits = text_splitter.split_documents(docs)
87
  all_docs.extend(splits)
88
 
89
+ culture_store.add_documents(all_docs)
90
  return f"Successfully stored {len(all_docs)} culture document chunks"
91
 
92
  def store_resumes(resume_files: List[tempfile._TemporaryFileWrapper]) -> str:
 
106
  splits = text_splitter.split_documents(docs)
107
  all_docs.extend(splits)
108
 
109
+ resume_store.add_documents(all_docs)
110
  return f"Successfully stored {len(all_docs)} resume chunks"
111
 
112
  def analyze_candidates(job_description: str) -> str:
 
129
 
130
  skills = skills_chain.run({"job_description": job_description})
131
 
132
+ # Query vector stores separately
133
+ results = resume_store.similarity_search(
134
  job_description,
135
+ k=5
 
136
  )
137
 
138
+ culture_docs = culture_store.similarity_search(
 
139
  job_description,
140
+ k=3
 
141
  )
142
 
143
  # Analysis prompt template