@hashgraphonline/conversational-agent
Version:
Hashgraph Online conversational AI agent implementing HCS-10 communication, HCS-2 registries, and content inscription on Hedera. https://hol.org
59 lines (57 loc) • 1.89 kB
TypeScript
import { EntityAssociation } from '../memory/smart-memory-manager';
import { EntityFormat } from '..';
export interface EntityResolverConfig {
apiKey: string;
modelName?: string;
}
interface ExtractedEntity {
id: string;
name: string;
type: EntityFormat;
transactionId?: string;
}
/**
* LLM-based entity resolver that replaces brittle regex patterns
*/
export declare class EntityResolver {
private llm;
private logger;
constructor(config: EntityResolverConfig);
/**
* Resolve entity references using LLM instead of regex
*/
resolveReferences(message: string, entities: EntityAssociation[]): Promise<string>;
/**
* Extract entities from agent response using receipt data (preferred) or LLM fallback
*/
extractEntities(response: unknown, userMessage: string): Promise<ExtractedEntity[]>;
/**
* Extract entities from transaction receipt data (primary method)
*/
private extractFromReceipt;
/**
* Extract entity name from user message
*/
private extractNameFromMessage;
/**
* Extract entities using LLM (fallback method)
*/
private extractWithLLM;
/**
* Validate that an entity matches the expected type
*/
validateEntityType(entityId: string, expectedType: string, entities: EntityAssociation[]): boolean;
/**
* Resolve entity references with type validation
*/
resolveWithTypeValidation(query: string, entities: EntityAssociation[], expectedType?: string): Promise<EntityAssociation[]>;
/**
* Get entities filtered by type
*/
getEntitiesByType(entities: EntityAssociation[], entityType: string): EntityAssociation[];
/**
* Find the most recent entity of a specific type
*/
getMostRecentEntityByType(entities: EntityAssociation[], entityType: string): EntityAssociation | null;
}
export {};