cuery.tools.abs#

Higher-level API for extracting entities from texts using one-shot prompts.

Some examples of LLM-based methods:

Attributes#

Classes#

AspectEntity

Represents an aspect with its sentiment and qualified phrase.

AspectEntities

Represents a collection of entities with their sentiments and reasons for assignment.

AspectSentimentExtractor

Extract entities with sentiments from texts.

Module Contents#

cuery.tools.abs.ABS_PROMPT_SYSTEM = ''#
cuery.tools.abs.ABS_PROMPT_USER = ''#
class cuery.tools.abs.AspectEntity(/, **data)#

Bases: cuery.Response

Represents an aspect with its sentiment and qualified phrase.

Parameters:

data (Any)

entity: str#

The specific, normalized aspect being evaluated (e.g., ‘ride queues’, ‘food prices’).

sentiment: Literal['positive', 'negative']#

The sentiment associated with the aspect (positive or negative).

reason: str#

‘<standardized_adjective> <entity>’ (e.g., ‘long ride queues’).

Type:

The normalized aspect phrase

category: str | None = None#

Optional category the entity belongs to (e.g., ‘food’, ‘service’, ‘pricing’).

class cuery.tools.abs.AspectEntities(/, **data)#

Bases: cuery.Response

Represents a collection of entities with their sentiments and reasons for assignment.

Parameters:

data (Any)

entities: list[AspectEntity]#

A list of entities with their sentiments and reasons.

class cuery.tools.abs.AspectSentimentExtractor(/, **data)#

Bases: cuery.Tool

Extract entities with sentiments from texts.

Parameters:

data (Any)

texts: collections.abc.Iterable[str | float | None]#

The texts to extract entities from.

instructions: str = ''#

Further instructions from the user for the entity extraction task.

aspect_categories: list[str] | None = None#

Optional list of aspect categories to map entities to (e.g., [‘food’, ‘service’, ‘pricing’]).

response_model: ClassVar[cuery.ResponseClass]#

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

classmethod _coerce_na(v)#

Convert pandas NA/NaN values to None so Pydantic accepts them.

property prompt: cuery.Prompt#

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

Return type:

cuery.Prompt

property context: cuery.AnyContext#
Return type:

cuery.AnyContext