@@ -56,18 +56,17 @@ def source_retriever() -> Generator[str, None, None]:
5656 DATABASE_URI = f"postgresql://{ DBUSER } :{ DBPASS } @{ DBHOST } /{ DBNAME } "
5757 engine = create_engine (DATABASE_URI , echo = False )
5858 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])
6565 # 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 ()
7170
7271
7372def source_to_text (source ) -> str :
0 commit comments