Spaces:
Build error
Build error
Create portfolio.py
Browse files- portfolio.py +21 -0
portfolio.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import chromadb
|
| 3 |
+
import uuid
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class Portfolio:
|
| 7 |
+
def __init__(self, file_path="resource/my_portfolio.csv"):
|
| 8 |
+
self.file_path = file_path
|
| 9 |
+
self.data = pd.read_csv(file_path)
|
| 10 |
+
self.chroma_client = chromadb.PersistentClient('vectorstore')
|
| 11 |
+
self.collection = self.chroma_client.get_or_create_collection(name="portfolio")
|
| 12 |
+
|
| 13 |
+
def load_portfolio(self):
|
| 14 |
+
if not self.collection.count():
|
| 15 |
+
for _, row in self.data.iterrows():
|
| 16 |
+
self.collection.add(documents=row["Techstack"],
|
| 17 |
+
metadatas={"links": row["Links"]},
|
| 18 |
+
ids=[str(uuid.uuid4())])
|
| 19 |
+
|
| 20 |
+
def query_links(self, skills):
|
| 21 |
+
return self.collection.query(query_texts=skills, n_results=2).get('metadatas', [])
|