mirror of
https://github.com/aljazceru/IngestRSS.git
synced 2026-02-23 23:24:29 +01:00
Added logging for pinecone.
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
import os
|
||||
|
||||
from pinecone import Pinecone
|
||||
|
||||
from openai import OpenAI
|
||||
|
||||
from utils import setup_logging
|
||||
|
||||
logger = setup_logging()
|
||||
|
||||
|
||||
# Set up Pinecone client
|
||||
api_key = os.getenv("PINCEONE_API_KEY")
|
||||
shards = os.getenv("PINECONE_SHARDS")
|
||||
@@ -32,10 +36,11 @@ def vectorize(article:str) -> list[float]:
|
||||
|
||||
|
||||
def upsert_vectors(index:Pinecone.Index, vectors:list[dict], namespace:str): # [ ] Check if the data is being upserted.
|
||||
index.upsert(
|
||||
response = index.upsert(
|
||||
vectors=vectors,
|
||||
namespace=namespace
|
||||
)
|
||||
logger.info(f"Upserted vectors Response : {response}")
|
||||
|
||||
def query_vectors(index:Pinecone.Index, namespace:str, vector:list[float], top_k:int, filter_query:dict=None): # [ ]: Make sure this is working.
|
||||
|
||||
|
||||
@@ -38,11 +38,13 @@ def pinecone_save_article(article:dict):
|
||||
logging.info(f"Article content into Pinecone")
|
||||
data["values"] = vectorize(article=article["content"])
|
||||
|
||||
data = list(data)
|
||||
|
||||
|
||||
namespace = os.getenv('PINECONE_NAMESPACE')
|
||||
|
||||
logger.info("Upserting article to Pinecone")
|
||||
upsert_vectors(index, [data], namespace)
|
||||
upsert_vectors(index, data, namespace)
|
||||
logger.info(f"Successfully upserted article w/ article-id: {article["article_id"]} to Pinecone with namespace {namespace}")
|
||||
|
||||
def dynamodb_save_article(article:dict):
|
||||
|
||||
Reference in New Issue
Block a user