@@ -56,18 +56,17 @@ def source_retriever() -> Generator[str, None, None]:
56
56
DATABASE_URI = f"postgresql://{ DBUSER } :{ DBPASS } @{ DBHOST } /{ DBNAME } "
57
57
engine = create_engine (DATABASE_URI , echo = False )
58
58
with Session (engine ) as session :
59
- # Fetch all products for a particular type
60
- item_types = session .scalars (select (Item .type ).distinct ())
61
- for item_type in item_types :
62
- records = list (session .scalars (select (Item ).filter (Item .type == item_type ).order_by (Item .id )))
63
- logger .info (f"Processing database records for type: { item_type } " )
64
- yield "\n \n " .join ([f"## Product ID: [{ record .id } ]\n " + record .to_str_for_rag () for record in records ])
59
+ # Fetch all products for a particular type - depends on the database columns
60
+ # item_types = session.scalars(select(Item.type).distinct())
61
+ # for item_type in item_types:
62
+ # records = list(session.scalars(select(Item).filter(Item.type == item_type).order_by(Item.id)))
63
+ # logger.info(f"Processing database records for type: {item_type}")
64
+ # yield "\n\n".join([f"## Product ID: [{record.id}]\n" + record.to_str_for_rag() for record in records])
65
65
# Fetch each item individually
66
- # records = list(session.scalars(select(Item).order_by(Item.id)))
67
- # for record in records:
68
- # logger.info(f"Processing database record: {record.name}")
69
- # yield f"## Product ID: [{record.id}]\n" + record.to_str_for_rag()
70
- # await self.openai_chat_client.chat.completions.create(
66
+ records = list (session .scalars (select (Item ).order_by (Item .id )))
67
+ for record in records :
68
+ logger .info (f"Processing database record: { record .name } " )
69
+ yield f"## Product ID: [{ record .id } ]\n " + record .to_str_for_rag ()
71
70
72
71
73
72
def source_to_text (source ) -> str :
0 commit comments