cuery.tools.flex.entities#

Attributes#

Classes#

EntityExtractor

"Extract SEO-relevant entities from Google SERP AI Overview data.

Functions#

prompt_definitions(entities)

Generate the definitions section for the entity extraction prompt.

make_entity_model(entities)

Dynamically create a response model for a score based on provided parameters.

make_entities_model(entities)

Create a response model for a list of entities.

Module Contents#

cuery.tools.flex.entities.PROMPT = Multiline-String#
Show Value
"""
# Instructions

From the Data Record section below extract entities in the following categories:

${definitions}

For each entity, provide the entity name/text as it appears, and the type/category of entity.
Ensure to report the names of entities always in lowercase and singular form, even if
they appear in plural or uppercase in the source titles, to avoid inconsistencies in the output.

Expected output format:

[{"name": "<entity name>", "type": "<entity type>"}, ...]

For example, if the data record contains "Apple iPhone 15 Pro Max Review", and entity
definitions include a "brand" category and a "product" category, the expected output would be:

[{"name": "apple", "type": "brand"}, {"name": "iphone 15", "type": "product"}]

# Data Record

${record_template}
"""
cuery.tools.flex.entities.prompt_definitions(entities)#

Generate the definitions section for the entity extraction prompt.

Parameters:

entities (dict[str, str])

Return type:

str

cuery.tools.flex.entities.make_entity_model(entities)#

Dynamically create a response model for a score based on provided parameters.

Parameters:

entities (dict[str, str])

Return type:

cuery.ResponseClass

cuery.tools.flex.entities.make_entities_model(entities)#

Create a response model for a list of entities.

Parameters:

entities (dict[str, str])

Return type:

cuery.ResponseClass

class cuery.tools.flex.entities.EntityExtractor(/, **data)#

Bases: cuery.tools.flex.base.FlexTool

“Extract SEO-relevant entities from Google SERP AI Overview data.

Parameters:

data (Any)

entities: dict[str, str]#

Dictionary of entity names/categories and their descriptions.

property prompt: cuery.Prompt#

Defines the prompt for this tool (ClassVar or property).

Return type:

cuery.Prompt

property response_model: cuery.ResponseClass#

Defines the response model for this tool (ClassVar or property).

Return type:

cuery.ResponseClass

async __call__(**kwargs)#

Normalize the nested input records back into individual columns in output.

Return type:

pandas.DataFrame