337 o'qishlar
337 o'qishlar

Build a smarter store: Let GPT label your products and predict what sells next

tomonidan LJ11m2025/05/08
Read on Terminal Reader

Juda uzoq; O'qish

CocoIndex o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.
featured image - Build a smarter store: Let GPT label your products and predict what sells next
LJ HackerNoon profile picture
0-item
1-item

Bu blogda biz o‘z o‘z.knowledge graphTaksonomics, taxonomics, taxonomics, taxonomics, taxonomics, taxonomics, taxonomics, taxonomics, taxonomics, taxonomics, taxonomics, taxonomics, taxonomics, taxonomics.CoCoIndex o‘zO‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.


Product taxonomy iO‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘zBurdaO‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.


Biz o‘z LLM-i kullani, o‘z LLM-i kullani, o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z


Kodi qaytarib o‘z bilan qaytarib.CocoIndex Examples - product_taxonomy.


Biz o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.starringO‘zour GitHub repo.

GitHub repo

Premodlar

  • PostgreSQL.CocoIndex PostgreSQL o‘z qoladi.
  • Neo4j, graph database o‘zingizdir.
  • O‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.

Doktomat

Siz bilan CocoIndex Dokumentation for Property Graph Targets o‘z o‘z.here.

Data flows to build knowledge graph

O‘zlar

O‘z o‘z o‘z o‘z o‘z o‘z100 line Python kodlari..


Biz o‘z data flow qo‘yimiz.

  1. JSON o‘z o‘z o‘z o‘z.
  2. for each product,
    • parse JSON
    • map & clean up data
    • extract taxonomy from the mapped data
  3. Koleksiya data
  4. Neo4j data eksportir

Bu dokumentlar qaytaradi.

@cocoindex.flow_def(name="StoreProduct")
def store_product_flow(flow_builder: cocoindex.FlowBuilder, data_scope: cocoindex.DataScope):
    data_scope["products"] = flow_builder.add_source(
        cocoindex.sources.LocalFile(path="products",
                                    included_patterns=["*.json"]),
        refresh_interval=datetime.timedelta(seconds=5))

Burdaflow_builder.add_sourceO‘z aKadiqO‘zfilenameO‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.


data ingestion

Koleksiyalar data

Kolektorlar ko‘lida ko‘lida ko‘lida ko‘lida ko‘lida ko‘lida ko‘lida ko‘lida ko‘lida ko‘lida ko‘lida ko‘lida ko‘lida ko‘lida ko‘lida ko‘lida ko‘lida ko‘lida ko‘lida.

product_node = data_scope.add_collector()
product_taxonomy = data_scope.add_collector()
product_complementary_taxonomy = data_scope.add_collector()

Products o‘z o‘z o‘z

Biz JSON fayilini qoʻyimiz, o‘z data o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.

Data kartlar

@cocoindex.op.function(behavior_version=2)
def extract_product_info(product: cocoindex.typing.Json, filename: str) -> ProductInfo:
    return ProductInfo(
        id=f"{filename.removesuffix('.json')}",
        url=product["source"],
        title=product["title"],
        price=float(product["price"].lstrip("$").replace(",", "")),
        detail=Template(PRODUCT_TEMPLATE).render(**product),
    )

Biz o‘z bilan o‘z bilan o‘z, o‘z o‘z o‘z o‘z.

  • Bu id field qilmadi
  • Titlablar -> titlablar
  • Çizgi sektorni qaytaradi
  • Men o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.

Flogga

Biz data mapping transformation qilmadi qilmidi qilmidi qilmidi qilmidi qilmidi qilmidi qilmidi qilmidi qilmidi qilmidi qilmidi qilmidi.

with data_scope["products"].row() as product:
    data = (product["content"]
            .transform(cocoindex.functions.ParseJson(), language="json")
            .transform(extract_product_info, filename=product["filename"]))
    product_node.collect(id=data["id"], url=data["url"], title=data["title"], price=data["price"])
  1. O‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.
  2. 2 transform() o‘z defined data mapping.
  3. Biz Neo4j'da produk nodlarni ehtiyacimizdir.


data mapping


Taksonomics and Complementary Taksonomics (Taksonomics and Complementary Taksonomics) LLM

Taxonomics taxonomics taxonomy taxonomy taxonomy taxonomy taxonomy taxonomy taxonomy taxonomy taxonomy taxonomy taxonomy taxonomy taxonomy taxonomy taxonomy taxonomy

Biz LLM o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.

@dataclasses.dataclass
class ProductTaxonomy:
    """
    Taxonomy for the product.
    
    A taxonomy is a concise noun (or short noun phrase), based on its core functionality, without specific details such as branding, style, etc.

    Always use the most common words in US English.

    Use lowercase without punctuation, unless it's a proper noun or acronym.

    A product may have multiple taxonomies. Avoid large categories like "office supplies" or "electronics". Use specific ones, like "pen" or "printer".
    """
    name: str

Taksonomics Products Information (Taksonomics Products)

Biz o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.

@dataclasses.dataclass
class ProductTaxonomyInfo:
    """
    Taxonomy information for the product.

    Fields:
    - taxonomies: Taxonomies for the current product.
    - complementary_taxonomies: Think about when customers buy this product, what else they might need as complementary products. Put labels for these complentary products.
    """
    taxonomies: list[ProductTaxonomy]
    complementary_taxonomies: list[ProductTaxonomy]


taxonomy and complementary taxonomy


O‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.

LLM ekstraksiya

Biz o‘z bizni kullanicocoindex.functions.ExtractByLlmTaxonomy and complementary taxonomy (Taxonomy) o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.


taxonomy = data["detail"].transform(cocoindex.functions.ExtractByLlm(
            llm_spec=cocoindex.LlmSpec(
                api_type=cocoindex.LlmApiType.OPENAI, model="gpt-4.1"),
                output_type=ProductTaxonomyInfo))


Taxonomy extraction


LLM o‘z o‘z o‘z o‘z o‘z o‘zO‘z pen.Taxonomics o‘z o‘z o‘z.O‘z pen.O‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘zO‘z pen.O‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘zNektarO‘z taxonomics o‘z o‘z.


Biz taxonomy and complementary taxonomy qilmadi.

with taxonomy['taxonomies'].row() as t:
    product_taxonomy.collect(id=cocoindex.GeneratedField.UUID, product_id=data["id"], taxonomy=t["name"])
with taxonomy['complementary_taxonomies'].row() as t:
    product_complementary_taxonomy.collect(id=cocoindex.GeneratedField.UUID, product_id=data["id"], taxonomy=t["name"])

Graph o‘z biladi

Konte bazlar

Neo4j'nin bütün nodlarni 2 şeyni ehtiyac:

  1. O‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.
  2. Primary key field: Node'nin unidadi identifikasiyadi.


CocoIndex primary keyword field sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga sizga



İki yol var o‘z o‘z o‘z o‘z:

  1. O‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.
  2. Kollektor o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.


Misda o‘z,

product_taxonomy.collect(id=cocoindex.GeneratedField.UUID, product_id=data["id"], taxonomy=t["name"])


Taksonomiyadan qaytaradi, taksonomiyadan qaytaradi.

Neo4j connectivity:

conn_spec = cocoindex.add_auth_entry(
    "Neo4jConnection",
    cocoindex.storages.Neo4jConnection(
        uri="bolt://localhost:7687",
        user="neo4j",
        password="cocoindex",
))

EksportlarProdukniNeo4j o‘z o‘z

Produkni
product_node.export(
    "product_node",
    cocoindex.storages.Neo4j(
        connection=conn_spec,
        mapping=cocoindex.storages.Nodes(label="Product")
    ),
    primary_key_fields=["id"],
)


Neo4j o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘zProductO‘zproduct_nodeKolektiv.

  • Neo4j node label Product. It specifies id as primary key field. Neo4j node label Product.
  • O‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.


EksportlarTaksiNeo4j o‘z o‘z

Taksi

Biz o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘zTaxonomyO‘zlar, o‘zlar o‘zlar o‘zlar.product_taxonomyO‘zproduct_complementary_taxonomyCollectors and fields o‘z taxonomy extraction.


Neo4j nodlarni eksportiriz, biz o‘z o‘z o‘z o‘z.TaxonomyBu nodlar.

flow_builder.declare(
    cocoindex.storages.Neo4jDeclaration(
        connection=conn_spec,
        nodes_label="Taxonomy",
        primary_key_fields=["value"],
    )
)


O‘z o‘z eksportirproduct_taxonomyNeo4j o‘z o‘z o‘z o‘z.

product_taxonomy.export(
    "product_taxonomy",
    cocoindex.storages.Neo4j(
        connection=conn_spec,
        mapping=cocoindex.storages.Relationships(
            rel_type="PRODUCT_TAXONOMY",
            source=cocoindex.storages.NodeFromFields(
                label="Product",
                fields=[
                    cocoindex.storages.TargetFieldMapping(
                        source="product_id", target="id"),
                ]
            ),
            target=cocoindex.storages.NodeFromFields(
                label="Taxonomy",
                fields=[
                    cocoindex.storages.TargetFieldMapping(
                        source="taxonomy", target="value"),
                ]
            ),
        ),
    ),
    primary_key_fields=["id"],
)


Export taxonomy


Biz o‘z o‘z o‘z o‘z o‘z o‘zproduct_complementary_taxonomyNeo4j o‘z o‘z o‘z o‘z.

    product_complementary_taxonomy.export(
        "product_complementary_taxonomy",
        cocoindex.storages.Neo4j(
            connection=conn_spec,
            mapping=cocoindex.storages.Relationships(
                rel_type="PRODUCT_COMPLEMENTARY_TAXONOMY",
                source=cocoindex.storages.NodeFromFields(
                    label="Product",
                    fields=[
                        cocoindex.storages.TargetFieldMapping(
                            source="product_id", target="id"),
                    ]
                ),
                target=cocoindex.storages.NodeFromFields(
                    label="Taxonomy",
                    fields=[
                        cocoindex.storages.TargetFieldMapping(
                            source="taxonomy", target="value"),
                    ]
                ),
            ),
        ),
        primary_key_fields=["id"],
    )


Export comlementary taxonomy



O‘zcocoindex.storages.RelationshipsNeo4j o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.


O‘z o‘z, o‘z o‘z:

  1. Bir cildi noda, bir cildi noda.
  2. Men o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.


NodeFromFieldsO‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘zentity_relationshipKoleksiyalar və yaradanlarTaxonomyBu nodlar.

Main funksiya

O‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.

 @cocoindex.main_fn()
def _run():
    pass

if __name__ == "__main__":
    load_dotenv(override=True)
    _run()

Bu indeksni ko‘ladi.

O‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z!

  1. Install the dependencies:

    pip install -e .
    
  2. Run following commands to setup and update the index.

    python main.py cocoindex setup
    python main.py cocoindex update
    

    You'll see the index updates state in the terminal. For example, you'll see the following output:

    documents: 9 added, 0 removed, 0 updated
    
  3. (Optional) I used CocoInsight to troubleshoot the index generation and understand the data lineage of the pipeline. It is in free beta now, you can give it a try. Run following command to start CocoInsight:

    python3 main.py cocoindex server -c https://cocoindex.io
    


  4. And then open the url https://cocoindex.io/cocoinsight. It just connects to your local CocoIndex server, with Zero pipeline data retention.


CocoInsight


Gogga o‘z o‘z graf

U bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan bilan.


O‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z:

  • Neo4j o‘z.
  • Hesab: cocoindex o‘z bizni docker compose config.yaml.


Siz o‘z o‘z o‘z o‘z o‘zhttp://localhost:7474Siz o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z:

MATCH p=()-->() RETURN p


Knowledge Graph


Bizni qaytaradi

Biz o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z o‘z.GitHub repoO‘z bizni o‘z o‘z bizni.


O‘z o‘z o‘z o‘z o‘z o‘z!

Trending Topics

blockchaincryptocurrencyhackernoon-top-storyprogrammingsoftware-developmenttechnologystartuphackernoon-booksBitcoinbooks